Skip to content

Commit b42f281

Browse files
Steve SistareFabiano Rosas
authored andcommitted
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 <[email protected]> Reviewed-by: Fabiano Rosas <[email protected]> Message-ID: <[email protected]> Signed-off-by: Fabiano Rosas <[email protected]>
1 parent e56ba18 commit b42f281

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

hw/core/loader.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "trace.h"
5252
#include "hw/hw.h"
5353
#include "disas/disas.h"
54+
#include "migration/cpr.h"
5455
#include "migration/vmstate.h"
5556
#include "monitor/monitor.h"
5657
#include "system/reset.h"
@@ -1029,7 +1030,9 @@ static void *rom_set_mr(Rom *rom, Object *owner, const char *name, bool ro)
10291030
vmstate_register_ram_global(rom->mr);
10301031

10311032
data = memory_region_get_ram_ptr(rom->mr);
1032-
memcpy(data, rom->data, rom->datasize);
1033+
if (!cpr_is_incoming()) {
1034+
memcpy(data, rom->data, rom->datasize);
1035+
}
10331036

10341037
return data;
10351038
}

0 commit comments

Comments
 (0)