mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
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>
This commit is contained in:
parent
6a23f6399a
commit
898ba906cc
3 changed files with 31 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue