From: BALATON Zoltan <[email protected]> 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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Fixes: 653c4fa5b0 hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate Signed-off-by: BALATON Zoltan <[email protected]> Link: https://lore.kernel.org/r/[email protected] [peterx: amend commit message, fix tag, add link] Signed-off-by: Peter Xu <[email protected]> --- hw/display/tcx.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) 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, }; -- 2.50.1
