memory: Remove most _nomigrate variants
cover memory: Remove most _nomigrate variants
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(-)
Signature · 1 line
2.41.3
PATCH 1/4 memory: Remove memory_region_init_rom_device_nomigrate()
This function is never used, remove it.
--- 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(-)
docs/devel/memory.rst +0 -1
@@ -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.
include/system/memory.h +0 -27
@@ -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
scripts/coccinelle/memory-region-housekeeping.cocci +0 -8
@@ -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;
system/memory.c +13 -28
54 lines not on this page · raw message
Signature · 1 line
2.41.3
Re: [PATCH 1/4] memory: Remove memory_region_init_rom_device_nomigrate()
Quoted 53 lines · BALATON Zoltan
This function is never used, remove it.
Signed-off-by BALATON Zoltan <[email protected]>--- 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(-)system/memory.c +6
-28-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;
system/memory.c bool memory_region_init_rom_device(MemoryRegion *mr, · line 3795
Quoted 10 lines
system/memory.c +7
-0+ 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:
PATCH 2/4 hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
In reply to BALATON ZoltanNothing else does this, convert to regular memory_region_init_rom().
--- hw/display/cg3.c | 5 ++--- hw/display/tcx.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-)
hw/display/cg3.c +2 -3
@@ -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);
hw/display/tcx.c +2 -3
@@ -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);
Signature · 1 line
2.41.3
Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
Quoted 25 lines · BALATON Zoltan
Nothing else does this, convert to regular
memory_region_init_rom().Signed-off-by BALATON Zoltan <[email protected]>--- hw/display/cg3.c | 5 ++--- hw/display/tcx.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-)hw/display/cg3.c +2
-2@@ -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",
hw/display/cg3.c static void cg3_realizefn(DeviceState *dev, Error **errp) · line 304
Quoted 7 lines
hw/display/cg3.c +0
-1@@ -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
Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
Quoted 28 lines · Peter Maydell
Quoted 27 lines · BALATON Zoltan
Nothing else does this, convert to regular
memory_region_init_rom().Signed-off-by BALATON Zoltan <[email protected]>--- hw/display/cg3.c | 5 ++--- hw/display/tcx.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-)hw/display/cg3.c +2
-2@@ -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;
Quoted 14 lines
hw/display/cg3.c static void cg3_realizefn(DeviceState *dev, Error **errp) · line 304
Quoted 5 lines
hw/display/cg3.c +0
-1/* 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 viavmstate_register_ram(), which picks an ID string for the memory that includes the path of the device, whereasvmstate_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_nomigratefunctions.
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.
Quoted 4 lines
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
Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
Quoted 12 lines · BALATON Zoltan
Quoted 9 lines · Peter Maydell
On Thu, 29 Jan 2026 at 16:21, BALATON Zoltan <[email protected]> wrote:
This is a migration compatibility break, because thememory_region_init_rom()function registers the MR
for migration viavmstate_register_ram(), which picks
an ID string for the memory that includes the path
of the device, whereasvmstate_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_nomigratefunctions.
Quoted 4 lines
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.
Quoted 10 lines
Quoted 4 lines
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_nomigrateusages in Sun machines could also be converted. If Mark is not open to that I'm inclined to convert these tworom_nomigrateusages tomemory_region_init_ram_flags_nomigrate+memory_region_set_readonlyinstead
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
Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
Quoted 17 lines · Peter Maydell
Quoted 11 lines · BALATON Zoltan
Quoted 9 lines · Peter Maydell
On Thu, 29 Jan 2026 at 16:21, BALATON Zoltan <[email protected]> wrote:
This is a migration compatibility break, because thememory_region_init_rom()function registers the MR
for migration viavmstate_register_ram(), which picks
an ID string for the memory that includes the path
of the device, whereasvmstate_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_nomigratefunctions.Quoted 4 lines
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.
Quoted 4 lines
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.
Quoted 11 lines
Quoted 10 lines
Quoted 4 lines
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_nomigrateusages in Sun machines could also be converted. If Mark is not open to that I'm inclined to convert these tworom_nomigrateusages tomemory_region_init_ram_flags_nomigrate+memory_region_set_readonlyinstead
Quoted 5 lines
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
Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
Quoted 24 lines · BALATON Zoltan
Quoted 17 lines · Peter Maydell
Quoted 11 lines · BALATON Zoltan
Quoted 9 lines · Peter Maydell
On Thu, 29 Jan 2026 at 16:21, BALATON Zoltan <[email protected]> wrote:
This is a migration compatibility break, because thememory_region_init_rom()function registers the MR
for migration viavmstate_register_ram(), which picks
an ID string for the memory that includes the path
of the device, whereasvmstate_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_nomigratefunctions.Quoted 4 lines
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.Quoted 4 lines
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.
Quoted 4 lines
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
Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
Quoted 25 lines · Peter Maydell
Quoted 24 lines · BALATON Zoltan
Quoted 21 lines · Peter Maydell
Quoted 11 lines · BALATON Zoltan
Quoted 9 lines · Peter Maydell
On Thu, 29 Jan 2026 at 16:21, BALATON Zoltan <[email protected]> wrote:
This is a migration compatibility break, because thememory_region_init_rom()function registers the MR
for migration viavmstate_register_ram(), which picks
an ID string for the memory that includes the path
of the device, whereasvmstate_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_nomigratefunctions.Quoted 4 lines
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.
Quoted 8 lines
Quoted 4 lines
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
Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
In reply to Peter MaydellQuoted 25 lines · Peter Maydell
Quoted 24 lines · BALATON Zoltan
Quoted 21 lines · Peter Maydell
Quoted 11 lines · BALATON Zoltan
Quoted 9 lines · Peter Maydell
On Thu, 29 Jan 2026 at 16:21, BALATON Zoltan <[email protected]> wrote:
This is a migration compatibility break, because thememory_region_init_rom()function registers the MR
for migration viavmstate_register_ram(), which picks
an ID string for the memory that includes the path
of the device, whereasvmstate_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_nomigratefunctions.Quoted 4 lines
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.
Quoted 8 lines
Quoted 4 lines
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.
Re: [PATCH 2/4] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate()
Quoted 31 lines · Mark Cave-Ayland
Quoted 30 lines · Peter Maydell
Quoted 28 lines · BALATON Zoltan
Quoted 17 lines · Peter Maydell
Quoted 11 lines · BALATON Zoltan
Quoted 9 lines · Peter Maydell
On Thu, 29 Jan 2026 at 16:21, BALATON Zoltan <[email protected]> wrote:
This is a migration compatibility break, because thememory_region_init_rom()function registers the MR
for migration viavmstate_register_ram(), which picks
an ID string for the memory that includes the path
of the device, whereasvmstate_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_nomigratefunctions.Quoted 4 lines
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.Quoted 4 lines
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
Quoted 5 lines
Quoted 3 lines
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
PATCH 3/4 memory: Remove memory_region_init_rom_nomigrate()
In reply to BALATON ZoltanAll users were converted to memory_region_init_rom() so no longer needed.
--- 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(-)
docs/devel/memory.rst +0 -1
@@ -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.
include/system/memory.h +0 -26
@@ -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
scripts/coccinelle/memory-region-housekeeping.cocci +0 -16
@@ -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;
system/memory.c +3 -16
@@ -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
Signature · 1 line
2.41.3
PATCH 4/4 memory: Remove memory_region_init_ram_nomigrate()
In reply to BALATON ZoltanThis 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.)
--- 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(-)
docs/devel/memory.rst +3 -5
@@ -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:
hw/display/tcx.c +3 -2
@@ -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);
hw/display/vga.c +2 -2
@@ -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;
hw/sparc/sun4m.c +9 -6
@@ -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 ; }
hw/sparc64/sun4u.c +5 -4
@@ -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); }
hw/xtensa/xtfpga.c +2 -2
@@ -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); }
include/system/memory.h +0 -23
@@ -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
scripts/coccinelle/memory-region-housekeeping.cocci +1 -17
@@ -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;
system/memory.c +2 -11
@@ -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.
Signature · 1 line
2.41.3