aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Sistare <steven.sistare@oracle.com>2025-03-07 12:55:53 -0800
committerFabiano Rosas <farosas@suse.de>2025-03-14 09:29:19 -0300
commitb42f28111e081ab1fd370e92ee78a461027590f0 (patch)
tree40744c779a6630a9ea94129e40d6c4568b1524df
parente56ba1878fefe7babff76ff399311ae5e399c5c5 (diff)
downloadqemu-b42f28111e081ab1fd370e92ee78a461027590f0.zip
qemu-b42f28111e081ab1fd370e92ee78a461027590f0.tar.gz
qemu-b42f28111e081ab1fd370e92ee78a461027590f0.tar.bz2
hw/loader: fix roms during cpr
During normal migration, new QEMU creates and initializes memory regions, then loads the preserved contents of the region from vmstate. During CPR, memory regions are preserved in place, then the realize method initializes the regions contents, losing the old contents. To fix, skip the re-init during CPR. Signed-off-by: Steve Sistare <steven.sistare@oracle.com> Reviewed-by: Fabiano Rosas <farosas@suse.de> Message-ID: <1741380954-341079-4-git-send-email-steven.sistare@oracle.com> Signed-off-by: Fabiano Rosas <farosas@suse.de>
-rw-r--r--hw/core/loader.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 332b879..ce6ff1b 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -51,6 +51,7 @@
#include "trace.h"
#include "hw/hw.h"
#include "disas/disas.h"
+#include "migration/cpr.h"
#include "migration/vmstate.h"
#include "monitor/monitor.h"
#include "system/reset.h"
@@ -1029,7 +1030,9 @@ static void *rom_set_mr(Rom *rom, Object *owner, const char *name, bool ro)
vmstate_register_ram_global(rom->mr);
data = memory_region_get_ram_ptr(rom->mr);
- memcpy(data, rom->data, rom->datasize);
+ if (!cpr_is_incoming()) {
+ memcpy(data, rom->data, rom->datasize);
+ }
return data;
}