Convert memory_region_init*() calls in device realize functions
to pass OBJECT(dev) instead of NULL. All sites (cg3, g364fb,
virtio-gpu-gl, vmware_vga) already have the DeviceState in scope.

omap_lcdc is handled separately together with the other OMAP
peripherals.

No functional change intended.

RAMBlock idstrs are unchanged for all conversions except
vmware_vga.c: the vmsvga.fifo RAM is now owned by a PCI device, so the
convenience wrapper is replaced with the _nomigrate variant plus an
explicit vmstate_register_ram_global() to preserve the historical bare
idstr.  All other display owners here are Machine or SysBus devices.

AI-used-for: code (refactoring)
Signed-off-by: Alexander Graf <[email protected]>
---
 hw/display/cg3.c           |  2 +-
 hw/display/g364fb.c        |  2 +-
 hw/display/virtio-gpu-gl.c |  2 +-
 hw/display/vmware_vga.c    | 12 ++++++++++--
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/hw/display/cg3.c b/hw/display/cg3.c
index f9dda1549d..507b0d8189 100644
--- a/hw/display/cg3.c
+++ b/hw/display/cg3.c
@@ -304,7 +304,7 @@ static void cg3_realizefn(DeviceState *dev, Error **errp)
         }
     }
 
-    memory_region_init_ram(&s->vram_mem, NULL, "cg3.vram", s->vram_size,
+    memory_region_init_ram(&s->vram_mem, OBJECT(dev), "cg3.vram", s->vram_size,
                            &error_fatal);
     memory_region_set_log(&s->vram_mem, true, DIRTY_MEMORY_VGA);
     sysbus_init_mmio(sbd, &s->vram_mem);
diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c
index af54f1f900..0bd993b826 100644
--- a/hw/display/g364fb.c
+++ b/hw/display/g364fb.c
@@ -482,7 +482,7 @@ static void g364fb_init(DeviceState *dev, G364State *s)
 
     memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &g364fb_ctrl_ops, s,
                           "ctrl", 0x180000);
-    memory_region_init_ram(&s->mem_vram, NULL, "g364fb.vram", s->vram_size,
+    memory_region_init_ram(&s->mem_vram, OBJECT(dev), "g364fb.vram", 
s->vram_size,
                            &error_fatal);
     memory_region_set_log(&s->mem_vram, true, DIRTY_MEMORY_VGA);
 }
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index 2b7a41c466..b6f183123d 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -153,7 +153,7 @@ static void virtio_gpu_gl_device_realize(DeviceState *qdev, 
Error **errp)
         }
 
         gl->hostmem_mmap = map;
-        memory_region_init_ram_ptr(&gl->hostmem_background, NULL,
+        memory_region_init_ram_ptr(&gl->hostmem_background, OBJECT(qdev),
                                    "hostmem-background", b->conf.hostmem,
                                    gl->hostmem_mmap);
         memory_region_add_subregion(&b->hostmem, 0, &gl->hostmem_background);
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index f6f9edfd1d..571c3184c2 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -1257,8 +1257,16 @@ static void vmsvga_init(DeviceState *dev, struct 
vmsvga_state_s *s,
     s->vga.con = qemu_graphic_console_create(dev, 0, &vmsvga_ops, s);
 
     s->fifo_size = SVGA_FIFO_SIZE;
-    memory_region_init_ram(&s->fifo_ram, NULL, "vmsvga.fifo", s->fifo_size,
-                           &error_fatal);
+    /*
+     * The fifo RAM must keep its historical bare RAMBlock idstr
+     * ("vmsvga.fifo") for cross-version migration.  Use _nomigrate + a
+     * global vmstate registration so the QOM owner is the PCI device but
+     * the migration idstr is not prefixed with the PCI dev-path.
+     */
+    memory_region_init_ram_flags_nomigrate(&s->fifo_ram, OBJECT(dev),
+                                           "vmsvga.fifo", s->fifo_size, 0,
+                                           &error_fatal);
+    vmstate_register_ram_global(&s->fifo_ram);
     s->fifo_ptr = memory_region_get_ram_ptr(&s->fifo_ram);
 
     vga_common_init(&s->vga, OBJECT(dev), &error_fatal);
-- 
2.47.1


Reply via email to