diff options
author | David Hildenbrand <david@redhat.com> | 2021-04-29 13:27:06 +0200 |
---|---|---|
committer | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2021-05-13 18:21:14 +0100 |
commit | 898ba906ccb85ba17d65e64a31cc13128803ef86 (patch) | |
tree | 1093d1525e1588c44424e9f3663f6c29ceb1a2a9 /include | |
parent | 6a23f6399a1f8807447f8680f80e4d536522683e (diff) | |
download | qemu-898ba906ccb85ba17d65e64a31cc13128803ef86.zip qemu-898ba906ccb85ba17d65e64a31cc13128803ef86.tar.gz qemu-898ba906ccb85ba17d65e64a31cc13128803ef86.tar.bz2 |
migration/ram: Handle RAM block resizes during postcopy
Resizing while migrating is dangerous and does not work as expected.
The whole migration code works with the usable_length of a ram block and
does not expect this value to change at random points in time.
In the case of postcopy, relying on used_length is racy as soon as the
guest is running. Also, when used_length changes we might leave the
uffd handler registered for some memory regions, reject valid pages
when migrating and fail when sending the recv bitmap to the source.
Resizing can be trigger *after* (but not during) a reset in
ACPI code by the guest
- hw/arm/virt-acpi-build.c:acpi_ram_update()
- hw/i386/acpi-build.c:acpi_ram_update()
Let's remember the original used_length in a separate variable and
use it in relevant postcopy code. Make sure to update it when we resize
during precopy, when synchronizing the RAM block sizes with the source.
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210429112708.12291-9-david@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/exec/ramblock.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/exec/ramblock.h b/include/exec/ramblock.h index 07d5086..664701b 100644 --- a/include/exec/ramblock.h +++ b/include/exec/ramblock.h @@ -59,6 +59,16 @@ struct RAMBlock { */ unsigned long *clear_bmap; uint8_t clear_bmap_shift; + + /* + * RAM block length that corresponds to the used_length on the migration + * source (after RAM block sizes were synchronized). Especially, after + * starting to run the guest, used_length and postcopy_length can differ. + * Used to register/unregister uffd handlers and as the size of the received + * bitmap. Receiving any page beyond this length will bail out, as it + * could not have been valid on the source. + */ + ram_addr_t postcopy_length; }; #endif #endif |