The migration stream assumes that the set of migratable RAMBlocks does not change while migration is running. Assert that RAMBlocks are not made migratable or non-migratable during migration, and that migratable RAMBlocks are not freed during migration.
Non-migratable RAMBlocks may still be allocated or freed during migration; for example, QMP object-add of memory-backend-ram creates a non-migratable RAMBlock without exposing it to the guest. Signed-off-by: Akihiko Odaki <[email protected]> --- system/physmem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/system/physmem.c b/system/physmem.c index 7bcbf8757361..42a39141645e 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -39,6 +39,7 @@ #include "hw/core/qdev.h" #include "hw/core/qdev-properties.h" #include "hw/core/boards.h" +#include "migration/misc.h" #include "system/xen.h" #include "system/kvm.h" #include "system/tcg.h" @@ -1911,11 +1912,13 @@ bool qemu_ram_is_migratable(const RAMBlock *rb) void qemu_ram_set_migratable(RAMBlock *rb) { + assert(!migration_is_running()); rb->flags |= RAM_MIGRATABLE; } void qemu_ram_unset_migratable(RAMBlock *rb) { + assert(!migration_is_running()); rb->flags &= ~RAM_MIGRATABLE; } @@ -2599,6 +2602,8 @@ void qemu_ram_free(RAMBlock *block) return; } + assert(!migration_is_running() || !qemu_ram_is_migratable(block)); + if (block->host) { ram_block_notify_remove(block->host, block->used_length, block->max_length); --- base-commit: 2db91528542672cf0db78b3f2cc0e22b36302b38 change-id: 20260602-migration-15128dbe4036 Best regards, -- Akihiko Odaki <[email protected]>
