Convert the *_orphan() device-creation calls in hw/isa to the new parented API introduced earlier in this series, so every onboard device gets a stable path in the composition tree instead of landing in /machine/unattached with an unstable device[N] name.
The parent for each device is the object that owns its lifetime: the machine for board-created devices, the containing device for composite children. Names follow existing QOM conventions. Per-site rationale (reviewers: dispute the modeling here): hw/isa/i82378.c:106 | isa_new | OBJECT(s) | "pcspk" | i82378_realize() creates ISA children of the i82378 PCI-ISA bridge hw/isa/i82378.c:113 | isa_create_simple | OBJECT(s) | "dma" | i82378_realize() creates ISA children of the i82378 PCI-ISA bridge hw/isa/isa-bus.c:62 | qdev_new_orphan | ORPHAN-JUSTIFIED | - | fallback isabus-bridge when caller passes dev==NULL; parenting requires isa_bus_new() signature change across many callers, deferred hw/isa/isa-bus.c:174 | isa_new_orphan | ORPHAN-JUSTIFIED | - | API definition (transitional _orphan wrapper) hw/isa/isa-bus.c:176 | qdev_new_orphan | ORPHAN-JUSTIFIED | - | API definition body of isa_new_orphan() hw/isa/isa-bus.c:179 | isa_try_new_orphan | ORPHAN-JUSTIFIED | - | API definition (transitional _orphan wrapper) hw/isa/isa-bus.c:181 | qdev_try_new_orphan | ORPHAN-JUSTIFIED | - | API definition body of isa_try_new_orphan() hw/isa/isa-bus.c:184 | isa_create_simple_orphan | ORPHAN-JUSTIFIED | - | API definition (transitional _orphan wrapper) hw/isa/isa-bus.c:188 | isa_new_orphan | ORPHAN-JUSTIFIED | - | API definition body of isa_create_simple_orphan() hw/isa/isa-bus.c:208 | isa_create_simple_orphan | ORPHAN-JUSTIFIED | - | isa_vga_init() is a public helper called from board code (hw/i386/pc.c); needs Object *parent threaded through include/hw/isa/isa.h; deferred to caller-side patch hw/isa/isa-bus.c:213 | isa_create_simple_orphan | ORPHAN-JUSTIFIED | - | isa_vga_init() is a public helper called from board code; deferred to caller-side patch hw/isa/isa-superio.c:57 | isa_new | OBJECT(dev) | name | isa_superio_realize(); collapse existing object_property_add_child(OBJECT(dev), name, ...) keeping dynamic per-index name hw/isa/isa-superio.c:96 | isa_new | OBJECT(dev) | name | isa_superio_realize(); collapse existing object_property_add_child(OBJECT(dev), name, ...) keeping dynamic per-index name hw/isa/isa-superio.c:123 | isa_new | OBJECT(sio) | "isa-fdc" | isa_superio_realize(); collapse existing object_property_add_child(OBJECT(sio), "isa-fdc", ...) hw/isa/isa-superio.c:147 | isa_new | OBJECT(sio) | TYPE_I8042 | isa_superio_realize(); collapse existing object_property_add_child(OBJECT(sio), TYPE_I8042, ...) hw/isa/isa-superio.c:154 | isa_new | OBJECT(sio) | "isa-ide" | isa_superio_realize(); collapse existing object_property_add_child(OBJECT(sio), "isa-ide", ...) Link: https://lore.kernel.org/qemu-devel/[email protected]/ Assisted-by: Kiro Signed-off-by: Alexander Graf <[email protected]> --- hw/isa/i82378.c | 6 +++--- hw/isa/isa-superio.c | 25 ++++++++++--------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c index da09d869f5..1c0a6ad779 100644 --- a/hw/isa/i82378.c +++ b/hw/isa/i82378.c @@ -103,14 +103,14 @@ static void i82378_realize(PCIDevice *pci, Error **errp) pit = i8254_pit_init(isabus, 0x40, 0, NULL); /* speaker */ - pcspk = isa_new_orphan(TYPE_PC_SPEAKER); + pcspk = isa_new(OBJECT(s), "pcspk", TYPE_PC_SPEAKER); object_property_set_link(OBJECT(pcspk), "pit", OBJECT(pit), &error_fatal); - if (!isa_realize_and_unref(pcspk, isabus, errp)) { + if (!qdev_realize(DEVICE(pcspk), BUS(isabus), errp)) { return; } /* 2 82C37 (dma) */ - isa_create_simple_orphan(isabus, "i82374"); + isa_create_simple(OBJECT(s), "dma", isabus, "i82374"); } static void i82378_init(Object *obj) diff --git a/hw/isa/isa-superio.c b/hw/isa/isa-superio.c index 2d65255f34..d0c3c1dbd3 100644 --- a/hw/isa/isa-superio.c +++ b/hw/isa/isa-superio.c @@ -54,7 +54,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) } else { name = g_strdup_printf("parallel%d", i); } - isa = isa_new_orphan(TYPE_ISA_PARALLEL); + isa = isa_new(OBJECT(dev), name, TYPE_ISA_PARALLEL); d = DEVICE(isa); qdev_prop_set_uint32(d, "index", i); if (k->parallel.get_iobase) { @@ -65,8 +65,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) qdev_prop_set_uint32(d, "irq", k->parallel.get_irq(sio, i)); } qdev_prop_set_chr(d, "chardev", chr); - object_property_add_child(OBJECT(dev), name, OBJECT(isa)); - isa_realize_and_unref(isa, bus, &error_fatal); + qdev_realize(DEVICE(isa), BUS(bus), &error_fatal); sio->parallel[i] = isa; trace_superio_create_parallel(i, k->parallel.get_iobase ? @@ -93,7 +92,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) } else { name = g_strdup_printf("serial%d", i); } - isa = isa_new_orphan(TYPE_ISA_SERIAL); + isa = isa_new(OBJECT(dev), name, TYPE_ISA_SERIAL); d = DEVICE(isa); qdev_prop_set_uint32(d, "index", i); if (k->serial.get_iobase) { @@ -104,8 +103,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) qdev_prop_set_uint32(d, "irq", k->serial.get_irq(sio, i)); } qdev_prop_set_chr(d, "chardev", chr); - object_property_add_child(OBJECT(dev), name, OBJECT(isa)); - isa_realize_and_unref(isa, bus, &error_fatal); + qdev_realize(DEVICE(isa), BUS(bus), &error_fatal); sio->serial[i] = isa; trace_superio_create_serial(i, k->serial.get_iobase ? @@ -120,7 +118,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) assert(k->floppy.count <= 1); if (k->floppy.count && (!k->floppy.is_enabled || k->floppy.is_enabled(sio, 0))) { - isa = isa_new_orphan(TYPE_ISA_FDC); + isa = isa_new(OBJECT(sio), "isa-fdc", TYPE_ISA_FDC); d = DEVICE(isa); if (k->floppy.get_iobase) { qdev_prop_set_uint32(d, "iobase", k->floppy.get_iobase(sio, 0)); @@ -132,8 +130,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) for (i = 0; i < MAX_FD; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); } - object_property_add_child(OBJECT(sio), "isa-fdc", OBJECT(isa)); - isa_realize_and_unref(isa, bus, &error_fatal); + qdev_realize(DEVICE(isa), BUS(bus), &error_fatal); isa_fdc_init_drives(isa, fd); sio->floppy = isa; trace_superio_create_floppy(0, @@ -144,14 +141,13 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) } /* Keyboard, mouse */ - isa = isa_new_orphan(TYPE_I8042); - object_property_add_child(OBJECT(sio), TYPE_I8042, OBJECT(isa)); - isa_realize_and_unref(isa, bus, &error_fatal); + isa = isa_new(OBJECT(sio), TYPE_I8042, TYPE_I8042); + qdev_realize(DEVICE(isa), BUS(bus), &error_fatal); sio->kbc = isa; /* IDE */ if (k->ide.count && (!k->ide.is_enabled || k->ide.is_enabled(sio, 0))) { - isa = isa_new_orphan("isa-ide"); + isa = isa_new(OBJECT(sio), "isa-ide", "isa-ide"); d = DEVICE(isa); if (k->ide.get_iobase) { qdev_prop_set_uint32(d, "iobase", k->ide.get_iobase(sio, 0)); @@ -162,8 +158,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) if (k->ide.get_irq) { qdev_prop_set_uint32(d, "irq", k->ide.get_irq(sio, 0)); } - object_property_add_child(OBJECT(sio), "isa-ide", OBJECT(isa)); - isa_realize_and_unref(isa, bus, &error_fatal); + qdev_realize(DEVICE(isa), BUS(bus), &error_fatal); sio->ide = isa; trace_superio_create_ide(0, k->ide.get_iobase ? -- 2.47.1
