Skip to content

future proof rom loading for cross versiom migration

Michael S. Tsirkin qemu-devel 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest2 patches 10 repliesIn review
  2. v32 patches 12 repliesSuperseded
  3. v22 patches 6 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v12 patches5 repliesSuperseded

Changes in v4 from the cover letter

- drop new API, all changes are now internal to memory subsystem Patch 1/2 is new. Patch 2/2 had minor changes.
At laszlo's request (offline), here's the diff of patch 2/2 from v3 to v4:
diff --git a/hw/core/loader.c b/hw/core/loader.c index 32d807a..7b3d3ee 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -610,15 +610,10 @@ static void rom_insert(Rom *rom)

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2arch_init: align MR size to target page sizearch_init.c+2 -15 replies
2/2loader: store FW CFG ROM files in RAMhw/core/loader.c hw/i386/pc_piix.c hw/i386/pc_q35.c +1 more+51 -34 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchLaszlo Ersek
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [Qemu-devel] [PATCH v4 0/2] future proof rom loading for cross versiom migration

Changes from v3:
- drop new API, all changes are now internal to memory subsystem Patch 1/2 is new. Patch 2/2 had minor changes.
At laszlo's request (offline), here's the diff of patch 2/2 from v3 to v4:
diff --git a/hw/core/loader.c b/hw/core/loader.c index 32d807a..7b3d3ee 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -610,15 +610,10 @@ static void rom_insert(Rom *rom)

static void *rom_set_mr(Rom *rom, Object *owner, const char *name) {
- /*
- * Migration code expects that all RAM blocks are full pages.
- * Round MR size up to satisfy this condition.
- */
- unsigned size = ROUND_UP(rom->datasize, qemu_migration_page_size());
void *data;

rom->mr = g_malloc(sizeof(*rom->mr));
- memory_region_init_ram(rom->mr, owner, name, size);
+ memory_region_init_ram(rom->mr, owner, name, rom->datasize);
memory_region_set_readonly(rom->mr, true); vmstate_register_ram_global(rom->mr);

Changes from v2: address comments on v2 by Peter Maydell
- switch from global constant to function
- use memory_region_init_ram instead of _ram_ptr
- disable for 1.6

Changes from v1: address comments by Peter Maydell
- drop useless data=data line
- rename target_page_size to migration_page_size to make use clear Peter, you also suggested somehow hiding this within memory core. I don't see a clean way to do this without lots of code changes, I think what I propose here is acceptable for now and we can always rework APIs without wire format changes.

Please review, and consider for merging.

Original cover letter below.

ROM files that are put in FW CFG are copied to guest ram, by BIOS, but they are not backed by RAM so they don't get migrated.

Each time we'll change at least two bytes in such a ROM this will break cross-version migration: since we can migrate after BIOS has read the first byte but before it has read the second one, getting an inconsistent state.

This patchset makes QEMU future-proof against such changes.

Naturally, this only helps for -M 1.7 and up, older machine types will still have the cross-version migration bug.

I think this should be applied for 1.7, this way we won't have this problem from 1.8 and on.

Note: compatibility code depends on patch 'pc: cleanup 1.4 compat support' to work correctly for machine types 1.5 and back.

Michael S. Tsirkin (2):
arch_init: align MR size to target page size
loader: store FW CFG ROM files in RAM

 arch_init.c         |  3 ++-
 hw/core/loader.c    | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
 hw/i386/pc_piix.c   |  2 ++
 hw/i386/pc_q35.c    |  2 ++
 include/hw/loader.h |  1 +
 5 files changed, 53 insertions(+), 4 deletions(-)
Signature · 1 line
MST