Commit 2a13e31073 for qemu.org
commit 2a13e310732154f75a02be54e2b32524cc869417
Author: BALATON Zoltan <balaton@eik.bme.hu>
Date: Mon Mar 16 14:06:51 2026 +0100
hw/display/tcx: Init memory regions in realize
Thomas reported test failure:
$ export QTEST_QEMU_BINARY=./qemu-system-sparc
$ tests/qtest/device-introspect-test -m thorough
...
# Testing device 'sun-tcx'
RAMBlock "tcx.prom" already registered, abort!
Broken pipe
../../devel/qemu/tests/qtest/libqtest.c:210: kill_qemu() detected QEMU
death from signal 6 (Aborted) (core dumped)
Aborted (core dumped)
Issue is the qom introspect test will create yet another sun-tcx device
causing double register of the memory region.
Fix it by removing the init method and move memory region creation in
realize.
Reported-by: Thomas Huth <thuth@redhat.com>
Link: https://lore.kernel.org/r/3b87e6d9-a027-4dcd-a995-857e16c8b2e6@redhat.com
Fixes: 653c4fa5b0 hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Link: https://lore.kernel.org/r/20260316130651.5C8735968DE@zero.eik.bme.hu
[peterx: amend commit message, fix tag, add link]
Signed-off-by: Peter Xu <peterx@redhat.com>
diff --git a/hw/display/tcx.c b/hw/display/tcx.c
index c8a4ac21ca..ea92a48400 100644
--- a/hw/display/tcx.c
+++ b/hw/display/tcx.c
@@ -751,10 +751,15 @@ static const GraphicHwOps tcx24_ops = {
.gfx_update = tcx24_update_display,
};
-static void tcx_initfn(Object *obj)
+static void tcx_realize(DeviceState *dev, Error **errp)
{
- SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
- TCXState *s = TCX(obj);
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+ TCXState *s = TCX(dev);
+ Object *obj = OBJECT(dev);
+ ram_addr_t vram_offset = 0;
+ int size, ret;
+ uint8_t *vram_base;
+ char *fcode_filename;
memory_region_init_rom(&s->rom, obj, "tcx.prom", FCODE_MAX_ROM_SIZE,
&error_fatal);
@@ -804,16 +809,6 @@ static void tcx_initfn(Object *obj)
memory_region_init_io(&s->alt, obj, &tcx_dummy_ops, s, "tcx.alt",
TCX_ALT_NREGS);
sysbus_init_mmio(sbd, &s->alt);
-}
-
-static void tcx_realizefn(DeviceState *dev, Error **errp)
-{
- SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
- TCXState *s = TCX(dev);
- ram_addr_t vram_offset = 0;
- int size, ret;
- uint8_t *vram_base;
- char *fcode_filename;
memory_region_init_ram(&s->vram_mem, OBJECT(s), "tcx.vram",
s->vram_size * (1 + 4 + 4), &error_fatal);
@@ -887,7 +882,7 @@ static void tcx_class_init(ObjectClass *klass, const void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- dc->realize = tcx_realizefn;
+ dc->realize = tcx_realize;
device_class_set_legacy_reset(dc, tcx_reset);
dc->vmsd = &vmstate_tcx;
device_class_set_props(dc, tcx_properties);
@@ -897,7 +892,6 @@ static const TypeInfo tcx_info = {
.name = TYPE_TCX,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(TCXState),
- .instance_init = tcx_initfn,
.class_init = tcx_class_init,
};