All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] memory: Remove most _nomigrate variants
@ 2026-01-29 16:20 BALATON Zoltan
  2026-01-29 16:20 ` [PATCH 1/4] memory: Remove memory_region_init_rom_device_nomigrate() BALATON Zoltan
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: BALATON Zoltan @ 2026-01-29 16:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Xu, Akihiko Odaki, Paolo Bonzini, Mark Cave-Ayland,
	Gerd Hoffmann, Max Filippov, Philippe Mathieu-Daudé

OK, let's start with some clean up to simplify memory region API. The
_nomigrate variants are rarely needed, some of them are already unused
so remove them standardising on memory_region_init_ram_flags_nomigrate()
for the few cases where this is really needed.

BALATON Zoltan (4):
  memory: Remove memory_region_init_rom_device_nomigrate()
  hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
  memory: Remove memory_region_init_rom_nomigrate()
  memory: Remove memory_region_init_ram_nomigrate()

 docs/devel/memory.rst                         | 10 +--
 hw/display/cg3.c                              |  5 +-
 hw/display/tcx.c                              | 10 +--
 hw/display/vga.c                              |  4 +-
 hw/sparc/sun4m.c                              | 15 ++--
 hw/sparc64/sun4u.c                            |  9 ++-
 hw/xtensa/xtfpga.c                            |  4 +-
 include/system/memory.h                       | 76 -------------------
 .../memory-region-housekeeping.cocci          | 42 +---------
 system/memory.c                               | 73 +++++-------------
 10 files changed, 47 insertions(+), 201 deletions(-)

-- 
2.41.3



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/4] memory: Remove memory_region_init_rom_device_nomigrate()
  2026-01-29 16:20 [PATCH 0/4] memory: Remove most _nomigrate variants BALATON Zoltan
@ 2026-01-29 16:20 ` BALATON Zoltan
  2026-01-29 23:29   ` Philippe Mathieu-Daudé
  2026-01-29 16:20 ` [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate() BALATON Zoltan
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: BALATON Zoltan @ 2026-01-29 16:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Xu, Akihiko Odaki, Paolo Bonzini, Mark Cave-Ayland,
	Gerd Hoffmann, Max Filippov, Philippe Mathieu-Daudé

This function is never used, remove it.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 docs/devel/memory.rst                         |  1 -
 include/system/memory.h                       | 27 ------------
 .../memory-region-housekeeping.cocci          |  8 ----
 system/memory.c                               | 41 ++++++-------------
 4 files changed, 13 insertions(+), 64 deletions(-)

diff --git a/docs/devel/memory.rst b/docs/devel/memory.rst
index f22146e56c..8558f70a42 100644
--- a/docs/devel/memory.rst
+++ b/docs/devel/memory.rst
@@ -114,7 +114,6 @@ the backing memory yourself, you can call the functions:
 
 - memory_region_init_ram_nomigrate()
 - memory_region_init_rom_nomigrate()
-- memory_region_init_rom_device_nomigrate()
 
 which only initialize the MemoryRegion and leave handling
 migration to the caller.
diff --git a/include/system/memory.h b/include/system/memory.h
index 8f8725ea2d..0562af3136 100644
--- a/include/system/memory.h
+++ b/include/system/memory.h
@@ -1614,33 +1614,6 @@ bool memory_region_init_rom_nomigrate(MemoryRegion *mr,
                                       uint64_t size,
                                       Error **errp);
 
-/**
- * memory_region_init_rom_device_nomigrate:  Initialize a ROM memory region.
- *                                 Writes are handled via callbacks.
- *
- * Note that this function does not do anything to cause the data in the
- * RAM side of the memory region to be migrated; that is the responsibility
- * of the caller.
- *
- * @mr: the #MemoryRegion to be initialized.
- * @owner: the object that tracks the region's reference count
- * @ops: callbacks for write access handling (must not be NULL).
- * @opaque: passed to the read and write callbacks of the @ops structure.
- * @name: Region name, becomes part of RAMBlock name used in migration stream
- *        must be unique within any device
- * @size: size of the region.
- * @errp: pointer to Error*, to store an error if it happens.
- *
- * Return: true on success, else false setting @errp with error.
- */
-bool memory_region_init_rom_device_nomigrate(MemoryRegion *mr,
-                                             Object *owner,
-                                             const MemoryRegionOps *ops,
-                                             void *opaque,
-                                             const char *name,
-                                             uint64_t size,
-                                             Error **errp);
-
 /**
  * memory_region_init_iommu: Initialize a memory region of a custom type
  * that translates addresses
diff --git a/scripts/coccinelle/memory-region-housekeeping.cocci b/scripts/coccinelle/memory-region-housekeeping.cocci
index 29651ebde9..7f89e9712e 100644
--- a/scripts/coccinelle/memory-region-housekeeping.cocci
+++ b/scripts/coccinelle/memory-region-housekeeping.cocci
@@ -97,14 +97,6 @@ expression NAME;
 expression SIZE;
 expression ERRP;
 @@
--memory_region_init_rom_device_nomigrate(MR, NULL, OPS, OPAQUE, NAME, SIZE, ERRP);
-+memory_region_init_rom_device(MR, NULL, OPS, OPAQUE, NAME, SIZE, ERRP);
- ...
--vmstate_register_ram_global(MR);
-
-
-// Device is owner
-@@
 typedef DeviceState;
 identifier device_fn, dev, obj;
 expression E1, E2, E3, E4, E5;
diff --git a/system/memory.c b/system/memory.c
index 4bf00d82bc..a9032fb2cf 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -1748,32 +1748,6 @@ bool memory_region_init_rom_nomigrate(MemoryRegion *mr,
     return true;
 }
 
-bool memory_region_init_rom_device_nomigrate(MemoryRegion *mr,
-                                             Object *owner,
-                                             const MemoryRegionOps *ops,
-                                             void *opaque,
-                                             const char *name,
-                                             uint64_t size,
-                                             Error **errp)
-{
-    Error *err = NULL;
-    assert(ops);
-    memory_region_init(mr, owner, name, size);
-    mr->ops = ops;
-    mr->opaque = opaque;
-    mr->terminates = true;
-    mr->rom_device = true;
-    mr->destructor = memory_region_destructor_ram;
-    mr->ram_block = qemu_ram_alloc(size, 0, mr, &err);
-    if (err) {
-        mr->size = int128_zero();
-        object_unparent(OBJECT(mr));
-        error_propagate(errp, err);
-        return false;
-    }
-    return true;
-}
-
 void memory_region_init_iommu(void *_iommu_mr,
                               size_t instance_size,
                               const char *mrtypename,
@@ -3802,9 +3776,20 @@ bool memory_region_init_rom_device(MemoryRegion *mr,
                                    Error **errp)
 {
     DeviceState *owner_dev;
+    Error *err = NULL;
 
-    if (!memory_region_init_rom_device_nomigrate(mr, owner, ops, opaque,
-                                                 name, size, errp)) {
+    assert(ops);
+    memory_region_init(mr, owner, name, size);
+    mr->ops = ops;
+    mr->opaque = opaque;
+    mr->terminates = true;
+    mr->rom_device = true;
+    mr->destructor = memory_region_destructor_ram;
+    mr->ram_block = qemu_ram_alloc(size, 0, mr, &err);
+    if (err) {
+        mr->size = int128_zero();
+        object_unparent(OBJECT(mr));
+        error_propagate(errp, err);
         return false;
     }
     /* This will assert if owner is neither NULL nor a DeviceState.
-- 
2.41.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
  2026-01-29 16:20 [PATCH 0/4] memory: Remove most _nomigrate variants BALATON Zoltan
  2026-01-29 16:20 ` [PATCH 1/4] memory: Remove memory_region_init_rom_device_nomigrate() BALATON Zoltan
@ 2026-01-29 16:20 ` BALATON Zoltan
  2026-01-29 16:30   ` Peter Maydell
  2026-01-29 16:20 ` [PATCH 3/4] memory: Remove memory_region_init_rom_nomigrate() BALATON Zoltan
  2026-01-29 16:20 ` [PATCH 4/4] memory: Remove memory_region_init_ram_nomigrate() BALATON Zoltan
  3 siblings, 1 reply; 14+ messages in thread
From: BALATON Zoltan @ 2026-01-29 16:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Xu, Akihiko Odaki, Paolo Bonzini, Mark Cave-Ayland,
	Gerd Hoffmann, Max Filippov, Philippe Mathieu-Daudé

Nothing else does this, convert to regular memory_region_init_rom().

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 hw/display/cg3.c | 5 ++---
 hw/display/tcx.c | 5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/hw/display/cg3.c b/hw/display/cg3.c
index 568d6048a6..61bdb0552e 100644
--- a/hw/display/cg3.c
+++ b/hw/display/cg3.c
@@ -282,8 +282,8 @@ static void cg3_initfn(Object *obj)
     SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
     CG3State *s = CG3(obj);
 
-    memory_region_init_rom_nomigrate(&s->rom, obj, "cg3.prom",
-                                     FCODE_MAX_ROM_SIZE, &error_fatal);
+    memory_region_init_rom(&s->rom, obj, "cg3.prom", FCODE_MAX_ROM_SIZE,
+                           &error_fatal);
     sysbus_init_mmio(sbd, &s->rom);
 
     memory_region_init_io(&s->reg, obj, &cg3_reg_ops, s, "cg3.reg",
@@ -299,7 +299,6 @@ static void cg3_realizefn(DeviceState *dev, Error **errp)
     char *fcode_filename;
 
     /* FCode ROM */
-    vmstate_register_ram_global(&s->rom);
     fcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, CG3_ROM_FILE);
     if (fcode_filename) {
         ret = load_image_mr(fcode_filename, &s->rom);
diff --git a/hw/display/tcx.c b/hw/display/tcx.c
index 36cad82abd..16114b9bb8 100644
--- a/hw/display/tcx.c
+++ b/hw/display/tcx.c
@@ -756,8 +756,8 @@ static void tcx_initfn(Object *obj)
     SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
     TCXState *s = TCX(obj);
 
-    memory_region_init_rom_nomigrate(&s->rom, obj, "tcx.prom",
-                                     FCODE_MAX_ROM_SIZE, &error_fatal);
+    memory_region_init_rom(&s->rom, obj, "tcx.prom", FCODE_MAX_ROM_SIZE,
+                           &error_fatal);
     sysbus_init_mmio(sbd, &s->rom);
 
     /* 2/STIP : Stippler */
@@ -822,7 +822,6 @@ static void tcx_realizefn(DeviceState *dev, Error **errp)
     vram_base = memory_region_get_ram_ptr(&s->vram_mem);
 
     /* 10/ROM : FCode ROM */
-    vmstate_register_ram_global(&s->rom);
     fcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, TCX_ROM_FILE);
     if (fcode_filename) {
         ret = load_image_mr(fcode_filename, &s->rom);
-- 
2.41.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/4] memory: Remove memory_region_init_rom_nomigrate()
  2026-01-29 16:20 [PATCH 0/4] memory: Remove most _nomigrate variants BALATON Zoltan
  2026-01-29 16:20 ` [PATCH 1/4] memory: Remove memory_region_init_rom_device_nomigrate() BALATON Zoltan
  2026-01-29 16:20 ` [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate() BALATON Zoltan
@ 2026-01-29 16:20 ` BALATON Zoltan
  2026-01-29 16:20 ` [PATCH 4/4] memory: Remove memory_region_init_ram_nomigrate() BALATON Zoltan
  3 siblings, 0 replies; 14+ messages in thread
From: BALATON Zoltan @ 2026-01-29 16:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Xu, Akihiko Odaki, Paolo Bonzini, Mark Cave-Ayland,
	Gerd Hoffmann, Max Filippov, Philippe Mathieu-Daudé

All users were converted to memory_region_init_rom() so no longer
needed.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 docs/devel/memory.rst                         |  1 -
 include/system/memory.h                       | 26 -------------------
 .../memory-region-housekeeping.cocci          | 16 ------------
 system/memory.c                               | 19 +++-----------
 4 files changed, 3 insertions(+), 59 deletions(-)

diff --git a/docs/devel/memory.rst b/docs/devel/memory.rst
index 8558f70a42..0bb5acab21 100644
--- a/docs/devel/memory.rst
+++ b/docs/devel/memory.rst
@@ -113,7 +113,6 @@ have a special case where you need to manage the migration of
 the backing memory yourself, you can call the functions:
 
 - memory_region_init_ram_nomigrate()
-- memory_region_init_rom_nomigrate()
 
 which only initialize the MemoryRegion and leave handling
 migration to the caller.
diff --git a/include/system/memory.h b/include/system/memory.h
index 0562af3136..7117699b10 100644
--- a/include/system/memory.h
+++ b/include/system/memory.h
@@ -1588,32 +1588,6 @@ void memory_region_init_alias(MemoryRegion *mr,
                               hwaddr offset,
                               uint64_t size);
 
-/**
- * memory_region_init_rom_nomigrate: Initialize a ROM memory region.
- *
- * This has the same effect as calling memory_region_init_ram_nomigrate()
- * and then marking the resulting region read-only with
- * memory_region_set_readonly().
- *
- * Note that this function does not do anything to cause the data in the
- * RAM side of the memory region to be migrated; that is the responsibility
- * of the caller.
- *
- * @mr: the #MemoryRegion to be initialized.
- * @owner: the object that tracks the region's reference count
- * @name: Region name, becomes part of RAMBlock name used in migration stream
- *        must be unique within any device
- * @size: size of the region.
- * @errp: pointer to Error*, to store an error if it happens.
- *
- * Return: true on success, else false setting @errp with error.
- */
-bool memory_region_init_rom_nomigrate(MemoryRegion *mr,
-                                      Object *owner,
-                                      const char *name,
-                                      uint64_t size,
-                                      Error **errp);
-
 /**
  * memory_region_init_iommu: Initialize a memory region of a custom type
  * that translates addresses
diff --git a/scripts/coccinelle/memory-region-housekeeping.cocci b/scripts/coccinelle/memory-region-housekeeping.cocci
index 7f89e9712e..8ec9a06c18 100644
--- a/scripts/coccinelle/memory-region-housekeeping.cocci
+++ b/scripts/coccinelle/memory-region-housekeeping.cocci
@@ -16,17 +16,10 @@
 expression E1, E2, E3, E4, E5;
 symbol true;
 @@
-(
 - memory_region_init_ram(E1, E2, E3, E4, E5);
 + memory_region_init_rom(E1, E2, E3, E4, E5);
   ... WHEN != E1
 - memory_region_set_readonly(E1, true);
-|
-- memory_region_init_ram_nomigrate(E1, E2, E3, E4, E5);
-+ memory_region_init_rom_nomigrate(E1, E2, E3, E4, E5);
-  ... WHEN != E1
-- memory_region_set_readonly(E1, true);
-)
 
 
 @possible_memory_region_init_rom@
@@ -53,11 +46,7 @@ cocci.print_main("potential use of memory_region_init_rom*() in ", p)
 expression ROM, E1, E2, E3, E4;
 expression ALIAS, E5, E6, E7, E8;
 @@
-(
   memory_region_init_rom(ROM, E1, E2, E3, E4);
-|
-  memory_region_init_rom_nomigrate(ROM, E1, E2, E3, E4);
-)
   ...
    memory_region_init_alias(ALIAS, E5, E6, ROM, E7, E8);
 -  memory_region_set_readonly(ALIAS, true);
@@ -85,11 +74,6 @@ expression NAME;
 expression SIZE;
 expression ERRP;
 @@
--memory_region_init_rom_nomigrate(MR, NULL, NAME, SIZE, ERRP);
-+memory_region_init_rom(MR, NULL, NAME, SIZE, ERRP);
- ...
--vmstate_register_ram_global(MR);
-@@
 expression MR;
 expression OPS;
 expression OPAQUE;
diff --git a/system/memory.c b/system/memory.c
index a9032fb2cf..b2b00ba7b4 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -1733,21 +1733,6 @@ void memory_region_init_alias(MemoryRegion *mr,
     mr->alias_offset = offset;
 }
 
-bool memory_region_init_rom_nomigrate(MemoryRegion *mr,
-                                      Object *owner,
-                                      const char *name,
-                                      uint64_t size,
-                                      Error **errp)
-{
-    if (!memory_region_init_ram_flags_nomigrate(mr, owner, name,
-                                                size, 0, errp)) {
-         return false;
-    }
-    mr->readonly = true;
-
-    return true;
-}
-
 void memory_region_init_iommu(void *_iommu_mr,
                               size_t instance_size,
                               const char *mrtypename,
@@ -3752,9 +3737,11 @@ bool memory_region_init_rom(MemoryRegion *mr,
 {
     DeviceState *owner_dev;
 
-    if (!memory_region_init_rom_nomigrate(mr, owner, name, size, errp)) {
+    if (!memory_region_init_ram_flags_nomigrate(mr, owner, name,
+                                                size, 0, errp)) {
         return false;
     }
+    mr->readonly = true;
     /* This will assert if owner is neither NULL nor a DeviceState.
      * We only want the owner here for the purposes of defining a
      * unique name for migration. TODO: Ideally we should implement
-- 
2.41.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/4] memory: Remove memory_region_init_ram_nomigrate()
  2026-01-29 16:20 [PATCH 0/4] memory: Remove most _nomigrate variants BALATON Zoltan
                   ` (2 preceding siblings ...)
  2026-01-29 16:20 ` [PATCH 3/4] memory: Remove memory_region_init_rom_nomigrate() BALATON Zoltan
@ 2026-01-29 16:20 ` BALATON Zoltan
  3 siblings, 0 replies; 14+ messages in thread
From: BALATON Zoltan @ 2026-01-29 16:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Xu, Akihiko Odaki, Paolo Bonzini, Mark Cave-Ayland,
	Gerd Hoffmann, Max Filippov, Philippe Mathieu-Daudé

This is rarely needed and those cases can use
memory_region_init_ram_flags_nomigrate() instead which is now the only
_nomigrate variant left. (Some of these may better be converted to use
memory_region_init_ram() but I don't know so left them as they are.)

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 docs/devel/memory.rst                         |  8 +++----
 hw/display/tcx.c                              |  5 ++--
 hw/display/vga.c                              |  4 ++--
 hw/sparc/sun4m.c                              | 15 +++++++-----
 hw/sparc64/sun4u.c                            |  9 ++++----
 hw/xtensa/xtfpga.c                            |  4 ++--
 include/system/memory.h                       | 23 -------------------
 .../memory-region-housekeeping.cocci          | 18 +--------------
 system/memory.c                               | 13 ++---------
 9 files changed, 27 insertions(+), 72 deletions(-)

diff --git a/docs/devel/memory.rst b/docs/devel/memory.rst
index 0bb5acab21..9083b18f08 100644
--- a/docs/devel/memory.rst
+++ b/docs/devel/memory.rst
@@ -110,11 +110,9 @@ migrated:
 
 For most devices and boards this is the correct thing. If you
 have a special case where you need to manage the migration of
-the backing memory yourself, you can call the functions:
-
-- memory_region_init_ram_nomigrate()
-
-which only initialize the MemoryRegion and leave handling
+the backing memory yourself, you can call the function
+memory_region_init_ram_flags_nomigrate()
+which only initializes the MemoryRegion and leaves handling
 migration to the caller.
 
 The functions:
diff --git a/hw/display/tcx.c b/hw/display/tcx.c
index 16114b9bb8..0ff73f823a 100644
--- a/hw/display/tcx.c
+++ b/hw/display/tcx.c
@@ -815,8 +815,9 @@ static void tcx_realizefn(DeviceState *dev, Error **errp)
     uint8_t *vram_base;
     char *fcode_filename;
 
-    memory_region_init_ram_nomigrate(&s->vram_mem, OBJECT(s), "tcx.vram",
-                           s->vram_size * (1 + 4 + 4), &error_fatal);
+    memory_region_init_ram_flags_nomigrate(&s->vram_mem, OBJECT(s), "tcx.vram",
+                                           s->vram_size * (1 + 4 + 4), 0,
+                                           &error_fatal);
     vmstate_register_ram_global(&s->vram_mem);
     memory_region_set_log(&s->vram_mem, true, DIRTY_MEMORY_VGA);
     vram_base = memory_region_get_ram_ptr(&s->vram_mem);
diff --git a/hw/display/vga.c b/hw/display/vga.c
index 59a65cbbff..ee7d97b5c2 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -2235,8 +2235,8 @@ bool vga_common_init(VGACommonState *s, Object *obj, Error **errp)
         return false;
     }
 
-    memory_region_init_ram_nomigrate(&s->vram, obj, "vga.vram", s->vram_size,
-                                     &local_err);
+    memory_region_init_ram_flags_nomigrate(&s->vram, obj, "vga.vram",
+                                           s->vram_size, 0, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         return false;
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 0c0d658d30..66a21ae86c 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -587,8 +587,10 @@ static void idreg_realize(DeviceState *ds, Error **errp)
     IDRegState *s = MACIO_ID_REGISTER(ds);
     SysBusDevice *dev = SYS_BUS_DEVICE(ds);
 
-    if (!memory_region_init_ram_nomigrate(&s->mem, OBJECT(ds), "sun4m.idreg",
-                                          sizeof(idreg_data), errp)) {
+    if (!memory_region_init_ram_flags_nomigrate(&s->mem, OBJECT(ds),
+                                                "sun4m.idreg",
+                                                sizeof(idreg_data),
+                                                0, errp)) {
         return;
     }
 
@@ -638,8 +640,8 @@ static void afx_realize(DeviceState *ds, Error **errp)
     AFXState *s = TCX_AFX(ds);
     SysBusDevice *dev = SYS_BUS_DEVICE(ds);
 
-    if (!memory_region_init_ram_nomigrate(&s->mem, OBJECT(ds), "sun4m.afx",
-                                          4, errp)) {
+    if (!memory_region_init_ram_flags_nomigrate(&s->mem, OBJECT(ds),
+                                                "sun4m.afx", 4, 0, errp)) {
         return;
     }
 
@@ -719,8 +721,9 @@ static void prom_realize(DeviceState *ds, Error **errp)
     PROMState *s = OPENPROM(ds);
     SysBusDevice *dev = SYS_BUS_DEVICE(ds);
 
-    if (!memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4m.prom",
-                                          PROM_SIZE_MAX, errp)) {
+    if (!memory_region_init_ram_flags_nomigrate(&s->prom, OBJECT(ds),
+                                                "sun4m.prom", PROM_SIZE_MAX, 0,
+                                                errp)) {
         return;
     }
 
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 5d7787fc1a..0da0eef74c 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -455,8 +455,9 @@ static void prom_realize(DeviceState *ds, Error **errp)
     PROMState *s = OPENPROM(ds);
     SysBusDevice *dev = SYS_BUS_DEVICE(ds);
 
-    if (!memory_region_init_ram_nomigrate(&s->prom, OBJECT(ds), "sun4u.prom",
-                                          PROM_SIZE_MAX, errp)) {
+    if (!memory_region_init_ram_flags_nomigrate(&s->prom, OBJECT(ds),
+                                                "sun4u.prom", PROM_SIZE_MAX, 0,
+                                                errp)) {
         return;
     }
 
@@ -498,8 +499,8 @@ static void ram_realize(DeviceState *dev, Error **errp)
     RamDevice *d = SUN4U_RAM(dev);
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
 
-    memory_region_init_ram_nomigrate(&d->ram, OBJECT(d), "sun4u.ram", d->size,
-                           &error_fatal);
+    memory_region_init_ram_flags_nomigrate(&d->ram, OBJECT(d), "sun4u.ram",
+                                           d->size, 0, &error_fatal);
     vmstate_register_ram_global(&d->ram);
     sysbus_init_mmio(sbd, &d->ram);
 }
diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index d427d68e50..b025cc53a8 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -163,8 +163,8 @@ static void xtfpga_net_init(MemoryRegion *address_space,
             sysbus_mmio_get_region(s, 1));
 
     ram = g_malloc(sizeof(*ram));
-    memory_region_init_ram_nomigrate(ram, OBJECT(s), "open_eth.ram", 16 * KiB,
-                           &error_fatal);
+    memory_region_init_ram_flags_nomigrate(ram, OBJECT(s), "open_eth.ram",
+                                           16 * KiB, 0, &error_fatal);
     vmstate_register_ram_global(ram);
     memory_region_add_subregion(address_space, buffers, ram);
 }
diff --git a/include/system/memory.h b/include/system/memory.h
index 7117699b10..d4793a08a7 100644
--- a/include/system/memory.h
+++ b/include/system/memory.h
@@ -1374,29 +1374,6 @@ void memory_region_init_io(MemoryRegion *mr,
                            const char *name,
                            uint64_t size);
 
-/**
- * memory_region_init_ram_nomigrate:  Initialize RAM memory region.  Accesses
- *                                    into the region will modify memory
- *                                    directly.
- *
- * @mr: the #MemoryRegion to be initialized.
- * @owner: the object that tracks the region's reference count
- * @name: Region name, becomes part of RAMBlock name used in migration stream
- *        must be unique within any device
- * @size: size of the region.
- * @errp: pointer to Error*, to store an error if it happens.
- *
- * Note that this function does not do anything to cause the data in the
- * RAM memory region to be migrated; that is the responsibility of the caller.
- *
- * Return: true on success, else false setting @errp with error.
- */
-bool memory_region_init_ram_nomigrate(MemoryRegion *mr,
-                                      Object *owner,
-                                      const char *name,
-                                      uint64_t size,
-                                      Error **errp);
-
 /**
  * memory_region_init_ram_flags_nomigrate:  Initialize RAM memory region.
  *                                          Accesses into the region will
diff --git a/scripts/coccinelle/memory-region-housekeeping.cocci b/scripts/coccinelle/memory-region-housekeeping.cocci
index 8ec9a06c18..40a8f7beb1 100644
--- a/scripts/coccinelle/memory-region-housekeeping.cocci
+++ b/scripts/coccinelle/memory-region-housekeeping.cocci
@@ -26,15 +26,9 @@ symbol true;
 expression E1, E2, E3, E4, E5;
 position p;
 @@
-(
   memory_region_init_ram@p(E1, E2, E3, E4, E5);
   ...
   memory_region_set_readonly(E1, true);
-|
-  memory_region_init_ram_nomigrate@p(E1, E2, E3, E4, E5);
-  ...
-  memory_region_set_readonly(E1, true);
-)
 @script:python@
 p << possible_memory_region_init_rom.p;
 @@
@@ -52,7 +46,7 @@ expression ALIAS, E5, E6, E7, E8;
 -  memory_region_set_readonly(ALIAS, true);
 
 
-// Replace by-hand memory_region_init_ram_nomigrate/vmstate_register_ram
+// Replace by-hand memory_region_init_ram/vmstate_register_ram
 // code sequences with use of the new memory_region_init_ram function.
 // Similarly for the _rom and _rom_device functions.
 // We don't try to replace sequences with a non-NULL owner, because
@@ -64,16 +58,6 @@ expression NAME;
 expression SIZE;
 expression ERRP;
 @@
--memory_region_init_ram_nomigrate(MR, NULL, NAME, SIZE, ERRP);
-+memory_region_init_ram(MR, NULL, NAME, SIZE, ERRP);
- ...
--vmstate_register_ram_global(MR);
-@@
-expression MR;
-expression NAME;
-expression SIZE;
-expression ERRP;
-@@
 expression MR;
 expression OPS;
 expression OPAQUE;
diff --git a/system/memory.c b/system/memory.c
index b2b00ba7b4..921e96554b 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -1572,16 +1572,6 @@ void memory_region_init_io(MemoryRegion *mr,
     mr->terminates = true;
 }
 
-bool memory_region_init_ram_nomigrate(MemoryRegion *mr,
-                                      Object *owner,
-                                      const char *name,
-                                      uint64_t size,
-                                      Error **errp)
-{
-    return memory_region_init_ram_flags_nomigrate(mr, owner, name,
-                                                  size, 0, errp);
-}
-
 bool memory_region_init_ram_flags_nomigrate(MemoryRegion *mr,
                                             Object *owner,
                                             const char *name,
@@ -3690,7 +3680,8 @@ bool memory_region_init_ram(MemoryRegion *mr,
 {
     DeviceState *owner_dev;
 
-    if (!memory_region_init_ram_nomigrate(mr, owner, name, size, errp)) {
+    if (!memory_region_init_ram_flags_nomigrate(mr, owner, name,
+                                                size, 0, errp)) {
         return false;
     }
     /* This will assert if owner is neither NULL nor a DeviceState.
-- 
2.41.3



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
  2026-01-29 16:20 ` [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate() BALATON Zoltan
@ 2026-01-29 16:30   ` Peter Maydell
  2026-01-29 17:20     ` BALATON Zoltan
  0 siblings, 1 reply; 14+ messages in thread
From: Peter Maydell @ 2026-01-29 16:30 UTC (permalink / raw)
  To: BALATON Zoltan
  Cc: qemu-devel, Peter Xu, Akihiko Odaki, Paolo Bonzini,
	Mark Cave-Ayland, Gerd Hoffmann, Max Filippov,
	Philippe Mathieu-Daudé

On Thu, 29 Jan 2026 at 16:21, BALATON Zoltan <balaton@eik.bme.hu> wrote:
>
> Nothing else does this, convert to regular memory_region_init_rom().

> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
>  hw/display/cg3.c | 5 ++---
>  hw/display/tcx.c | 5 ++---
>  2 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/hw/display/cg3.c b/hw/display/cg3.c
> index 568d6048a6..61bdb0552e 100644
> --- a/hw/display/cg3.c
> +++ b/hw/display/cg3.c
> @@ -282,8 +282,8 @@ static void cg3_initfn(Object *obj)
>      SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
>      CG3State *s = CG3(obj);
>
> -    memory_region_init_rom_nomigrate(&s->rom, obj, "cg3.prom",
> -                                     FCODE_MAX_ROM_SIZE, &error_fatal);
> +    memory_region_init_rom(&s->rom, obj, "cg3.prom", FCODE_MAX_ROM_SIZE,
> +                           &error_fatal);
>      sysbus_init_mmio(sbd, &s->rom);
>
>      memory_region_init_io(&s->reg, obj, &cg3_reg_ops, s, "cg3.reg",
> @@ -299,7 +299,6 @@ static void cg3_realizefn(DeviceState *dev, Error **errp)
>      char *fcode_filename;
>
>      /* FCode ROM */
> -    vmstate_register_ram_global(&s->rom);
>      fcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, CG3_ROM_FILE);
>      if (fcode_filename) {
>          ret = load_image_mr(fcode_filename, &s->rom);

This is a migration compatibility break, because the
memory_region_init_rom() function registers the MR
for migration via vmstate_register_ram(), which picks
an ID string for the memory that includes the path
of the device, whereas vmstate_register_ram_global()
picks an ID string for the memory that does not include
the path of any device. It is this difference that is the
reason why they're still using the _nomigrate functions.

I think it's reasonable to accept a compat break for the purposes
of cleaning up the codebase, because these are used on sparc machine
types and we don't version those, but the commit message needs to
note that this is a compat break.

thanks
-- PMM


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
  2026-01-29 16:30   ` Peter Maydell
@ 2026-01-29 17:20     ` BALATON Zoltan
  2026-01-29 18:19       ` Peter Maydell
  0 siblings, 1 reply; 14+ messages in thread
From: BALATON Zoltan @ 2026-01-29 17:20 UTC (permalink / raw)
  To: Peter Maydell
  Cc: qemu-devel, Peter Xu, Akihiko Odaki, Paolo Bonzini,
	Mark Cave-Ayland, Gerd Hoffmann, Max Filippov,
	Philippe Mathieu-Daudé

On Thu, 29 Jan 2026, Peter Maydell wrote:
> On Thu, 29 Jan 2026 at 16:21, BALATON Zoltan <balaton@eik.bme.hu> wrote:
>>
>> Nothing else does this, convert to regular memory_region_init_rom().
>
>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>> ---
>>  hw/display/cg3.c | 5 ++---
>>  hw/display/tcx.c | 5 ++---
>>  2 files changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/hw/display/cg3.c b/hw/display/cg3.c
>> index 568d6048a6..61bdb0552e 100644
>> --- a/hw/display/cg3.c
>> +++ b/hw/display/cg3.c
>> @@ -282,8 +282,8 @@ static void cg3_initfn(Object *obj)
>>      SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
>>      CG3State *s = CG3(obj);
>>
>> -    memory_region_init_rom_nomigrate(&s->rom, obj, "cg3.prom",
>> -                                     FCODE_MAX_ROM_SIZE, &error_fatal);
>> +    memory_region_init_rom(&s->rom, obj, "cg3.prom", FCODE_MAX_ROM_SIZE,
>> +                           &error_fatal);
>>      sysbus_init_mmio(sbd, &s->rom);
>>
>>      memory_region_init_io(&s->reg, obj, &cg3_reg_ops, s, "cg3.reg",
>> @@ -299,7 +299,6 @@ static void cg3_realizefn(DeviceState *dev, Error **errp)
>>      char *fcode_filename;
>>
>>      /* FCode ROM */
>> -    vmstate_register_ram_global(&s->rom);
>>      fcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, CG3_ROM_FILE);
>>      if (fcode_filename) {
>>          ret = load_image_mr(fcode_filename, &s->rom);
>
> This is a migration compatibility break, because the
> memory_region_init_rom() function registers the MR
> for migration via vmstate_register_ram(), which picks
> an ID string for the memory that includes the path
> of the device, whereas vmstate_register_ram_global()
> picks an ID string for the memory that does not include
> the path of any device. It is this difference that is the
> reason why they're still using the _nomigrate functions.

I thought it might be the case but wasn't sure. How was this handled in 
all other machines where they were converted to not use _nomigrate? Only 
some Sun machines still seem to use this and this may be a good 
opportunity to bring them inline with all other machines.

> I think it's reasonable to accept a compat break for the purposes
> of cleaning up the codebase, because these are used on sparc machine
> types and we don't version those, but the commit message needs to
> note that this is a compat break.

If we accept that then the other memory_region_init_ram_nomigrate usages 
in Sun machines could also be converted. If Mark is not open to that I'm 
inclined to convert these two rom_nomigrate usages to 
memory_region_init_ram_flags_nomigrate + memory_region_set_readonly 
instead but get rid of these other _nomigrate variants anyhow. Let me know 
which way you prefer.

Regards,
BALATON Zoltan


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
  2026-01-29 17:20     ` BALATON Zoltan
@ 2026-01-29 18:19       ` Peter Maydell
  2026-01-29 19:08         ` BALATON Zoltan
  0 siblings, 1 reply; 14+ messages in thread
From: Peter Maydell @ 2026-01-29 18:19 UTC (permalink / raw)
  To: BALATON Zoltan
  Cc: qemu-devel, Peter Xu, Akihiko Odaki, Paolo Bonzini,
	Mark Cave-Ayland, Gerd Hoffmann, Max Filippov,
	Philippe Mathieu-Daudé

On Thu, 29 Jan 2026 at 17:20, BALATON Zoltan <balaton@eik.bme.hu> wrote:
>
> On Thu, 29 Jan 2026, Peter Maydell wrote:
> > On Thu, 29 Jan 2026 at 16:21, BALATON Zoltan <balaton@eik.bme.hu> wrote:
> > This is a migration compatibility break, because the
> > memory_region_init_rom() function registers the MR
> > for migration via vmstate_register_ram(), which picks
> > an ID string for the memory that includes the path
> > of the device, whereas vmstate_register_ram_global()
> > picks an ID string for the memory that does not include
> > the path of any device. It is this difference that is the
> > reason why they're still using the _nomigrate functions.
>
> I thought it might be the case but wasn't sure. How was this handled in
> all other machines where they were converted to not use _nomigrate? Only
> some Sun machines still seem to use this and this may be a good
> opportunity to bring them inline with all other machines.

If I remember correctly, we converted all the machines where
we were happy at the time to have a compat break. The remainder
are not only Sun machines -- you can see in your patch 4 that xtensa
and vga are also affected.

> > I think it's reasonable to accept a compat break for the purposes
> > of cleaning up the codebase, because these are used on sparc machine
> > types and we don't version those, but the commit message needs to
> > note that this is a compat break.
>
> If we accept that then the other memory_region_init_ram_nomigrate usages
> in Sun machines could also be converted. If Mark is not open to that I'm
> inclined to convert these two rom_nomigrate usages to
> memory_region_init_ram_flags_nomigrate + memory_region_set_readonly
> instead

My preference would be to convert all these Sun devices. I think
we're a bit more clear these days that migration compat matters
for versioned machine types but can be (cleanly) broken for
non-versioned machine types: back then it was a bit less of a
well-defined rule.

-- PMM


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
  2026-01-29 18:19       ` Peter Maydell
@ 2026-01-29 19:08         ` BALATON Zoltan
  2026-01-29 20:22           ` Peter Maydell
  0 siblings, 1 reply; 14+ messages in thread
From: BALATON Zoltan @ 2026-01-29 19:08 UTC (permalink / raw)
  To: Peter Maydell
  Cc: qemu-devel, Peter Xu, Akihiko Odaki, Paolo Bonzini,
	Mark Cave-Ayland, Gerd Hoffmann, Max Filippov,
	Philippe Mathieu-Daudé

On Thu, 29 Jan 2026, Peter Maydell wrote:
> On Thu, 29 Jan 2026 at 17:20, BALATON Zoltan <balaton@eik.bme.hu> wrote:
>> On Thu, 29 Jan 2026, Peter Maydell wrote:
>>> On Thu, 29 Jan 2026 at 16:21, BALATON Zoltan <balaton@eik.bme.hu> wrote:
>>> This is a migration compatibility break, because the
>>> memory_region_init_rom() function registers the MR
>>> for migration via vmstate_register_ram(), which picks
>>> an ID string for the memory that includes the path
>>> of the device, whereas vmstate_register_ram_global()
>>> picks an ID string for the memory that does not include
>>> the path of any device. It is this difference that is the
>>> reason why they're still using the _nomigrate functions.
>>
>> I thought it might be the case but wasn't sure. How was this handled in
>> all other machines where they were converted to not use _nomigrate? Only
>> some Sun machines still seem to use this and this may be a good
>> opportunity to bring them inline with all other machines.
>
> If I remember correctly, we converted all the machines where
> we were happy at the time to have a compat break. The remainder
> are not only Sun machines -- you can see in your patch 4 that xtensa
> and vga are also affected.

Well, almost all of the usages are because of the Sun machines and those 
could be easily converted accepting one time migration break. The VGA one 
seems to be because of isa cards which may not have been QOM'ified so 
could not be converted before but maybe could be now but I haven't checked 
and I have no idea about xtensa but if only those few are left that's much 
better. There's one more _nomigrate in hw/m68k/next-cube.c which seems to 
be some shared memory region (not sure why it can't be migrated) and the 
one in backends/hostmem-ram.c which may be the only real place that needs 
this. But those could be taken care of later, converting the Sun machines 
would only leave 2 or 3 usages.

>>> I think it's reasonable to accept a compat break for the purposes
>>> of cleaning up the codebase, because these are used on sparc machine
>>> types and we don't version those, but the commit message needs to
>>> note that this is a compat break.
>>
>> If we accept that then the other memory_region_init_ram_nomigrate usages
>> in Sun machines could also be converted. If Mark is not open to that I'm
>> inclined to convert these two rom_nomigrate usages to
>> memory_region_init_ram_flags_nomigrate + memory_region_set_readonly
>> instead
>
> My preference would be to convert all these Sun devices. I think
> we're a bit more clear these days that migration compat matters
> for versioned machine types but can be (cleanly) broken for
> non-versioned machine types: back then it was a bit less of a
> well-defined rule.

I agree but wait for the maintainer's opinion (and maybe some more review 
on other patches) before doing a v2. (Mark may have some reason like old 
savevm files he may use for testing and does not want to redo them or 
similar to want to keep this but if that's the only reason for using this 
old stuff it might be time to refresh those testing images.)

Regards,
BALATON Zoltan


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
  2026-01-29 19:08         ` BALATON Zoltan
@ 2026-01-29 20:22           ` Peter Maydell
  2026-01-29 22:28             ` BALATON Zoltan
  2026-01-30 19:24             ` Mark Cave-Ayland
  0 siblings, 2 replies; 14+ messages in thread
From: Peter Maydell @ 2026-01-29 20:22 UTC (permalink / raw)
  To: BALATON Zoltan
  Cc: qemu-devel, Peter Xu, Akihiko Odaki, Paolo Bonzini,
	Mark Cave-Ayland, Gerd Hoffmann, Max Filippov,
	Philippe Mathieu-Daudé

On Thu, 29 Jan 2026 at 19:08, BALATON Zoltan <balaton@eik.bme.hu> wrote:
>
> On Thu, 29 Jan 2026, Peter Maydell wrote:
> > On Thu, 29 Jan 2026 at 17:20, BALATON Zoltan <balaton@eik.bme.hu> wrote:
> >> On Thu, 29 Jan 2026, Peter Maydell wrote:
> >>> On Thu, 29 Jan 2026 at 16:21, BALATON Zoltan <balaton@eik.bme.hu> wrote:
> >>> This is a migration compatibility break, because the
> >>> memory_region_init_rom() function registers the MR
> >>> for migration via vmstate_register_ram(), which picks
> >>> an ID string for the memory that includes the path
> >>> of the device, whereas vmstate_register_ram_global()
> >>> picks an ID string for the memory that does not include
> >>> the path of any device. It is this difference that is the
> >>> reason why they're still using the _nomigrate functions.
> >>
> >> I thought it might be the case but wasn't sure. How was this handled in
> >> all other machines where they were converted to not use _nomigrate? Only
> >> some Sun machines still seem to use this and this may be a good
> >> opportunity to bring them inline with all other machines.
> >
> > If I remember correctly, we converted all the machines where
> > we were happy at the time to have a compat break. The remainder
> > are not only Sun machines -- you can see in your patch 4 that xtensa
> > and vga are also affected.
>
> Well, almost all of the usages are because of the Sun machines and those
> could be easily converted accepting one time migration break. The VGA one
> seems to be because of isa cards which may not have been QOM'ified so
> could not be converted before but maybe could be now but I haven't checked

We can't change the the vga usage, because it's a migration compat
break, and you can use vga on x86 PC machines, where we do care
about not breaking migration.

-- PMM


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
  2026-01-29 20:22           ` Peter Maydell
@ 2026-01-29 22:28             ` BALATON Zoltan
  2026-01-30 19:24             ` Mark Cave-Ayland
  1 sibling, 0 replies; 14+ messages in thread
From: BALATON Zoltan @ 2026-01-29 22:28 UTC (permalink / raw)
  To: Peter Maydell
  Cc: qemu-devel, Peter Xu, Akihiko Odaki, Paolo Bonzini,
	Mark Cave-Ayland, Gerd Hoffmann, Max Filippov,
	Philippe Mathieu-Daudé

On Thu, 29 Jan 2026, Peter Maydell wrote:
> On Thu, 29 Jan 2026 at 19:08, BALATON Zoltan <balaton@eik.bme.hu> wrote:
>>
>> On Thu, 29 Jan 2026, Peter Maydell wrote:
>>> On Thu, 29 Jan 2026 at 17:20, BALATON Zoltan <balaton@eik.bme.hu> wrote:
>>>> On Thu, 29 Jan 2026, Peter Maydell wrote:
>>>>> On Thu, 29 Jan 2026 at 16:21, BALATON Zoltan <balaton@eik.bme.hu> wrote:
>>>>> This is a migration compatibility break, because the
>>>>> memory_region_init_rom() function registers the MR
>>>>> for migration via vmstate_register_ram(), which picks
>>>>> an ID string for the memory that includes the path
>>>>> of the device, whereas vmstate_register_ram_global()
>>>>> picks an ID string for the memory that does not include
>>>>> the path of any device. It is this difference that is the
>>>>> reason why they're still using the _nomigrate functions.
>>>>
>>>> I thought it might be the case but wasn't sure. How was this handled in
>>>> all other machines where they were converted to not use _nomigrate? Only
>>>> some Sun machines still seem to use this and this may be a good
>>>> opportunity to bring them inline with all other machines.
>>>
>>> If I remember correctly, we converted all the machines where
>>> we were happy at the time to have a compat break. The remainder
>>> are not only Sun machines -- you can see in your patch 4 that xtensa
>>> and vga are also affected.
>>
>> Well, almost all of the usages are because of the Sun machines and those
>> could be easily converted accepting one time migration break. The VGA one
>> seems to be because of isa cards which may not have been QOM'ified so
>> could not be converted before but maybe could be now but I haven't checked
>
> We can't change the the vga usage, because it's a migration compat
> break, and you can use vga on x86 PC machines, where we do care
> about not breaking migration.

I think pc machines use PCI which would not change so it would only break 
isapc where we probably don't care but I don't intend to change that now. 
Just getting rid of what we can do safely to simplify the 
memory_region_init API is enough for me. The remaining few can be 
considered later but we will likely need some _nomigrate option for 
backends/hostmem-ram.c so we probably can't get rid of them all.

Regards,
BALATON Zoltan


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] memory: Remove memory_region_init_rom_device_nomigrate()
  2026-01-29 16:20 ` [PATCH 1/4] memory: Remove memory_region_init_rom_device_nomigrate() BALATON Zoltan
@ 2026-01-29 23:29   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-01-29 23:29 UTC (permalink / raw)
  To: BALATON Zoltan, qemu-devel
  Cc: Peter Xu, Akihiko Odaki, Paolo Bonzini, Mark Cave-Ayland,
	Gerd Hoffmann, Max Filippov

On 29/1/26 17:20, BALATON Zoltan wrote:
> This function is never used, remove it.
> 
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
>   docs/devel/memory.rst                         |  1 -
>   include/system/memory.h                       | 27 ------------
>   .../memory-region-housekeeping.cocci          |  8 ----
>   system/memory.c                               | 41 ++++++-------------
>   4 files changed, 13 insertions(+), 64 deletions(-)


> -bool memory_region_init_rom_device_nomigrate(MemoryRegion *mr,
> -                                             Object *owner,
> -                                             const MemoryRegionOps *ops,
> -                                             void *opaque,
> -                                             const char *name,
> -                                             uint64_t size,
> -                                             Error **errp)
> -{
> -    Error *err = NULL;
> -    assert(ops);
> -    memory_region_init(mr, owner, name, size);
> -    mr->ops = ops;
> -    mr->opaque = opaque;
> -    mr->terminates = true;
> -    mr->rom_device = true;
> -    mr->destructor = memory_region_destructor_ram;
> -    mr->ram_block = qemu_ram_alloc(size, 0, mr, &err);
> -    if (err) {
> -        mr->size = int128_zero();
> -        object_unparent(OBJECT(mr));
> -        error_propagate(errp, err);
> -        return false;
> -    }
> -    return true;
> -}
> -
>   void memory_region_init_iommu(void *_iommu_mr,
>                                 size_t instance_size,
>                                 const char *mrtypename,
> @@ -3802,9 +3776,20 @@ bool memory_region_init_rom_device(MemoryRegion *mr,
>                                      Error **errp)
>   {
>       DeviceState *owner_dev;
> +    Error *err = NULL;
>   
> -    if (!memory_region_init_rom_device_nomigrate(mr, owner, ops, opaque,
> -                                                 name, size, errp)) {
> +    assert(ops);
> +    memory_region_init(mr, owner, name, size);
> +    mr->ops = ops;
> +    mr->opaque = opaque;
> +    mr->terminates = true;
> +    mr->rom_device = true;
> +    mr->destructor = memory_region_destructor_ram;
> +    mr->ram_block = qemu_ram_alloc(size, 0, mr, &err);
> +    if (err) {
> +        mr->size = int128_zero();
> +        object_unparent(OBJECT(mr));
> +        error_propagate(errp, err);
>           return false;
>       }
>       /* This will assert if owner is neither NULL nor a DeviceState.

The code is actually inlined, not removed. With that clarified:

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
  2026-01-29 20:22           ` Peter Maydell
  2026-01-29 22:28             ` BALATON Zoltan
@ 2026-01-30 19:24             ` Mark Cave-Ayland
  2026-01-30 21:14               ` BALATON Zoltan
  1 sibling, 1 reply; 14+ messages in thread
From: Mark Cave-Ayland @ 2026-01-30 19:24 UTC (permalink / raw)
  To: Peter Maydell, BALATON Zoltan
  Cc: qemu-devel, Peter Xu, Akihiko Odaki, Paolo Bonzini, Gerd Hoffmann,
	Max Filippov, Philippe Mathieu-Daudé

On 29/01/2026 20:22, Peter Maydell wrote:

> On Thu, 29 Jan 2026 at 19:08, BALATON Zoltan <balaton@eik.bme.hu> wrote:
>>
>> On Thu, 29 Jan 2026, Peter Maydell wrote:
>>> On Thu, 29 Jan 2026 at 17:20, BALATON Zoltan <balaton@eik.bme.hu> wrote:
>>>> On Thu, 29 Jan 2026, Peter Maydell wrote:
>>>>> On Thu, 29 Jan 2026 at 16:21, BALATON Zoltan <balaton@eik.bme.hu> wrote:
>>>>> This is a migration compatibility break, because the
>>>>> memory_region_init_rom() function registers the MR
>>>>> for migration via vmstate_register_ram(), which picks
>>>>> an ID string for the memory that includes the path
>>>>> of the device, whereas vmstate_register_ram_global()
>>>>> picks an ID string for the memory that does not include
>>>>> the path of any device. It is this difference that is the
>>>>> reason why they're still using the _nomigrate functions.
>>>>
>>>> I thought it might be the case but wasn't sure. How was this handled in
>>>> all other machines where they were converted to not use _nomigrate? Only
>>>> some Sun machines still seem to use this and this may be a good
>>>> opportunity to bring them inline with all other machines.
>>>
>>> If I remember correctly, we converted all the machines where
>>> we were happy at the time to have a compat break. The remainder
>>> are not only Sun machines -- you can see in your patch 4 that xtensa
>>> and vga are also affected.
>>
>> Well, almost all of the usages are because of the Sun machines and those
>> could be easily converted accepting one time migration break. The VGA one
>> seems to be because of isa cards which may not have been QOM'ified so
>> could not be converted before but maybe could be now but I haven't checked
> 
> We can't change the the vga usage, because it's a migration compat
> break, and you can use vga on x86 PC machines, where we do care
> about not breaking migration.

Yeah. Whilst we don't necessarily guarantee Sun machine migration between QEMU 
versions, I'd still like to keep it if possible. If the Sun machines were the last 
holdout here then I'd say let's just accept the break: however given that it's 
impossible to remove these functions because of VGA then the reasons for breaking 
migration compatibility become much less compelling.


ATB,

Mark.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
  2026-01-30 19:24             ` Mark Cave-Ayland
@ 2026-01-30 21:14               ` BALATON Zoltan
  0 siblings, 0 replies; 14+ messages in thread
From: BALATON Zoltan @ 2026-01-30 21:14 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: Peter Maydell, qemu-devel, Peter Xu, Akihiko Odaki, Paolo Bonzini,
	Gerd Hoffmann, Max Filippov, Philippe Mathieu-Daudé

On Fri, 30 Jan 2026, Mark Cave-Ayland wrote:
> On 29/01/2026 20:22, Peter Maydell wrote:
>> On Thu, 29 Jan 2026 at 19:08, BALATON Zoltan <balaton@eik.bme.hu> wrote:
>>> 
>>> On Thu, 29 Jan 2026, Peter Maydell wrote:
>>>> On Thu, 29 Jan 2026 at 17:20, BALATON Zoltan <balaton@eik.bme.hu> wrote:
>>>>> On Thu, 29 Jan 2026, Peter Maydell wrote:
>>>>>> On Thu, 29 Jan 2026 at 16:21, BALATON Zoltan <balaton@eik.bme.hu> 
>>>>>> wrote:
>>>>>> This is a migration compatibility break, because the
>>>>>> memory_region_init_rom() function registers the MR
>>>>>> for migration via vmstate_register_ram(), which picks
>>>>>> an ID string for the memory that includes the path
>>>>>> of the device, whereas vmstate_register_ram_global()
>>>>>> picks an ID string for the memory that does not include
>>>>>> the path of any device. It is this difference that is the
>>>>>> reason why they're still using the _nomigrate functions.
>>>>> 
>>>>> I thought it might be the case but wasn't sure. How was this handled in
>>>>> all other machines where they were converted to not use _nomigrate? Only
>>>>> some Sun machines still seem to use this and this may be a good
>>>>> opportunity to bring them inline with all other machines.
>>>> 
>>>> If I remember correctly, we converted all the machines where
>>>> we were happy at the time to have a compat break. The remainder
>>>> are not only Sun machines -- you can see in your patch 4 that xtensa
>>>> and vga are also affected.
>>> 
>>> Well, almost all of the usages are because of the Sun machines and those
>>> could be easily converted accepting one time migration break. The VGA one
>>> seems to be because of isa cards which may not have been QOM'ified so
>>> could not be converted before but maybe could be now but I haven't checked
>> 
>> We can't change the the vga usage, because it's a migration compat
>> break, and you can use vga on x86 PC machines, where we do care
>> about not breaking migration.
>
> Yeah. Whilst we don't necessarily guarantee Sun machine migration between 
> QEMU versions, I'd still like to keep it if possible. If the Sun machines 
> were the last holdout here then I'd say let's just accept the break: however 
> given that it's impossible to remove these functions because of VGA then the 
> reasons for breaking migration compatibility become much less compelling.

The Sun machines are pretty much the last ones using these. The 
memory_region_init_rom_nomigrate() function is only used by cg3 and tcx 
and nothing else so if we remove those we already have a migration break 
for these devices so it would be a good time to also convert the Sun 
machines now. The memory_region_init_ram_nomigrate() function is used by 
cg3, tcx, sun4m, sun4u, xtfpga and vga so most of the usage is in Sun 
machines and related devices. I think we could also convert xtfpga used by 
xtensa as that's also not versioned so no migration guarantee but I know 
nothing about that so I'm waiting for some opinion from the maintainers of 
that machine.

In vga the memory_region_init_ram_nomigrate function is used only to keep 
compatibility for old machines based on the global-vmstate property which 
is recognised by VGA, vmware-svga, cirrus-vga and qxl but defaults to 
false for all of these so all machines where we care about migration 
already use the new way and would not break when we converted vga to 
memory_region_init_ram. The global-vmstate property is only set to true in 
hw_compat_2_12 (which probably can be removed because due to auto 
deprecation and Philippe's previous work the oldest visible pc and q35 
machine is currently 5.1). Apart from that global-vmstate is also set to 
true by isa-vga, isa-cirrus-vga and vga-mmio (the last of which is used by 
mips/jazz machine) so we don't have any machines with migration 
compatibility requirement that would prevent removing the usage from vga 
as well if we accept migration break for isa-pc and mips/jazz which I 
think we could but I'd leave that for later to untangle this after at 
least the old no longer needed hw_compat settings are removed from 
hw/core/machine.c.

So besides the vga and xtensa which I think could also be converted all 
remaining usages are in the Sun machines and their display devices and 
converting those are easy that I'm willing to do in this series. In light 
of that would you accept the migration break for the Sun machines to 
remove most of the still active usages of these functions? If I hear back 
from xtensa I can convert that too and vga could be done separately 
afterwards as I think that does not fit the scope of this series but 
there's nothing that makes it impossible to do as no active versioned 
machines still depend on this feature of vga.

Do you know about anybody using migration with these Sun machines that 
would be affected by this change? As we make no guarantee about migration 
compatibility for these it would still not prevent us from changing it but 
if we don't even know about any active users then it's even less critical 
to keep to the old way for these machines when all other machines were 
long converted.

Regards,
BALATON Zoltan


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-01-30 21:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-29 16:20 [PATCH 0/4] memory: Remove most _nomigrate variants BALATON Zoltan
2026-01-29 16:20 ` [PATCH 1/4] memory: Remove memory_region_init_rom_device_nomigrate() BALATON Zoltan
2026-01-29 23:29   ` Philippe Mathieu-Daudé
2026-01-29 16:20 ` [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate() BALATON Zoltan
2026-01-29 16:30   ` Peter Maydell
2026-01-29 17:20     ` BALATON Zoltan
2026-01-29 18:19       ` Peter Maydell
2026-01-29 19:08         ` BALATON Zoltan
2026-01-29 20:22           ` Peter Maydell
2026-01-29 22:28             ` BALATON Zoltan
2026-01-30 19:24             ` Mark Cave-Ayland
2026-01-30 21:14               ` BALATON Zoltan
2026-01-29 16:20 ` [PATCH 3/4] memory: Remove memory_region_init_rom_nomigrate() BALATON Zoltan
2026-01-29 16:20 ` [PATCH 4/4] memory: Remove memory_region_init_ram_nomigrate() BALATON Zoltan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.