qom: Make composition-tree parenting mandatory
Subsystems (11)
RFC PATCH 114/134 hw: Give allocated IRQs an owner and name
In reply to Alexander GrafConvert the remaining IRQ allocation calls across hw/ to the parented form. Owner is the enclosing device for realize()-time allocations and the machine for board-init allocations. Names describe the pin's purpose; the auto-indexed [*] form is used where the same allocation runs in a loop.
--- hw/alpha/typhoon.c | 4 ++-- hw/char/diva-gsp.c | 3 ++- hw/display/macfb.c | 2 +- hw/ide/ahci.c | 2 +- hw/ide/pci.c | 2 +- hw/intc/sh_intc.c | 2 +- hw/isa/i82378.c | 3 ++- hw/isa/lpc_ich9.c | 2 +- hw/m68k/mcf5206.c | 2 +- hw/m68k/q800.c | 4 ++-- hw/mips/mips_int.c | 2 +- hw/net/can/can_kvaser_pci.c | 2 +- hw/pci-host/pnv_phb3.c | 3 ++- hw/pci-host/pnv_phb3_msi.c | 3 ++- hw/pci-host/pnv_phb4.c | 3 ++- hw/ppc/e500.c | 3 ++- hw/ppc/pnv_lpc.c | 2 +- hw/ppc/pnv_psi.c | 6 ++++-- hw/ppc/spapr_irq.c | 2 +- hw/riscv/sifive_u.c | 3 ++- hw/scsi/esp-pci.c | 2 +- hw/sh4/sh7750.c | 2 +- hw/sparc/sun4m.c | 5 +++-- hw/sparc64/sun4u.c | 3 ++- hw/xen/xen-pvh-common.c | 5 +++-- 25 files changed, 42 insertions(+), 30 deletions(-)
hw/alpha/typhoon.c +2 -2
@@ -849,8 +849,8 @@ PCIBus *typhoon_init(Object *parent, MemoryRegion *ram, qemu_irq *p_isa_irq, } } - *p_isa_irq =qemu_allocate_irq_orphan (typhoon_set_isa_irq, s,0 ); - *p_rtc_irq =qemu_allocate_irq_orphan (typhoon_set_timer_irq, s,0 ); + *p_isa_irq =qemu_allocate_irq (parent,"isa-irq" , typhoon_set_isa_irq, s,0 ); + *p_rtc_irq =qemu_allocate_irq (parent,"rtc-irq" , typhoon_set_timer_irq, s,0 );/* Main memory region, 0x00.0000.0000. Real hardware supports 32GB, but the address space hole reserved at this point is 8TB. */
hw/char/diva-gsp.c +2 -1
@@ -126,7 +126,8 @@ static void diva_pci_realize(PCIDevice *dev, Error **errp) pci->dev.config[PCI_INTERRUPT_PIN ] =1 ;memory_region_init (&pci->membar,OBJECT (pci),"serial_ports" ,4096 );pci_register_bar (&pci->dev,0 ,PCI_BASE_ADDRESS_SPACE_MEMORY , &pci->membar); - pci->irqs =qemu_allocate_irqs_orphan (multi_serial_irq_mux, pci, di.nports); + pci->irqs =qemu_allocate_irqs (OBJECT (dev),"serial-irq" , + multi_serial_irq_mux, pci, di.nports);for (i =0 ; i < di.nports; i++) { s = pci->state + i;
hw/display/macfb.c +1 -1
@@ -737,7 +737,7 @@ static void macfb_nubus_realize(DeviceState *dev, Error **errp)memory_region_add_subregion (&nd->slot_mem,DAFB_BASE , &ms->mem_ctrl);memory_region_add_subregion (&nd->slot_mem,VIDEO_BASE , &ms->mem_vram); - ms->irq =qemu_allocate_irq_orphan (macfb_nubus_set_irq, s,0 ); + ms->irq =qemu_allocate_irq (OBJECT (dev),"nubus-irq" , macfb_nubus_set_irq, s,0 ); }static void macfb_nubus_unrealize (DeviceState *dev)
hw/ide/ahci.c +1 -1
@@ -1594,7 +1594,7 @@ void ahci_realize(AHCIState *s, DeviceState *qdev, AddressSpace *as)assert (s->ports >0 ); s->dev =g_new0 (AHCIDevice, s->ports);ahci_reg_init (s); - irqs =qemu_allocate_irqs_orphan (ahci_irq_set, s, s->ports); + irqs =qemu_allocate_irqs (OBJECT (qdev),"port-irq" , ahci_irq_set, s, s->ports);for (i =0 ; i < s->ports; i++) {AHCIDevice *ad = &s->dev[i];
hw/ide/pci.c +1 -1
@@ -606,7 +606,7 @@ void bmdma_init(IDEBus *bus, BMDMAState *bm, PCIIDEState *d) bm->dma.ops = &bmdma_ops; bus->dma = &bm->dma; bm->irq = bus->irq; - bus->irq =qemu_allocate_irq_orphan (bmdma_irq, bm,0 ); + bus->irq =qemu_allocate_irq (OBJECT (d),"bmdma-irq[*]" , bmdma_irq, bm,0 ); bm->bus = bus; bm->pci_dev = d; }
hw/intc/sh_intc.c +1 -1
@@ -403,7 +403,7 @@ int sh_intc_init(Object *owner, MemoryRegion *sysmem,for (i =0 ; i < nr_sources; i++) { desc->sources[i].parent = desc; } - desc->irqs =qemu_allocate_irqs_orphan (sh_intc_set_irq, desc, nr_sources); + desc->irqs =qemu_allocate_irqs (owner,"src-irq" , sh_intc_set_irq, desc, nr_sources);memory_region_init_io (&desc->iomem, owner, &sh_intc_ops, desc,"intc" ,0x100000000ULL ); j =0 ;
hw/isa/i82378.c +2 -1
@@ -95,7 +95,8 @@ static void i82378_realize(PCIDevice *pci, Error **errp)/* 2 82C59 (irq) */ s->isa_irqs_in =i8259_init (OBJECT (pci), isabus, -qemu_allocate_irq_orphan (i82378_request_out0_irq, +qemu_allocate_irq (OBJECT (dev),"out0-irq" , + i82378_request_out0_irq, s,0 ));isa_bus_register_input_irqs (isabus, s->isa_irqs_in);
hw/isa/lpc_ich9.c +1 -1
@@ -429,7 +429,7 @@ static void ich9_lpc_pm_init(ICH9LPCState *lpc)qemu_irq sci_irq;FWCfgState *fw_cfg =fw_cfg_find (); - sci_irq =qemu_allocate_irq_orphan (ich9_set_sci, lpc,0 ); + sci_irq =qemu_allocate_irq (OBJECT (lpc),"sci-irq" , ich9_set_sci, lpc,0 );ich9_pm_init (PCI_DEVICE (lpc), &lpc->pm, sci_irq);if (lpc->smi_host_features && fw_cfg) {
hw/m68k/mcf5206.c +1 -1
@@ -593,7 +593,7 @@ static void mcf5206_mbar_realize(DeviceState *dev, Error **errp) "mbar", 0x00001000);sysbus_init_mmio (SYS_BUS_DEVICE (dev), &s->iomem); - s->pic =qemu_allocate_irqs_orphan (m5206_mbar_set_irq, s,14 ); + s->pic =qemu_allocate_irqs (OBJECT (dev),"pic-irq" , m5206_mbar_set_irq, s,14 );m5206_timer_init (&s->timer[0 ], s->pic[9 ]);m5206_timer_init (&s->timer[1 ], s->pic[10 ]); s->uart[0 ] =mcf_uart_create (OBJECT (s), s->pic[12 ],serial_hd (0 ));
hw/m68k/q800.c +2 -2
@@ -474,11 +474,11 @@ static void q800_machine_init(MachineState *machine)sysbus_realize (sysbus, &error_fatal);/* SCSI and SCSI data IRQs are negative edge triggered */ sysbus_connect_irq (sysbus,0 , -qemu_irq_invert_orphan ( +qemu_irq_invert (OBJECT (machine),"scsi-irq-inv" ,qdev_get_gpio_in (DEVICE (&m->via2),VIA2_IRQ_SCSI_BIT )));sysbus_connect_irq (sysbus,1 , -qemu_irq_invert_orphan ( +qemu_irq_invert (OBJECT (machine),"scsi-drq-inv" ,qdev_get_gpio_in (DEVICE (&m->via2),VIA2_IRQ_SCSI_DATA_BIT ))); memory_region_add_subregion(&m->macio, ESP_BASE - IO_BASE,
hw/mips/mips_int.c +1 -1
@@ -56,7 +56,7 @@ void cpu_mips_irq_init_cpu(MIPSCPU *cpu)qemu_irq *qi;int i; - qi =qemu_allocate_irqs_orphan (cpu_mips_irq_request, cpu,8 ); + qi =qemu_allocate_irqs (OBJECT (cpu),"cpu-irq" , cpu_mips_irq_request, cpu,8 );for (i =0 ; i <8 ; i++) { env->irq[i] = qi[i]; }
hw/net/can/can_kvaser_pci.c +1 -1
@@ -224,7 +224,7 @@ static void kvaser_pci_realize(PCIDevice *pci_dev, Error **errp) pci_conf = pci_dev->config; pci_conf[PCI_INTERRUPT_PIN ] =0x01 ;/* interrupt pin A */ - d->irq =qemu_allocate_irq_orphan (kvaser_pci_irq_handler, d,0 ); + d->irq =qemu_allocate_irq (OBJECT (s),"kvaser-irq" , kvaser_pci_irq_handler, d,0 );can_sja_init (s, d->irq);
hw/pci-host/pnv_phb3.c +2 -1
@@ -1054,7 +1054,8 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp)ics_set_irq_type (&phb->lsis, i, true); } - phb->qirqs =qemu_allocate_irqs_orphan (ics_set_irq, &phb->lsis, phb->lsis.nr_irqs); + phb->qirqs =qemu_allocate_irqs (OBJECT (dev),"lsi-irq" , + ics_set_irq, &phb->lsis, phb->lsis.nr_irqs);/* MSI sources */ object_property_set_link(OBJECT(&phb->msis), "phb", OBJECT(phb),
hw/pci-host/pnv_phb3_msi.c +2 -1
@@ -267,7 +267,8 @@ static void phb3_msi_realize(DeviceState *dev, Error **errp)return ; } - msi->qirqs =qemu_allocate_irqs_orphan (phb3_msi_set_irq, msi, ics->nr_irqs); + msi->qirqs =qemu_allocate_irqs (OBJECT (dev),"msi-irq" , + phb3_msi_set_irq, msi, ics->nr_irqs); }static void phb3_msi_instance_init (Object *obj)
hw/pci-host/pnv_phb4.c +2 -1
@@ -1605,7 +1605,8 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp)pnv_phb4_update_xsrc (phb); - phb->qirqs =qemu_allocate_irqs_orphan (xive_source_set_irq, xsrc, xsrc->nr_irqs); + phb->qirqs =qemu_allocate_irqs (OBJECT (dev),"lsi-irq" , + xive_source_set_irq, xsrc, xsrc->nr_irqs);pnv_phb4_xscom_realize (phb); }
hw/ppc/e500.c +2 -1
@@ -1089,7 +1089,8 @@ void ppce500_init(MachineState *machine) sysbus_mmio_get_region(s, 0));/* Power Off GPIO at Pin 0 */ - poweroff_irq =qemu_allocate_irq_orphan (ppce500_power_off,NULL ,0 ); + poweroff_irq =qemu_allocate_irq (OBJECT (machine),"poweroff" , + ppce500_power_off,NULL ,0 );qdev_connect_gpio_out (dev,0 , poweroff_irq); }
hw/ppc/pnv_lpc.c +1 -1
@@ -993,7 +993,7 @@ ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp) }/* POWER has a 17th irq, QEMU only implements the 16 regular device irqs */ - irqs =qemu_allocate_irqs_orphan (handler, lpc,ISA_NUM_IRQS ); + irqs =qemu_allocate_irqs (OBJECT (lpc),"isa-irq" , handler, lpc,ISA_NUM_IRQS );isa_bus_register_input_irqs (isa_bus, irqs);
hw/ppc/pnv_psi.c +4 -2
@@ -509,7 +509,8 @@ static void pnv_psi_power8_realize(DeviceState *dev, Error **errp)qdev_init_gpio_in (dev, pnv_psi_power8_set_irq, ics->nr_irqs); - psi->qirqs =qemu_allocate_irqs_orphan (ics_set_irq, ics, ics->nr_irqs); + psi->qirqs =qemu_allocate_irqs (OBJECT (dev),"psi-irq" , + ics_set_irq, ics, ics->nr_irqs);/* XSCOM region for PSI registers */ pnv_xscom_region_init(&psi->xscom_regs, OBJECT(dev), &pnv_psi_xscom_ops,
@@ -872,7 +873,8 @@ static void pnv_psi_power9_realize(DeviceState *dev, Error **errp)xive_source_irq_set_lsi (xsrc, i); } - psi->qirqs =qemu_allocate_irqs_orphan (xive_source_set_irq, xsrc, xsrc->nr_irqs); + psi->qirqs =qemu_allocate_irqs (OBJECT (dev),"psi-irq" , + xive_source_set_irq, xsrc, xsrc->nr_irqs);qdev_init_gpio_in (dev, pnv_psi_power9_set_irq, xsrc->nr_irqs);
hw/ppc/spapr_irq.c +1 -1
@@ -339,7 +339,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp)spapr_xive_hcall_init (spapr); } - spapr->qirqs =qemu_allocate_irqs_orphan (spapr_set_irq, spapr, + spapr->qirqs =qemu_allocate_irqs (OBJECT (spapr),"irq" , spapr_set_irq, spapr,SPAPR_NR_XIRQS +SPAPR_IRQ_NR_IPIS );/*
hw/riscv/sifive_u.c +2 -1
@@ -484,7 +484,8 @@ static void sifive_u_machine_init(MachineState *machine)/* register gpio-restart */ qdev_connect_gpio_out (DEVICE (&(s->soc.gpio)),10 , -qemu_allocate_irq_orphan (sifive_u_machine_reset,NULL ,0 )); +qemu_allocate_irq (OBJECT (machine),"reset-irq" , + sifive_u_machine_reset,NULL ,0 ));/* load/create device tree */ if (machine->dtb) {
hw/scsi/esp-pci.c +1 -1
@@ -407,7 +407,7 @@ static void esp_pci_scsi_realize(PCIDevice *dev, Error **errp) "esp-io", 0x80);pci_register_bar (dev,0 ,PCI_BASE_ADDRESS_SPACE_IO , &pci->io); - s->irq =qemu_allocate_irq_orphan (esp_irq_handler, pci,0 ); + s->irq =qemu_allocate_irq (OBJECT (s),"esp-irq" , esp_irq_handler, pci,0 );scsi_bus_init (&s->bus,sizeof (s->bus), d, &esp_pci_scsi_info); }
hw/sh4/sh7750.c +1 -1
@@ -848,5 +848,5 @@ SH7750State *sh7750_init(Object *parent, SuperHCPU *cpu,qemu_irq sh7750_irl (SH7750State *s) {sh_intc_toggle_source (&s->intc.sources[IRL ],1 ,0 );/* enable */ -return qemu_allocate_irq_orphan (sh_intc_set_irl, &s->intc.sources[IRL ],0 ); +return qemu_allocate_irq (OBJECT (s),"irl" , sh_intc_set_irl, &s->intc.sources[IRL ],0 ); }
hw/sparc/sun4m.c +3 -2
@@ -1008,7 +1008,8 @@ static void sun4m_hw_init(MachineState *machine)if (hwdef->apc_base) {apc_init (OBJECT (machine), hwdef->apc_base, -qemu_allocate_irq_orphan (cpu_halt_signal,NULL ,0 )); +qemu_allocate_irq (OBJECT (machine),"cpu-halt" , + cpu_halt_signal,NULL ,0 )); }if (hwdef->fd_base) {
@@ -1018,7 +1019,7 @@ static void sun4m_hw_init(MachineState *machine)sun4m_fdctrl_init (OBJECT (machine), slavio_irq[22 ], hwdef->fd_base, fd, &fdc_tc); }else { - fdc_tc =qemu_allocate_irq_orphan (dummy_fdc_tc,NULL ,0 ); + fdc_tc =qemu_allocate_irq (OBJECT (machine),"fdc-tc" , dummy_fdc_tc,NULL ,0 ); } slavio_misc_init(OBJECT(machine), hwdef->slavio_base, hwdef->aux1_base,
hw/sparc64/sun4u.c +2 -1
@@ -311,7 +311,8 @@ static void ebus_realize(PCIDevice *pci_dev, Error **errp) }/* ISA bus */ - s->isa_irqs_in =qemu_allocate_irqs_orphan (ebus_isa_irq_handler, s,ISA_NUM_IRQS ); + s->isa_irqs_in =qemu_allocate_irqs (OBJECT (s),"isa-irq-in" , + ebus_isa_irq_handler, s,ISA_NUM_IRQS );isa_bus_register_input_irqs (s->isa_bus, s->isa_irqs_in);qdev_init_gpio_out_named (DEVICE (s), s->isa_irqs_out,"isa-irq" ,ISA_NUM_IRQS );
hw/xen/xen-pvh-common.c +3 -2
@@ -170,7 +170,7 @@ static void xen_create_virtio_mmio_devices(XenPVHMachineState *s)*/ for (i = s->cfg.virtio_mmio_num -1 ; i >=0 ; i--) {hwaddr base = s->cfg.virtio_mmio.base + i * s->cfg.virtio_mmio.size; -qemu_irq irq =qemu_allocate_irq_orphan (xen_set_irq,NULL , +qemu_irq irq =qemu_allocate_irq (OBJECT (s),"virtio-irq[*]" , xen_set_irq,NULL , s->cfg.virtio_mmio_irq_base + i); sysbus_create_simple(OBJECT(s), "virtio-mmio[*]", "virtio-mmio",
@@ -260,7 +260,8 @@ static inline void xenpvh_gpex_init(XenPVHMachineState *s,assert (xpc->set_pci_intx_irq);for (i =0 ; i <PCI_NUM_PINS ; i++) { -qemu_irq irq =qemu_allocate_irq_orphan (xpc->set_pci_intx_irq, s, i); +qemu_irq irq =qemu_allocate_irq (OBJECT (s),"pci-intx-irq[*]" , + xpc->set_pci_intx_irq, s, i);sysbus_connect_irq (SYS_BUS_DEVICE (dev), i, irq);gpex_set_irq_num (GPEX_HOST (dev), i, s->cfg.pci_intx_irq_base + i);
Signature · 1 line
2.47.1
RFC PATCH 115/134 hw/core: Parent GPIO input IRQs and embedded IRQState via QOM
In reply to Alexander Grafqdev_init_gpio_in_named_with_opaque() now uses qemu_extend_irqs() directly, so the input IRQ objects are parented under the device via object_new_child() and the manual object_property_add_child() loop goes away. device_finalize() no longer needs to free the IRQ objects explicitly since child<> property destruction does that; only the qemu_irq* array itself needs g_free().
Convert the six users of qemu_init_irq()/qemu_init_irqs() (which initialize an IRQState embedded in a device struct) to qemu_init_irq_child() so those IRQs also get a QOM parent.
qdev_connect_gpio_out_named() now asserts that its input pin has a parent instead of falling back to /machine/unattached; every qemu_irq that reaches it is parented after this and the preceding commits.
--- hw/core/gpio.c | 24 ++++-------------------- hw/core/qdev.c | 3 ++- hw/ipack/ipack.c | 11 +++++++++-- hw/isa/vt82c686.c | 3 ++- hw/net/imx_fec.c | 2 +- hw/net/lan9118.c | 2 +- hw/ppc/pegasos.c | 3 ++- hw/sh4/r2d.c | 5 ++++- 8 files changed, 25 insertions(+), 28 deletions(-)
hw/core/gpio.c +4 -20
@@ -45,24 +45,12 @@ void qdev_init_gpio_in_named_with_opaque(DeviceState *dev,void *opaque, const char *name, int n) { - int i; NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name);assert (gpio_list->num_out ==0 || !name); - gpio_list->in =qemu_extend_irqs_orphan (gpio_list->in, gpio_list->num_in, handler, - opaque, n); - -if (!name) { - name ="unnamed-gpio-in" ; - } -for (i = gpio_list->num_in; i < gpio_list->num_in + n; i++) { -gchar *propname =g_strdup_printf ("%s[%u]" , name, i); - -object_property_add_child (OBJECT (dev), propname, -OBJECT (gpio_list->in[i])); -g_free (propname); - } - + gpio_list->in =qemu_extend_irqs (OBJECT (dev), name ?:"unnamed-gpio-in" , + gpio_list->in, gpio_list->num_in, + handler, opaque, n); gpio_list->num_in += n; }
@@ -119,11 +107,7 @@ void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n, {char *propname =g_strdup_printf ("%s[%d]" , name ? name :"unnamed-gpio-out" , n); -if (input_pin && !OBJECT (input_pin)->parent) { -/* We need a name for object_property_set_link to work */ -object_property_add_child (machine_get_container ("unattached" ), -"non-qdev-gpio[*]" ,OBJECT (input_pin)); - } +g_assert (!input_pin ||OBJECT (input_pin)->parent);object_property_set_link (OBJECT (dev), propname,OBJECT (input_pin), &error_abort);g_free (propname);
hw/core/qdev.c +2 -1
@@ -697,7 +697,8 @@ static void device_finalize(Object *obj) QLIST_FOREACH_SAFE(ngl, &dev->gpios, node, next) {QLIST_REMOVE (ngl, node); -qemu_free_irqs (ngl->in, ngl->num_in); +/* IRQs are child<> properties of dev; freed via child destruction */ +g_free (ngl->in);g_free (ngl->name);g_free (ngl);/* ngl->out irqs are owned by the other end and should not be freed
hw/ipack/ipack.c +9 -2
@@ -55,18 +55,25 @@ static void ipack_device_realize(DeviceState *dev, Error **errp) } bus->free_slot = idev->slot +1 ; -qemu_init_irqs (idev->irq,ARRAY_SIZE (idev->irq), bus->set_irq, idev); +for (int i =0 ; i <ARRAY_SIZE (idev->irq); i++) { +qemu_init_irq_child (OBJECT (idev),"irq[*]" , &idev->irq[i], + bus->set_irq, idev, i); + } k->realize (dev, errp); }static void ipack_device_unrealize (DeviceState *dev) { +IPackDevice *idev =IPACK_DEVICE (dev);IPackDeviceClass *k =IPACK_DEVICE_GET_CLASS (dev);if (k->unrealize) { k->unrealize (dev); -return ; + } + +for (int i =0 ; i <ARRAY_SIZE (idev->irq); i++) { +object_unparent (OBJECT (&idev->irq[i])); } }
hw/isa/vt82c686.c +2 -1
@@ -722,7 +722,8 @@ static void via_isa_realize(PCIDevice *d, Error **errp)qdev_init_gpio_out_named (dev, &s->cpu_intr,"intr" ,1 );qdev_init_gpio_in_named (dev, via_isa_pirq,"pirq" ,PCI_NUM_PINS ); -qemu_init_irq (&s->i8259_irq, via_isa_request_i8259_irq, s,0 ); +qemu_init_irq_child (OBJECT (s),"i8259-irq" , &s->i8259_irq, + via_isa_request_i8259_irq, s,0 ); isa_bus =isa_bus_new (dev,pci_address_space (d),pci_address_space_io (d), errp);
hw/net/imx_fec.c +1 -1
@@ -1205,7 +1205,7 @@ static void imx_eth_realize(DeviceState *dev, Error **errp)sysbus_init_irq (sbd, &s->irq[0 ]);sysbus_init_irq (sbd, &s->irq[1 ]); -qemu_init_irq (&s->mii_irq, imx_phy_update_irq, s,0 ); +qemu_init_irq_child (OBJECT (s),"mii-irq" , &s->mii_irq, imx_phy_update_irq, s,0 );object_initialize_child (OBJECT (s),"mii" , &s->mii,TYPE_LAN9118_PHY );if (!sysbus_realize_and_unref (SYS_BUS_DEVICE (&s->mii), errp)) {return ;
hw/net/lan9118.c +1 -1
@@ -1274,7 +1274,7 @@ static void lan9118_realize(DeviceState *dev, Error **errp)const MemoryRegionOps *mem_ops = s->mode_16bit ? &lan9118_16bit_mem_ops : &lan9118_mem_ops; -qemu_init_irq (&s->mii_irq, lan9118_update_irq, s,0 ); +qemu_init_irq_child (OBJECT (s),"mii-irq" , &s->mii_irq, lan9118_update_irq, s,0 );object_initialize_child (OBJECT (s),"mii" , &s->mii,TYPE_LAN9118_PHY );if (!sysbus_realize_and_unref (SYS_BUS_DEVICE (&s->mii), errp)) {return ;
hw/ppc/pegasos.c +2 -1
@@ -134,7 +134,8 @@ static void pegasos2_setup_pci_irq(PegasosMachineState *pm)TYPE_OR_IRQ , &error_fatal, "num-lines", "2", NULL);qdev_realize (DEVICE (ori),NULL , &error_fatal); -qemu_init_irq (&pm->pci_irqs[i], pegasos2_pci_irq, pm, i); +qemu_init_irq_child (OBJECT (pm),"pci-irq[*]" , &pm->pci_irqs[i], + pegasos2_pci_irq, pm, i);qdev_connect_gpio_out (DEVICE (ori),0 , &pm->pci_irqs[i]); pm->mv_pirq[i] =qdev_get_gpio_in_named (pm->nb,"gpp" ,12 + i); pm->via_pirq[i] =qdev_get_gpio_in_named (pm->sb,"pirq" , i);
hw/sh4/r2d.c +4 -1
@@ -200,7 +200,10 @@ static r2d_fpga_t *r2d_fpga_init(Object *owner,memory_region_init_io (&s->iomem, owner, &r2d_fpga_ops, s,"r2d-fpga" ,0x40 );memory_region_add_subregion (sysmem, base, &s->iomem); -qemu_init_irqs (s->irq,NR_IRQS , r2d_fpga_irq_set, s); +for (int i =0 ; i <NR_IRQS ; i++) { +qemu_init_irq_child (owner,"fpga-irq[*]" , &s->irq[i], + r2d_fpga_irq_set, s, i); + }return s; }
Signature · 1 line
2.47.1
RFC PATCH 116/134 irq: Delete the *_orphan() IRQ allocation variants
In reply to Alexander GrafEvery caller has been converted to the parented form; drop the transitional *_orphan() helpers.
--- hw/core/irq.c | 35 ----------------------------------- include/hw/core/irq.h | 20 +------------------- 2 files changed, 1 insertion(+), 54 deletions(-)
hw/core/irq.c +0 -35
@@ -68,34 +68,6 @@ void qemu_init_irqs(IRQState irq[], size_t count, } } -qemu_irq *qemu_extend_irqs_orphan (qemu_irq *old,int n_old,qemu_irq_handler handler, -void *opaque,int n) -{ -qemu_irq *s; -int i; - -if (!old) { - n_old =0 ; - } - s = old ?g_renew (qemu_irq, old, n + n_old) :g_new (qemu_irq, n); -for (i = n_old; i < n + n_old; i++) { - s[i] =qemu_allocate_irq_orphan (handler, opaque, i); - } -return s; -} - -qemu_irq *qemu_allocate_irqs_orphan (qemu_irq_handler handler,void *opaque,int n) -{ -return qemu_extend_irqs_orphan (NULL ,0 , handler, opaque, n); -} - -qemu_irq qemu_allocate_irq_orphan (qemu_irq_handler handler,void *opaque,int n) -{ -IRQState *irq =IRQ (object_new (TYPE_IRQ )); -init_irq_fields (irq, handler, opaque, n); -return irq; -} -qemu_irq qemu_allocate_irq (Object *owner,const char *name,qemu_irq_handler handler,void *opaque,int n) {
@@ -153,13 +125,6 @@ static void qemu_notirq(void *opaque, int line, int level)qemu_set_irq (irq, !level); } -qemu_irq qemu_irq_invert_orphan (qemu_irq irq) -{ -/* The default state for IRQs is low, so raise the output now. */ -qemu_irq_raise (irq); -return qemu_allocate_irq_orphan (qemu_notirq, irq,0 ); -} -qemu_irq qemu_irq_invert (Object *owner,const char *name,qemu_irq irq) {/* The default state for IRQs is low, so raise the output now. */
include/hw/core/irq.h +1 -19
@@ -74,19 +74,8 @@ void qemu_init_irq_child(Object *parent, const char *propname,void qemu_init_irqs (IRQState irq[],size_t count,qemu_irq_handler handler,void *opaque); -/* Returns an array of N IRQs. Each IRQ is assigned the argument handler and -* opaque data. -*/ -qemu_irq *qemu_allocate_irqs_orphan (qemu_irq_handler handler,void *opaque,int n); -/* -* Allocates a single IRQ. The irq is assigned with a handler, an opaque -* data and the interrupt number. -*/ -qemu_irq qemu_allocate_irq_orphan (qemu_irq_handler handler,void *opaque,int n); - -/* -* Same as the *_orphan() variants above, but the new IRQ objects are +* Allocate IRQ objects with an explicit QOM parent. The new objects are * parented under @owner with property name @name (or @name[*] for the * array/extend variants). The reference is held by @owner; call * qemu_free_irq() to unparent and free.
@@ -99,17 +88,10 @@ qemu_irq *qemu_extend_irqs(Object *owner, const char *name, qemu_irq *old, int n_old, qemu_irq_handler handler, void *opaque, int n); -/* Extends an Array of IRQs. Old IRQs have their handlers and opaque data -* preserved. New IRQs are assigned the argument handler and opaque data. -*/ -qemu_irq *qemu_extend_irqs_orphan (qemu_irq *old,int n_old,qemu_irq_handler handler, -void *opaque,int n); -void qemu_free_irqs (qemu_irq *s,int n);void qemu_free_irq (qemu_irq irq);/* Returns a new IRQ with opposite polarity. */ -qemu_irq qemu_irq_invert_orphan (qemu_irq irq);qemu_irq qemu_irq_invert (Object *owner,const char *name,qemu_irq irq);/* For internal use in qtest. */
Signature · 1 line
2.47.1
RFC PATCH 117/134 sysbus: Parent main-system-bus directly under /machine
In reply to Alexander GrafThe main system bus is the only object deliberately placed under /machine/unattached; every other resident is an accidental orphan. Promoting it to /machine/sysbus makes /machine/unattached a pure bug indicator that later commits can turn into a hard error.
The canonical path changes from /machine/unattached/sysbus to /machine/sysbus. qom-list users that hard-code the old path need to be updated; the hmp/qmp qom-tree output naturally follows.
--- system/vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
system/vl.c +1 -1
@@ -2211,7 +2211,7 @@ static void qemu_create_machine(QDict *qdict)object_property_add_child (object_get_root (),"machine" ,OBJECT (current_machine));qemu_create_machine_containers (OBJECT (current_machine)); -object_property_add_child (machine_get_container ("unattached" ), +object_property_add_child (OBJECT (current_machine),"sysbus" ,OBJECT (sysbus_get_default ()));if (machine_class->minimum_page_bits) {
Signature · 1 line
2.47.1
RFC PATCH 118/134 accel: Parent the accelerator singleton under /machine
In reply to Alexander Grafdo_configure_accelerator() runs after qemu_create_machine(), so current_machine is available. Give the AccelState singleton a canonical path at /machine/accel and drop the floating caller reference; on init failure, unparent instead of unref.
--- accel/accel-system.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
accel/accel-system.c +3 -1
@@ -41,12 +41,14 @@ int accel_init_machine(AccelState *accel, MachineState *ms)AccelClass *acc =ACCEL_GET_CLASS (accel);int ret; ms->accelerator = accel; +object_property_add_child (OBJECT (ms),"accel" ,OBJECT (accel)); +object_unref (OBJECT (accel)); *(acc->allowed) = true; ret = acc->init_machine (accel, ms);if (ret <0 ) { ms->accelerator =NULL ; *(acc->allowed) = false; -object_unref (OBJECT (accel)); +object_unparent (OBJECT (accel)); }else {object_set_accelerator_compat_props (acc->compat_props); }
Signature · 1 line
2.47.1
RFC PATCH 119/134 hw/core/reset: Give the root reset container and legacy shims a QOM path
In reply to Alexander GrafThe root ResettableContainer and the LegacyReset shim objects are long-lived singletons held only by static pointers and refcounts. Give them a canonical path in the composition tree so qom-tree/qom-list can enumerate them and so device_set_realized() can require a QOM parent for every object.
/machine/reset-container (ResettableContainer)
/machine/reset-container/legacy-reset[N] (LegacyReset shims)
get_root_reset_container() is first reached from configure_accelerators() or machine_run_board_init(), both of which run after qemu_create_machine(), so qdev_get_machine() is available. qemu_unregister_reset() switches from object_unref() to object_unparent() to release the child<> ref.
--- hw/core/reset.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
hw/core/reset.c +9 -4
@@ -27,6 +27,7 @@#include "system/reset.h" #include "hw/core/resettable.h" #include "hw/core/resetcontainer.h" +#include "hw/core/qdev.h" /* * Return a pointer to the singleton container that holds all the Resettable
@@ -38,7 +39,9 @@ static ResettableContainer *get_root_reset_container(void)if (!root_reset_container) { root_reset_container = -RESETTABLE_CONTAINER (object_new (TYPE_RESETTABLE_CONTAINER )); +RESETTABLE_CONTAINER (object_new_child (qdev_get_machine (), +"reset-container" , +TYPE_RESETTABLE_CONTAINER )); }return root_reset_container; }
@@ -94,7 +97,8 @@ static void legacy_reset_class_init(ObjectClass *klass, const void *data)void qemu_register_reset (QEMUResetHandler *func,void *opaque) { -Object *obj =object_new (TYPE_LEGACY_RESET ); +Object *obj =object_new_child (OBJECT (get_root_reset_container ()), +"legacy-reset[*]" ,TYPE_LEGACY_RESET );LegacyReset *lr =LEGACY_RESET (obj); lr->func = func;
@@ -104,7 +108,8 @@ void qemu_register_reset(QEMUResetHandler *func, void *opaque)void qemu_register_reset_nosnapshotload (QEMUResetHandler *func,void *opaque) { -Object *obj =object_new (TYPE_LEGACY_RESET ); +Object *obj =object_new_child (OBJECT (get_root_reset_container ()), +"legacy-reset[*]" ,TYPE_LEGACY_RESET );LegacyReset *lr =LEGACY_RESET (obj); lr->func = func;
@@ -156,7 +161,7 @@ void qemu_unregister_reset(QEMUResetHandler *func, void *opaque)if (obj) {qemu_unregister_resettable (obj); -object_unref (obj); +object_unparent (obj); } }
Signature · 1 line
2.47.1
RFC PATCH 120/134 system: Parent per-MR helper objects under their owner
In reply to Alexander GrafRamBlockAttributes and MemoryRegionPortioList objects are long-lived helpers whose lifetime is already tied to a MemoryRegion or its owner. Give each a canonical path under that owner instead of leaving them as floating refcounted objects:
<mr-path>/attributes (RamBlockAttributes)
<owner-path>/portio-list[N] (MemoryRegionPortioList)
The destroy paths switch from object_unref() to object_unparent() now that the parent holds the reference.
RamDiscardManager is deliberately left as-is: it is unref'd from memory_region_finalize() itself, so making it a child<> of the MR would introduce a use-after-free during MR teardown. It can move under a different owner in a follow-up once the RDM lifecycle is untangled from MR finalize.
--- system/ioport.c | 5 +++-- system/ram-block-attributes.c | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-)
system/ioport.c +3 -2
@@ -145,7 +145,7 @@ void portio_list_destroy(PortioList *piolist)for (i =0 ; i < piolist->nr; ++i) { mrpio =container_of (piolist->regions[i], MemoryRegionPortioList, mr);object_unparent (OBJECT (&mrpio->mr)); -object_unref (mrpio); +object_unparent (OBJECT (mrpio)); }g_free (piolist->regions); }
@@ -228,7 +228,8 @@ static void portio_list_add_1(PortioList *piolist,/* Copy the sub-list and null-terminate it. */ mrpio =MEMORY_REGION_PORTIO_LIST ( -object_new (TYPE_MEMORY_REGION_PORTIO_LIST )); +object_new_child (piolist->owner,"portio-list[*]" , +TYPE_MEMORY_REGION_PORTIO_LIST )); mrpio->portio_opaque = piolist->opaque; mrpio->ports =g_new0 (MemoryRegionPortio, count +1 );memcpy (mrpio->ports, pio_init,sizeof (MemoryRegionPortio) * count);
system/ram-block-attributes.c +4 -3
@@ -182,12 +182,13 @@ RamBlockAttributes *ram_block_attributes_create(RAMBlock *ram_block)RamBlockAttributes *attr;MemoryRegion *mr = ram_block->mr; - attr =RAM_BLOCK_ATTRIBUTES (object_new (TYPE_RAM_BLOCK_ATTRIBUTES )); + attr =RAM_BLOCK_ATTRIBUTES (object_new_child (OBJECT (mr),"attributes" , +TYPE_RAM_BLOCK_ATTRIBUTES )); attr->ram_block = ram_block;if (memory_region_add_ram_discard_source (mr,RAM_DISCARD_SOURCE (attr))) { -object_unref (OBJECT (attr)); +object_unparent (OBJECT (attr));return NULL ; } attr->bitmap_size =DIV_ROUND_UP (int128_get64 (mr->size), block_size);
@@ -202,7 +203,7 @@ void ram_block_attributes_destroy(RamBlockAttributes *attr)g_free (attr->bitmap);memory_region_del_ram_discard_source (attr->ram_block->mr,RAM_DISCARD_SOURCE (attr)); -object_unref (OBJECT (attr)); +object_unparent (OBJECT (attr)); }static void ram_block_attributes_init (Object *obj)
Signature · 1 line
2.47.1
RFC PATCH 121/134 hw/virtio, hw/display: Parent per-device helper objects
In reply to Alexander GrafThe virtio-mem system-reset shim, the vhost-user-gpu backend, and its socket chardev live exactly as long as their enclosing virtio device. Parent them under it so they show up in the composition tree instead of floating with only a refcount.
The unrealize/finalize/error paths switch from object_unref() to object_unparent(), and vhost_user_gpu_instance_finalize() drops its now-redundant unref: the vhost-backend is a child<> of the GPU and is released automatically when the GPU is finalized.
--- hw/display/vhost-user-gpu.c | 12 ++++++------ hw/virtio/virtio-mem.c | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-)
hw/display/vhost-user-gpu.c +6 -6
@@ -439,7 +439,8 @@ vhost_user_gpu_do_set_socket(VhostUserGPU *g, Error **errp)return false; } - chr =CHARDEV (object_new (TYPE_CHARDEV_SOCKET )); + chr =CHARDEV (object_new_child (OBJECT (g),"vhost-chardev" , +TYPE_CHARDEV_SOCKET ));if (!chr ||qemu_chr_add_client (chr, sv[0 ]) ==-1 ) {error_setg (errp,"Failed to make socket chardev" ); goto err;
@@ -462,7 +463,7 @@ err:close (sv[0 ]);close (sv[1 ]);if (chr) { -object_unref (OBJECT (chr)); +object_unparent (OBJECT (chr)); }return false; }
@@ -584,7 +585,8 @@ vhost_user_gpu_instance_init(Object *obj) {VhostUserGPU *g =VHOST_USER_GPU (obj); - g->vhost =VHOST_USER_BACKEND (object_new (TYPE_VHOST_USER_BACKEND )); + g->vhost =VHOST_USER_BACKEND (object_new_child (obj,"vhost-backend" , +TYPE_VHOST_USER_BACKEND ));object_property_add_alias (obj,"chardev" ,OBJECT (g->vhost),"chardev" ); }
@@ -592,9 +594,7 @@ vhost_user_gpu_instance_init(Object *obj)static void vhost_user_gpu_instance_finalize (Object *obj) { -VhostUserGPU *g =VHOST_USER_GPU (obj); - -object_unref (OBJECT (g->vhost)); +/* g->vhost is a child<> of obj and released with it */ } static void
hw/virtio/virtio-mem.c +3 -2
@@ -1011,7 +1011,8 @@ static void virtio_mem_device_realize(DeviceState *dev, Error **errp)* we need a dedicated reset object that only gets called during * qemu_devices_reset(). */ - obj =object_new (TYPE_VIRTIO_MEM_SYSTEM_RESET ); + obj =object_new_child (OBJECT (vmem),"system-reset" , +TYPE_VIRTIO_MEM_SYSTEM_RESET ); vmem->system_reset =VIRTIO_MEM_SYSTEM_RESET (obj); vmem->system_reset->vmem = vmem;qemu_register_resettable (obj);
@@ -1023,7 +1024,7 @@ static void virtio_mem_device_unrealize(DeviceState *dev)VirtIOMEM *vmem =VIRTIO_MEM (dev);qemu_unregister_resettable (OBJECT (vmem->system_reset)); -object_unref (OBJECT (vmem->system_reset)); +object_unparent (OBJECT (vmem->system_reset));if (vmem->early_migration) { vmstate_unregister(VMSTATE_IF(vmem), &vmstate_virtio_mem_device_early,
Signature · 1 line
2.47.1
RFC PATCH 122/134 hw/i386/amd_iommu: Parent internally-created AMDVI-PCI under the IOMMU
In reply to Alexander GrafWhen the AMD IOMMU creates its own PCI companion device (no pci-id supplied by the user), parent it under the sysbus IOMMU so it has a canonical path at <iommu>/pci. The user-supplied path already parents via -device.
--- hw/i386/amd_iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/i386/amd_iommu.c +2 -1
@@ -2698,7 +2698,8 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp) s->pci =AMD_IOMMU_PCI (pdev); dc->vmsd = &vmstate_amdvi_sysbus_migratable; }else { - s->pci =AMD_IOMMU_PCI (object_new (TYPE_AMD_IOMMU_PCI )); + s->pci =AMD_IOMMU_PCI (object_new_child (OBJECT (s),"pci" , +TYPE_AMD_IOMMU_PCI ));/* This device should take care of IOMMU PCI properties */ if (!qdev_realize (DEVICE (s->pci), &bus->qbus, errp)) {return ;
Signature · 1 line
2.47.1
RFC PATCH 123/134 hw/s390x, hw/remote: Parent per-devfn IOMMU objects
In reply to Alexander GrafGive the per-devfn S390 PCI IOMMU object a canonical path under the S390 PCI host state. s390_pci_iommu_free() already calls object_unparent(), which was previously a no-op; it now performs the actual release.
For the multi-process remote IOMMU, replace the raw object_new(TYPE_MEMORY_REGION) with a proper memory_region_init() under the RemoteIommu object so the MR gets an owner like every other MR in the tree.
--- hw/remote/iommu.c | 5 +++-- hw/s390x/s390-pci-bus.c | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-)
hw/remote/iommu.c +3 -2
@@ -52,8 +52,9 @@ static AddressSpace *remote_iommu_find_add_as(PCIBus *pci_bus, }if (!elem->mr) { - elem->mr =MEMORY_REGION (object_new (TYPE_MEMORY_REGION )); -memory_region_set_size (elem->mr,UINT64_MAX ); + g_autofree char *name = g_strdup_printf("mr-devfn-%02x", devfn); + elem->mr =g_new0 (MemoryRegion,1 ); +memory_region_init (elem->mr,OBJECT (iommu), name,UINT64_MAX );address_space_init (&elem->as, elem->mr,NULL ); }
hw/s390x/s390-pci-bus.c +7 -1
@@ -618,7 +618,13 @@ static S390PCIIOMMU *s390_pci_get_iommu(S390pciState *s, PCIBus *bus, iommu = table->iommu[PCI_SLOT (devfn)];if (!iommu) { - iommu =S390_PCI_IOMMU (object_new (TYPE_S390_PCI_IOMMU )); +char *ch_name =g_strdup_printf ("iommu[%02x:%02x.%01x]" , +pci_bus_num (bus), +PCI_SLOT (devfn), +PCI_FUNC (devfn)); + iommu =S390_PCI_IOMMU (object_new_child (OBJECT (s), ch_name, +TYPE_S390_PCI_IOMMU )); +g_free (ch_name); char *mr_name = g_strdup_printf("iommu-root-%02x:%02x.%01x", pci_bus_num(bus),
Signature · 1 line
2.47.1
RFC PATCH 124/134 hw/pci-host/raven: Parent the OR-IRQ under the host bridge
In reply to Alexander GrafThe PReP raven host bridge creates an or-irq gate to fan PCI interrupts into IRQ 15. Parent it under the host bridge so it gets a canonical path.
--- hw/pci-host/raven.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/pci-host/raven.c +2 -1
@@ -249,7 +249,8 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp)* According to PReP specification section 6.1.6 "System Interrupt * Assignments", all PCI interrupts are routed via IRQ 15 */ - s->or_irq =OR_IRQ (object_new (TYPE_OR_IRQ )); + s->or_irq =OR_IRQ (object_new_child (OBJECT (s),"or-irq" , +TYPE_OR_IRQ ));object_property_set_int (OBJECT (s->or_irq),"num-lines" ,PCI_NUM_PINS , &error_fatal);qdev_realize (DEVICE (s->or_irq),NULL , &error_fatal);
Signature · 1 line
2.47.1
RFC PATCH 125/134 hw/arm/mps2: Parent the OR-IRQ gates under the machine
In reply to Alexander GrafThe mps2 board creates several TYPE_OR_IRQ gates for UART overflow, per-UART tx/rx, and SPI interrupts. Parent them under the machine so they get canonical paths. The 282/325 pair sit on mutually-exclusive switch arms, so a single "uart-orgate" name is sufficient; the loop-created gates use "[*]" auto-indexing.
--- hw/arm/mps2.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
hw/arm/mps2.c +5 -4
@@ -279,7 +279,7 @@ static void mps2_common_init(MachineState *machine)Object *orgate;DeviceState *orgate_dev; - orgate =object_new (TYPE_OR_IRQ ); + orgate =object_new_child (OBJECT (mms),"uart-orgate" ,TYPE_OR_IRQ );object_property_set_int (orgate,"num-lines" ,6 , &error_fatal);qdev_realize (DEVICE (orgate),NULL , &error_fatal); orgate_dev =DEVICE (orgate);
@@ -322,7 +322,7 @@ static void mps2_common_init(MachineState *machine)Object *orgate;DeviceState *orgate_dev; - orgate =object_new (TYPE_OR_IRQ ); + orgate =object_new_child (OBJECT (mms),"uart-orgate" ,TYPE_OR_IRQ );object_property_set_int (orgate,"num-lines" ,10 , &error_fatal);qdev_realize (DEVICE (orgate),NULL , &error_fatal); orgate_dev =DEVICE (orgate);
@@ -338,7 +338,8 @@ static void mps2_common_init(MachineState *machine)DeviceState *txrx_orgate_dev, *dev;SysBusDevice *s; - txrx_orgate =object_new (TYPE_OR_IRQ ); + txrx_orgate =object_new_child (OBJECT (mms),"uart-txrx-orgate[*]" , +TYPE_OR_IRQ );object_property_set_int (txrx_orgate,"num-lines" ,2 , &error_fatal);qdev_realize (DEVICE (txrx_orgate),NULL , &error_fatal); txrx_orgate_dev =DEVICE (txrx_orgate);
@@ -430,7 +431,7 @@ static void mps2_common_init(MachineState *machine)Object *orgate;int j; - orgate =object_new (TYPE_OR_IRQ ); + orgate =object_new_child (OBJECT (mms),"spi-orgate[*]" ,TYPE_OR_IRQ );object_property_set_int (orgate,"num-lines" ,2 , &error_fatal); orgate_dev =DEVICE (orgate);qdev_realize (orgate_dev,NULL , &error_fatal);
Signature · 1 line
2.47.1
RFC PATCH 126/134 hw/arm/digic: Parent the DIGIC SoC under the machine
In reply to Alexander GrafBring digic in line with cubieboard/orangepi/bpim2u/imx6ul/imx7, which all parent their SoC as /machine/soc.
--- hw/arm/digic_boards.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/arm/digic_boards.c +2 -1
@@ -50,7 +50,8 @@ typedef struct DigicBoard {static void digic4_board_init (MachineState *machine,DigicBoard *board) {Error *err =NULL ; -DigicState *s =DIGIC (object_new (TYPE_DIGIC )); +DigicState *s =DIGIC (object_new_child (OBJECT (machine),"soc" , +TYPE_DIGIC ));MachineClass *mc =MACHINE_GET_CLASS (machine);if (machine->ram_size != mc->default_ram_size) {
Signature · 1 line
2.47.1
RFC PATCH 127/134 hw/microblaze: Parent the CPU under the machine
In reply to Alexander GrafBoth petalogix boards create exactly one MicroBlaze CPU via object_new(); parent it as /machine/cpu[0] like every other single-CPU board.
--- hw/microblaze/petalogix_ml605_mmu.c | 3 ++- hw/microblaze/petalogix_s3adsp1800_mmu.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
hw/microblaze/petalogix_ml605_mmu.c +2 -1
@@ -82,7 +82,8 @@ petalogix_ml605_init(MachineState *machine)qemu_irq irq[32 ];/* init CPUs */ - cpu =MICROBLAZE_CPU (object_new (TYPE_MICROBLAZE_CPU )); + cpu =MICROBLAZE_CPU (object_new_child (OBJECT (machine),"cpu[0]" , +TYPE_MICROBLAZE_CPU ));object_property_set_str (OBJECT (cpu),"version" ,"8.10.a" , &error_abort);/* Use FPU but don't use floating point conversion and square * root instructions
hw/microblaze/petalogix_s3adsp1800_mmu.c +2 -1
@@ -85,7 +85,8 @@ petalogix_s3adsp1800_init(MachineState *machine)MemoryRegion *sysmem =get_system_memory ();EndianMode endianness = psms->endianness; - cpu =MICROBLAZE_CPU (object_new (TYPE_MICROBLAZE_CPU )); + cpu =MICROBLAZE_CPU (object_new_child (OBJECT (machine),"cpu[0]" , +TYPE_MICROBLAZE_CPU ));object_property_set_str (OBJECT (cpu),"version" ,"7.10.d" , &error_abort);object_property_set_bool (OBJECT (cpu),"little-endian" , endianness ==ENDIAN_MODE_LITTLE , &error_abort);
Signature · 1 line
2.47.1
RFC PATCH 128/134 hw: Pair object_initialize_child() with plain realize()
In reply to Alexander GrafA number of composite devices and boards create embedded children via object_initialize_child() (or object_new_with_props()) and then realize them via *_realize_and_unref(). The child<> property already holds the sole reference; the extra unref drops it and the object survives only because bus_add_child() takes a reference of its own. Use plain sysbus_realize()/qdev_realize() so the parent's child<> keeps the reference it is documented to hold.
--- hw/arm/imx8mm-evk.c | 2 +- hw/arm/imx8mp-evk.c | 2 +- hw/arm/mps2.c | 2 +- hw/display/sm501.c | 2 +- hw/m68k/q800.c | 6 +++--- hw/misc/macio/macio.c | 2 +- hw/net/imx_fec.c | 2 +- hw/net/lan9118.c | 2 +- hw/nubus/nubus-virtio-mmio.c | 2 +- hw/pci-host/mv64361.c | 2 +- hw/xen/xen-pvh-common.c | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-)
hw/arm/imx8mm-evk.c +1 -1
@@ -80,7 +80,7 @@ static void imx8mm_evk_init(MachineState *machine) s =FSL_IMX8MM (object_new_with_props (TYPE_FSL_IMX8MM ,OBJECT (machine),"soc" , &error_fatal,NULL ));object_property_set_uint (OBJECT (s),"fec1-phy-num" ,1 , &error_fatal); -sysbus_realize_and_unref (SYS_BUS_DEVICE (s), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (s), &error_fatal);memory_region_add_subregion (get_system_memory (),FSL_IMX8MM_RAM_START , machine->ram);
hw/arm/imx8mp-evk.c +1 -1
@@ -93,7 +93,7 @@ static void imx8mp_evk_init(MachineState *machine)object_property_set_link (OBJECT (&s->soc), bus_name,OBJECT (s->canbus[i]), &error_fatal); } -sysbus_realize_and_unref (SYS_BUS_DEVICE (&s->soc), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (&s->soc), &error_fatal);memory_region_add_subregion (get_system_memory (),FSL_IMX8MP_RAM_START , machine->ram);
hw/arm/mps2.c +1 -1
@@ -379,7 +379,7 @@ static void mps2_common_init(MachineState *machine) TYPE_CMSDK_APB_TIMER); sbd =SYS_BUS_DEVICE (&mms->timer[i]);qdev_connect_clock_in (DEVICE (&mms->timer[i]),"pclk" , mms->sysclk); -sysbus_realize_and_unref (sbd, &error_fatal); +sysbus_realize (sbd, &error_fatal);sysbus_mmio_map (sbd,0 , base);sysbus_connect_irq (sbd,0 ,qdev_get_gpio_in (armv7m, irqno)); }
hw/display/sm501.c +1 -1
@@ -2045,7 +2045,7 @@ static void sm501_realize_sysbus(DeviceState *dev, Error **errp)sysbus_init_mmio (sbd, &s->state.mmio_region);/* bridge to usb host emulation module */ -sysbus_realize_and_unref (SYS_BUS_DEVICE (&s->ohci), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (&s->ohci), &error_fatal);memory_region_add_subregion (&s->state.mmio_region,SM501_USB_HOST ,sysbus_mmio_get_region (SYS_BUS_DEVICE (&s->ohci),0 ));sysbus_pass_irq (sbd,SYS_BUS_DEVICE (&s->ohci));
hw/m68k/q800.c +3 -3
@@ -324,14 +324,14 @@ static void q800_machine_init(MachineState *machine)object_initialize_child (OBJECT (machine),"djmemc" , &m->djmemc,TYPE_DJMEMC ); sysbus =SYS_BUS_DEVICE (&m->djmemc); -sysbus_realize_and_unref (sysbus, &error_fatal); +sysbus_realize (sysbus, &error_fatal);memory_region_add_subregion (&m->macio,DJMEMC_BASE -IO_BASE ,sysbus_mmio_get_region (sysbus,0 ));/* IOSB subsystem */ object_initialize_child (OBJECT (machine),"iosb" , &m->iosb,TYPE_IOSB ); sysbus =SYS_BUS_DEVICE (&m->iosb); -sysbus_realize_and_unref (sysbus, &error_fatal); +sysbus_realize (sysbus, &error_fatal);memory_region_add_subregion (&m->macio,IOSB_BASE -IO_BASE ,sysbus_mmio_get_region (sysbus,0 ));
@@ -497,7 +497,7 @@ static void q800_machine_init(MachineState *machine)qdev_prop_set_string (DEVICE (&m->asc),"audiodev" , machine->audiodev); } sysbus =SYS_BUS_DEVICE (&m->asc); -sysbus_realize_and_unref (sysbus, &error_fatal); +sysbus_realize (sysbus, &error_fatal);memory_region_add_subregion (&m->macio,ASC_BASE -IO_BASE ,sysbus_mmio_get_region (sysbus,0 )); sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(DEVICE(&m->glue),
hw/misc/macio/macio.c +1 -1
@@ -274,7 +274,7 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)/* OpenPIC */ qdev_prop_set_uint32 (pic_dev,"model" ,OPENPIC_MODEL_KEYLARGO ); sbd =SYS_BUS_DEVICE (&ns->pic); -sysbus_realize_and_unref (sbd, &error_fatal); +sysbus_realize (sbd, &error_fatal);memory_region_add_subregion (&s->bar,0x40000 ,sysbus_mmio_get_region (sbd,0 ));
hw/net/imx_fec.c +1 -1
@@ -1207,7 +1207,7 @@ static void imx_eth_realize(DeviceState *dev, Error **errp)qemu_init_irq_child (OBJECT (s),"mii-irq" , &s->mii_irq, imx_phy_update_irq, s,0 );object_initialize_child (OBJECT (s),"mii" , &s->mii,TYPE_LAN9118_PHY ); -if (!sysbus_realize_and_unref (SYS_BUS_DEVICE (&s->mii), errp)) { +if (!sysbus_realize (SYS_BUS_DEVICE (&s->mii), errp)) {return ; }qdev_connect_gpio_out (DEVICE (&s->mii),0 , &s->mii_irq);
hw/net/lan9118.c +1 -1
@@ -1276,7 +1276,7 @@ static void lan9118_realize(DeviceState *dev, Error **errp)qemu_init_irq_child (OBJECT (s),"mii-irq" , &s->mii_irq, lan9118_update_irq, s,0 );object_initialize_child (OBJECT (s),"mii" , &s->mii,TYPE_LAN9118_PHY ); -if (!sysbus_realize_and_unref (SYS_BUS_DEVICE (&s->mii), errp)) { +if (!sysbus_realize (SYS_BUS_DEVICE (&s->mii), errp)) {return ; }qdev_connect_gpio_out (DEVICE (&s->mii),0 , &s->mii_irq);
hw/nubus/nubus-virtio-mmio.c +1 -1
@@ -51,7 +51,7 @@ static void nubus_virtio_mmio_realize(DeviceState *dev, Error **errp)for (i =0 ; i <NUBUS_VIRTIO_MMIO_NUM_DEVICES ; i++) { sbd =SYS_BUS_DEVICE (&s->virtio_mmio[i]);qdev_prop_set_bit (DEVICE (sbd),"force-legacy" , false); -if (!sysbus_realize_and_unref (sbd, errp)) { +if (!sysbus_realize (sbd, errp)) {return ; }
hw/pci-host/mv64361.c +1 -1
@@ -874,7 +874,7 @@ static void mv64361_realize(DeviceState *dev, Error **errp) TYPE_MV64361_PCI);DeviceState *pci =DEVICE (&s->pci[i]);qdev_prop_set_uint8 (pci,"index" , i); -sysbus_realize_and_unref (SYS_BUS_DEVICE (pci), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (pci), &error_fatal); }sysbus_init_irq (SYS_BUS_DEVICE (dev), &s->cpu_irq);qdev_init_gpio_in_named (dev, mv64361_gpp_irq,"gpp" ,32 );
hw/xen/xen-pvh-common.c +1 -1
@@ -230,7 +230,7 @@ static inline void xenpvh_gpex_init(XenPVHMachineState *s,object_initialize_child (OBJECT (s),"gpex" , &s->pci.gpex,TYPE_GPEX_HOST ); dev =DEVICE (&s->pci.gpex); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal); ecam_reg =sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 );memory_region_add_subregion (sysmem, s->cfg.pci_ecam.base, ecam_reg);
Signature · 1 line
2.47.1
RFC PATCH 129/134 hw: Parent board-created CPUs under the machine
In reply to Alexander GrafA number of boards create CPUs via object_new(cpu_type) followed by property setting and qdev_realize(NULL), rather than through cpu_create(). These CPUs currently fall into /machine/unattached via the device_set_realized() fallback. Parent them explicitly under the machine (or the CPS/SoC container that owns them) as "cpu[*]", matching the naming convention used by cpu_create().
The subsequent object_unref() and qdev_realize_and_unref() calls are converted to plain qdev_realize() (or dropped) since the parent's child<> property now holds the reference. Error paths switch to object_unparent().
The transient introspection object_new() in hw/arm/virt.c machvirt_init() (probing pa_bits) is deliberately left as-is; it is unref'd immediately without being realized.
hw/arm: integratorcp mps3r realview sbsa-ref versatilepb
vexpress virt xilinx-zynq
hw/hexagon: hexagon_dsp virt
hw/i386: x86-common xen-pvh
hw/loongarch: virt
hw/mips: cps hw/ppc: e500 spapr (cpu-core) hw/riscv: cps microblaze-v-generic hw/s390x: s390-virtio-ccw hw/sparc: leon3 sun4m hw/sparc64: sparc64
--- hw/arm/integratorcp.c | 3 ++- hw/arm/mps3r.c | 4 ++-- hw/arm/realview.c | 3 ++- hw/arm/sbsa-ref.c | 4 ++-- hw/arm/versatilepb.c | 3 ++- hw/arm/vexpress.c | 3 ++- hw/arm/virt.c | 4 ++-- hw/arm/xilinx_zynq.c | 3 ++- hw/hexagon/hexagon_dsp.c | 5 +++-- hw/hexagon/virt.c | 5 +++-- hw/i386/x86-common.c | 9 ++++----- hw/i386/xen/xen-pvh.c | 5 ++--- hw/loongarch/virt.c | 5 +++-- hw/mips/cps.c | 5 +++-- hw/ppc/e500.c | 5 +++-- hw/ppc/spapr.c | 4 ++-- hw/riscv/cps.c | 5 +++-- hw/riscv/microblaze-v-generic.c | 3 ++- hw/s390x/s390-virtio-ccw.c | 16 +++++++--------- hw/sparc/leon3.c | 3 ++- hw/sparc/sun4m.c | 5 +++-- hw/sparc64/sparc64.c | 3 ++- 22 files changed, 58 insertions(+), 47 deletions(-)
hw/arm/integratorcp.c +2 -1
@@ -598,7 +598,8 @@ static void integratorcp_init(MachineState *machine)DriveInfo *dinfo;int i; - cpuobj =object_new (machine->cpu_type); + cpuobj =object_new_child (OBJECT (machine),"cpu[0]" , + machine->cpu_type);/* By default ARM1176 CPUs have EL3 enabled. This board does not * currently support EL3 so the CPU EL3 property is disabled before
hw/arm/mps3r.c +2 -2
@@ -388,13 +388,13 @@ static void mps3r_common_init(MachineState *machine)memory_region_add_subregion_overlap (&mms->cpu_sysmem[i],0 , &mms->sysmem_alias[i],-1 ); - mms->cpu[i] =object_new (machine->cpu_type); + mms->cpu[i] =object_new_child (OBJECT (mms),"cpu[*]" , + machine->cpu_type);object_property_set_link (mms->cpu[i],"memory" ,OBJECT (&mms->cpu_sysmem[i]), &error_abort);object_property_set_int (mms->cpu[i],"reset-cbar" ,PERIPHBASE , &error_abort);qdev_realize (DEVICE (mms->cpu[i]),NULL , &error_fatal); -object_unref (mms->cpu[i]);/* Per-CPU RAM */ memory_region_init_ram(&mms->cpu_ram[i], OBJECT(mms), ramname,
hw/arm/realview.c +2 -1
@@ -119,7 +119,8 @@ static void realview_init(MachineState *machine, }for (n =0 ; n < smp_cpus; n++) { -Object *cpuobj =object_new (machine->cpu_type); +Object *cpuobj =object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type);/* By default A9,A15 and ARM1176 CPUs have EL3 enabled. This board * does not currently support EL3 so the CPU EL3 property is disabled
hw/arm/sbsa-ref.c +2 -2
@@ -783,7 +783,8 @@ static void sbsa_ref_init(MachineState *machine)break ; } - cpuobj =object_new (possible_cpus->cpus[n].type); + cpuobj =object_new_child (OBJECT (sms),"cpu[*]" , + possible_cpus->cpus[n].type);object_property_set_int (cpuobj,"mp-affinity" , possible_cpus->cpus[n].arch_id,NULL );
@@ -808,7 +809,6 @@ static void sbsa_ref_init(MachineState *machine) OBJECT(secure_sysmem), &error_abort);qdev_realize (DEVICE (cpuobj),NULL , &error_fatal); -object_unref (cpuobj); } memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base,
hw/arm/versatilepb.c +2 -1
@@ -208,7 +208,8 @@ static void versatile_init(MachineState *machine, int board_id)exit (1 ); } - cpuobj =object_new (machine->cpu_type); + cpuobj =object_new_child (OBJECT (machine),"cpu[0]" , + machine->cpu_type);/* By default ARM1176 CPUs have EL3 enabled. This board does not * currently support EL3 so the CPU EL3 property is disabled before
hw/arm/vexpress.c +2 -1
@@ -219,7 +219,8 @@ static void init_cpus(MachineState *ms, const char *cpu_type,/* Create the actual CPUs */ for (n =0 ; n < smp_cpus; n++) { -Object *cpuobj =object_new (cpu_type); +Object *cpuobj =object_new_child (qdev_get_machine (),"cpu[*]" , + cpu_type);if (!secure) {object_property_set_bool (cpuobj,"has_el3" , false,NULL );
hw/arm/virt.c +2 -2
@@ -3039,7 +3039,8 @@ static void machvirt_init(MachineState *machine)break ; } - cpuobj =object_new (possible_cpus->cpus[n].type); + cpuobj =object_new_child (OBJECT (vms),"cpu[*]" , + possible_cpus->cpus[n].type);object_property_set_int (cpuobj,"mp-affinity" , possible_cpus->cpus[n].arch_id,NULL );
@@ -3139,7 +3140,6 @@ static void machvirt_init(MachineState *machine) }qdev_realize (DEVICE (cpuobj),NULL , &error_fatal); -object_unref (cpuobj); }/* Now we've created the CPUs we can see if they have the hypvirt timer */
hw/arm/xilinx_zynq.c +2 -1
@@ -222,7 +222,8 @@ static void zynq_init(MachineState *machine) }for (n =0 ; n < smp_cpus; n++) { -Object *cpuobj =object_new (machine->cpu_type); +Object *cpuobj =object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type);object_property_set_int (cpuobj,"midr" ,ZYNQ_BOARD_MIDR , &error_fatal);
hw/hexagon/hexagon_dsp.c +3 -2
@@ -143,7 +143,8 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,sysbus_realize (SYS_BUS_DEVICE (tlb_dev), &error_fatal);for (int i =0 ; i < machine->smp.cpus; i++) { -HexagonCPU *cpu =HEXAGON_CPU (object_new (machine->cpu_type)); +HexagonCPU *cpu =HEXAGON_CPU (object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type));qemu_register_reset (do_cpu_reset, cpu);/*
@@ -158,7 +159,7 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, OBJECT(glob_regs_dev), &error_fatal);object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (tlb_dev), &error_fatal); -qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal); +qdev_realize (DEVICE (cpu),NULL , &error_fatal); } rom_add_blob_fixed_as("config_table.rom", &m_cfg->cfgtable,
hw/hexagon/virt.c +3 -2
@@ -280,7 +280,8 @@ static void virt_init(MachineState *ms) cpu0 =NULL ;for (int i =0 ; i < ms->smp.cpus; i++) { -HexagonCPU *cpu =HEXAGON_CPU (object_new (ms->cpu_type)); +HexagonCPU *cpu =HEXAGON_CPU (object_new_child (OBJECT (ms),"cpu[*]" , + ms->cpu_type));qemu_register_reset (do_cpu_reset, cpu);if (i ==0 ) {
@@ -300,7 +301,7 @@ static void virt_init(MachineState *ms)object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (tlb_dev), &error_fatal); -qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal); +qdev_realize (DEVICE (cpu),NULL , &error_fatal); }fdt_add_cpu_nodes (vms); clk_phandle =fdt_add_clocks (vms);
hw/i386/x86-common.c +4 -5
@@ -55,15 +55,14 @@ static size_t pvh_start_addr;static void x86_cpu_new (X86MachineState *x86ms,int64_t apic_id,Error **errp) { -Object *cpu =object_new (MACHINE (x86ms)->cpu_type); +Object *cpu =object_new_child (OBJECT (x86ms),"cpu[*]" , +MACHINE (x86ms)->cpu_type);if (!object_property_set_uint (cpu,"apic-id" , apic_id, errp)) { - goto out; +object_unparent (cpu); +return ; }qdev_realize (DEVICE (cpu),NULL , errp); - -out: -object_unref (cpu); }void x86_cpus_init (X86MachineState *x86ms,int default_cpu_version)
hw/i386/xen/xen-pvh.c +2 -3
@@ -29,12 +29,11 @@ struct XenPVHx86State {static DeviceState *xen_pvh_cpu_new (MachineState *ms,int64_t apic_id) { -Object *cpu =object_new (ms->cpu_type); +Object *cpu =object_new_child (OBJECT (ms),"cpu[*]" , + ms->cpu_type); -object_property_add_child (OBJECT (ms),"cpu[*]" , cpu);object_property_set_uint (cpu,"apic-id" , apic_id, &error_fatal);qdev_realize (DEVICE (cpu),NULL , &error_fatal); -object_unref (cpu);return DEVICE (cpu); }
hw/loongarch/virt.c +3 -2
@@ -948,13 +948,14 @@ static void virt_init(MachineState *machine)/* Init CPUs */ mc->possible_cpu_arch_ids (machine);for (i =0 ; i < machine->smp.cpus; i++) { - cpuobj =object_new (machine->cpu_type); + cpuobj =object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type);if (cpuobj ==NULL ) {error_report ("Fail to create object with type %s " , machine->cpu_type);exit (EXIT_FAILURE ); } -qdev_realize_and_unref (DEVICE (cpuobj),NULL , &error_fatal); +qdev_realize (DEVICE (cpuobj),NULL , &error_fatal); }virt_check_dmsi (machine);fw_cfg_add_memory (machine);
hw/mips/cps.c +3 -2
@@ -74,7 +74,8 @@ static void mips_cps_realize(DeviceState *dev, Error **errp) }for (int i =0 ; i < s->num_vp; i++) { -MIPSCPU *cpu =MIPS_CPU (object_new (s->cpu_type)); +MIPSCPU *cpu =MIPS_CPU (object_new_child (OBJECT (s),"cpu[*]" , + s->cpu_type));CPUMIPSState *env = &cpu->env; object_property_set_bool(OBJECT(cpu), "big-endian", s->cpu_is_bigendian,
@@ -87,7 +88,7 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)/* All cores use the same clock tree */ qdev_connect_clock_in (DEVICE (cpu),"clk-in" , s->clock); -if (!qdev_realize_and_unref (DEVICE (cpu),NULL , errp)) { +if (!qdev_realize (DEVICE (cpu),NULL , errp)) {return ; }
hw/ppc/e500.c +3 -2
@@ -941,7 +941,8 @@ void ppce500_init(MachineState *machine)PowerPCCPU *cpu;CPUState *cs; - cpu =POWERPC_CPU (object_new (machine->cpu_type)); + cpu =POWERPC_CPU (object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type)); env = &cpu->env; cs =CPU (cpu);
@@ -956,7 +957,7 @@ void ppce500_init(MachineState *machine)*/ object_property_set_bool (OBJECT (cs),"start-powered-off" , i !=0 , &error_abort); -qdev_realize_and_unref (DEVICE (cs),NULL , &error_fatal); +qdev_realize (DEVICE (cs),NULL , &error_fatal);if (!firstenv) { firstenv = env;
hw/ppc/spapr.c +2 -2
@@ -2776,7 +2776,8 @@ static void spapr_init_cpus(SpaprMachineState *spapr) }if (i < boot_cores_nr) { -Object *core =object_new (type); +Object *core =object_new_child (OBJECT (spapr),"cpu-core[*]" , + type);int nr_threads = smp_threads;/* Handle the partially filled core for older machine types */
@@ -2790,7 +2791,6 @@ static void spapr_init_cpus(SpaprMachineState *spapr) &error_fatal);qdev_realize (DEVICE (core),NULL , &error_fatal); -object_unref (core); } } }
hw/riscv/cps.c +3 -2
@@ -63,13 +63,14 @@ static void riscv_cps_realize(DeviceState *dev, Error **errp)int harts_in_cluster = s->num_hart * s->num_core;int num_of_clusters = s->num_vp / harts_in_cluster;for (i =0 ; i < s->num_vp; i++) { - cpu =RISCV_CPU (object_new (s->cpu_type)); + cpu =RISCV_CPU (object_new_child (OBJECT (s),"cpu[*]" , + s->cpu_type));/* All VPs are halted on reset. Leave powering up to CPC. */ object_property_set_bool (OBJECT (cpu),"start-powered-off" , true, &error_abort); -if (!qdev_realize_and_unref (DEVICE (cpu),NULL , errp)) { +if (!qdev_realize (DEVICE (cpu),NULL , errp)) {return ; }
hw/riscv/microblaze-v-generic.c +2 -1
@@ -65,7 +65,8 @@ static void mb_v_generic_init(MachineState *machine)qemu_irq irq[32 ];MemoryRegion *sysmem =get_system_memory (); - cpu =RISCV_CPU (object_new (machine->cpu_type)); + cpu =RISCV_CPU (object_new_child (OBJECT (machine),"cpu[0]" , + machine->cpu_type));object_property_set_bool (OBJECT (cpu),"h" , false,NULL );object_property_set_bool (OBJECT (cpu),"d" , false,NULL );qdev_realize (DEVICE (cpu),NULL , &error_abort);
hw/s390x/s390-virtio-ccw.c +7 -9
@@ -56,20 +56,18 @@ static Error *pv_mig_blocker;static S390CPU *s390x_new_cpu (const char *typename,uint32_t core_id,Error **errp) { -S390CPU *cpu =S390_CPU (object_new (typename)); -S390CPU *ret =NULL ; +S390CPU *cpu =S390_CPU (object_new_child (qdev_get_machine (),"cpu[*]" , + typename));if (!object_property_set_int (OBJECT (cpu),"core-id" , core_id, errp)) { - goto out; +object_unparent (OBJECT (cpu)); +return NULL ; }if (!qdev_realize (DEVICE (cpu),NULL , errp)) { - goto out; +object_unparent (OBJECT (cpu)); +return NULL ; } - ret = cpu; - -out: -object_unref (OBJECT (cpu)); -return ret; +return cpu; }static void s390_init_cpus (MachineState *machine)
hw/sparc/leon3.c +2 -1
@@ -278,7 +278,8 @@ static void leon3_generic_hw_init(MachineState *machine)for (i =0 ; i < machine->smp.cpus; i++) {/* Init CPU */ - cpu =SPARC_CPU (object_new (machine->cpu_type)); + cpu =SPARC_CPU (object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type));qdev_init_gpio_in_named (DEVICE (cpu), leon3_start_cpu,"start_cpu" ,1 );qdev_init_gpio_in_named (DEVICE (cpu), leon3_set_pil_in,"pil" ,1 );qdev_realize (DEVICE (cpu),NULL , &error_fatal);
hw/sparc/sun4m.c +3 -2
@@ -787,7 +787,8 @@ static DeviceState *cpu_devinit(const char *cpu_type, unsigned int id,CPUSPARCState *env;DeviceState *cpudev; - cpu =SPARC_CPU (object_new (cpu_type)); + cpu =SPARC_CPU (object_new_child (qdev_get_machine (),"cpu[*]" , + cpu_type)); env = &cpu->env; cpudev =DEVICE (cpu);
@@ -795,7 +796,7 @@ static DeviceState *cpu_devinit(const char *cpu_type, unsigned int id,object_property_set_bool (OBJECT (cpu),"start-powered-off" , id !=0 , &error_abort);qdev_init_gpio_in_named (cpudev, cpu_set_irq,"pil" ,MAX_PILS ); -qdev_realize_and_unref (cpudev,NULL , &error_fatal); +qdev_realize (cpudev,NULL , &error_fatal);cpu_sparc_set_id (env, id); env->prom_addr = prom_addr;return cpudev;
hw/sparc64/sparc64.c +2 -1
@@ -272,7 +272,8 @@ SPARCCPU *sparc64_cpu_devinit(const char *cpu_type, uint64_t prom_addr)uint32_t stick_frequency =100 *1000000 ;uint32_t hstick_frequency =100 *1000000 ; - cpu =SPARC_CPU (object_new (cpu_type)); + cpu =SPARC_CPU (object_new_child (qdev_get_machine (),"cpu[0]" , + cpu_type));qdev_init_gpio_in_named (DEVICE (cpu), sparc64_cpu_set_ivec_irq,"ivec-irq" ,IVEC_MAX );qdev_realize (DEVICE (cpu),NULL , &error_fatal);
Signature · 1 line
2.47.1
Re: [RFC PATCH 129/134] hw: Parent board-created CPUs under the machine
Am 11. Juli 2026 22:37:02 UTC schrieb Alexander Graf <[email protected]>:
Quoted 28 lines
A number of boards create CPUs via
object_new(cpu_type)followed by property setting andqdev_realize(NULL), rather than throughcpu_create(). These CPUs currently fall into /machine/unattached via thedevice_set_realized()fallback. Parent them explicitly under the machine (or the CPS/SoC container that owns them) as "cpu[*]", matching the naming convention used bycpu_create().The subsequent
object_unref()andqdev_realize_and_unref()calls are converted to plainqdev_realize()(or dropped) since the parent's child<> property now holds the reference. Error paths switch toobject_unparent().The transient introspection
object_new()inhw/arm/virt.cmachvirt_init()(probingpa_bits) is deliberately left as-is; it is unref'd immediately without being realized.hw/arm: integratorcp mps3r realview sbsa-ref versatilepb
vexpress virt xilinx-zynq
hw/hexagon:hexagon_dspvirt
hw/i386: x86-common xen-pvh
hw/loongarch: virthw/mips: cps hw/ppc: e500 spapr (cpu-core) hw/riscv: cps microblaze-v-generic hw/s390x: s390-virtio-ccw hw/sparc: leon3 sun4m hw/sparc64: sparc64
Quoted 2 lines
Assisted-by KiroSigned-off-by Alexander Graf <[email protected]>
For e500 where migration compatibility is not an issue:
Quoted 455 lines
---
hw/arm/integratorcp.c | 3 ++- hw/arm/mps3r.c | 4 ++-- hw/arm/realview.c | 3 ++- hw/arm/sbsa-ref.c | 4 ++-- hw/arm/versatilepb.c | 3 ++- hw/arm/vexpress.c | 3 ++- hw/arm/virt.c | 4 ++-- hw/arm/xilinx_zynq.c | 3 ++- hw/hexagon/hexagon_dsp.c | 5 +++-- hw/hexagon/virt.c | 5 +++-- hw/i386/x86-common.c | 9 ++++----- hw/i386/xen/xen-pvh.c | 5 ++--- hw/loongarch/virt.c | 5 +++-- hw/mips/cps.c | 5 +++-- hw/ppc/e500.c | 5 +++-- hw/ppc/spapr.c | 4 ++-- hw/riscv/cps.c | 5 +++-- hw/riscv/microblaze-v-generic.c | 3 ++- hw/s390x/s390-virtio-ccw.c | 16 +++++++--------- hw/sparc/leon3.c | 3 ++- hw/sparc/sun4m.c | 5 +++-- hw/sparc64/sparc64.c | 3 ++- 22 files changed, 58 insertions(+), 47 deletions(-)hw/arm/integratorcp.c +2
-1@@ -598,7 +598,8 @@ static void integratorcp_init(MachineState *machine)DriveInfo *dinfo;int i; - cpuobj =object_new (machine->cpu_type); + cpuobj =object_new_child (OBJECT (machine),"cpu[0]" , + machine->cpu_type);/* By default ARM1176 CPUs have EL3 enabled. This board does not * currently support EL3 so the CPU EL3 property is disabled before hw/arm/mps3r.c +2
-2@@ -388,13 +388,13 @@ static void mps3r_common_init(MachineState *machine)memory_region_add_subregion_overlap (&mms->cpu_sysmem[i],0 , &mms->sysmem_alias[i],-1 ); - mms->cpu[i] =object_new (machine->cpu_type); + mms->cpu[i] =object_new_child (OBJECT (mms),"cpu[*]" , + machine->cpu_type);object_property_set_link (mms->cpu[i],"memory" ,OBJECT (&mms->cpu_sysmem[i]), &error_abort);object_property_set_int (mms->cpu[i],"reset-cbar" ,PERIPHBASE , &error_abort);qdev_realize (DEVICE (mms->cpu[i]),NULL , &error_fatal); -object_unref (mms->cpu[i]);/* Per-CPU RAM */ memory_region_init_ram(&mms->cpu_ram[i], OBJECT(mms), ramname,hw/arm/realview.c +2
-1@@ -119,7 +119,8 @@ static void realview_init(MachineState *machine, }for (n =0 ; n < smp_cpus; n++) { -Object *cpuobj =object_new (machine->cpu_type); +Object *cpuobj =object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type);/* By default A9,A15 and ARM1176 CPUs have EL3 enabled. This board * does not currently support EL3 so the CPU EL3 property is disabled hw/arm/sbsa-ref.c +2
-2@@ -783,7 +783,8 @@ static void sbsa_ref_init(MachineState *machine)break ; } - cpuobj =object_new (possible_cpus->cpus[n].type); + cpuobj =object_new_child (OBJECT (sms),"cpu[*]" , + possible_cpus->cpus[n].type);object_property_set_int (cpuobj,"mp-affinity" , possible_cpus->cpus[n].arch_id,NULL );@@ -808,7 +809,6 @@ static void sbsa_ref_init(MachineState *machine) OBJECT(secure_sysmem), &error_abort);qdev_realize (DEVICE (cpuobj),NULL , &error_fatal); -object_unref (cpuobj); } memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base,hw/arm/versatilepb.c +2
-1@@ -208,7 +208,8 @@ static void versatile_init(MachineState *machine, int board_id)exit (1 ); } - cpuobj =object_new (machine->cpu_type); + cpuobj =object_new_child (OBJECT (machine),"cpu[0]" , + machine->cpu_type);/* By default ARM1176 CPUs have EL3 enabled. This board does not * currently support EL3 so the CPU EL3 property is disabled before hw/arm/vexpress.c +2
-1@@ -219,7 +219,8 @@ static void init_cpus(MachineState *ms, const char *cpu_type,/* Create the actual CPUs */ for (n =0 ; n < smp_cpus; n++) { -Object *cpuobj =object_new (cpu_type); +Object *cpuobj =object_new_child (qdev_get_machine (),"cpu[*]" , + cpu_type);if (!secure) {object_property_set_bool (cpuobj,"has_el3" , false,NULL );hw/arm/virt.c +2
-2@@ -3039,7 +3039,8 @@ static void machvirt_init(MachineState *machine)break ; } - cpuobj =object_new (possible_cpus->cpus[n].type); + cpuobj =object_new_child (OBJECT (vms),"cpu[*]" , + possible_cpus->cpus[n].type);object_property_set_int (cpuobj,"mp-affinity" , possible_cpus->cpus[n].arch_id,NULL );@@ -3139,7 +3140,6 @@ static void machvirt_init(MachineState *machine) }qdev_realize (DEVICE (cpuobj),NULL , &error_fatal); -object_unref (cpuobj); }/* Now we've created the CPUs we can see if they have the hypvirt timer */ hw/arm/xilinx_zynq.c +2
-1@@ -222,7 +222,8 @@ static void zynq_init(MachineState *machine) }for (n =0 ; n < smp_cpus; n++) { -Object *cpuobj =object_new (machine->cpu_type); +Object *cpuobj =object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type);object_property_set_int (cpuobj,"midr" ,ZYNQ_BOARD_MIDR , &error_fatal);hw/hexagon/hexagon_dsp.c +3
-2@@ -143,7 +143,8 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,sysbus_realize (SYS_BUS_DEVICE (tlb_dev), &error_fatal);for (int i =0 ; i < machine->smp.cpus; i++) { -HexagonCPU *cpu =HEXAGON_CPU (object_new (machine->cpu_type)); +HexagonCPU *cpu =HEXAGON_CPU (object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type));qemu_register_reset (do_cpu_reset, cpu);/* @@ -158,7 +159,7 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, OBJECT(glob_regs_dev), &error_fatal);object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (tlb_dev), &error_fatal); -qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal); +qdev_realize (DEVICE (cpu),NULL , &error_fatal); } rom_add_blob_fixed_as("config_table.rom", &m_cfg->cfgtable,hw/hexagon/virt.c +3
-2@@ -280,7 +280,8 @@ static void virt_init(MachineState *ms) cpu0 =NULL ;for (int i =0 ; i < ms->smp.cpus; i++) { -HexagonCPU *cpu =HEXAGON_CPU (object_new (ms->cpu_type)); +HexagonCPU *cpu =HEXAGON_CPU (object_new_child (OBJECT (ms),"cpu[*]" , + ms->cpu_type));qemu_register_reset (do_cpu_reset, cpu);if (i ==0 ) {@@ -300,7 +301,7 @@ static void virt_init(MachineState *ms)object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (tlb_dev), &error_fatal); -qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal); +qdev_realize (DEVICE (cpu),NULL , &error_fatal); }fdt_add_cpu_nodes (vms); clk_phandle =fdt_add_clocks (vms);hw/i386/x86-common.c +4
-5@@ -55,15 +55,14 @@ static size_t pvh_start_addr;static void x86_cpu_new (X86MachineState *x86ms,int64_t apic_id,Error **errp) { -Object *cpu =object_new (MACHINE (x86ms)->cpu_type); +Object *cpu =object_new_child (OBJECT (x86ms),"cpu[*]" , +MACHINE (x86ms)->cpu_type);if (!object_property_set_uint (cpu,"apic-id" , apic_id, errp)) { - goto out; +object_unparent (cpu); +return ; }qdev_realize (DEVICE (cpu),NULL , errp); - -out: -object_unref (cpu); }void x86_cpus_init (X86MachineState *x86ms,int default_cpu_version)hw/i386/xen/xen-pvh.c +2
-3@@ -29,12 +29,11 @@ struct XenPVHx86State {static DeviceState *xen_pvh_cpu_new (MachineState *ms,int64_t apic_id) { -Object *cpu =object_new (ms->cpu_type); +Object *cpu =object_new_child (OBJECT (ms),"cpu[*]" , + ms->cpu_type); -object_property_add_child (OBJECT (ms),"cpu[*]" , cpu);object_property_set_uint (cpu,"apic-id" , apic_id, &error_fatal);qdev_realize (DEVICE (cpu),NULL , &error_fatal); -object_unref (cpu);return DEVICE (cpu); }hw/loongarch/virt.c +3
-2@@ -948,13 +948,14 @@ static void virt_init(MachineState *machine)/* Init CPUs */ mc->possible_cpu_arch_ids (machine);for (i =0 ; i < machine->smp.cpus; i++) { - cpuobj =object_new (machine->cpu_type); + cpuobj =object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type);if (cpuobj ==NULL ) {error_report ("Fail to create object with type %s " , machine->cpu_type);exit (EXIT_FAILURE ); } -qdev_realize_and_unref (DEVICE (cpuobj),NULL , &error_fatal); +qdev_realize (DEVICE (cpuobj),NULL , &error_fatal); }virt_check_dmsi (machine);fw_cfg_add_memory (machine);hw/mips/cps.c +3
-2@@ -74,7 +74,8 @@ static void mips_cps_realize(DeviceState *dev, Error **errp) }for (int i =0 ; i < s->num_vp; i++) { -MIPSCPU *cpu =MIPS_CPU (object_new (s->cpu_type)); +MIPSCPU *cpu =MIPS_CPU (object_new_child (OBJECT (s),"cpu[*]" , + s->cpu_type));CPUMIPSState *env = &cpu->env; object_property_set_bool(OBJECT(cpu), "big-endian", s->cpu_is_bigendian,@@ -87,7 +88,7 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)/* All cores use the same clock tree */ qdev_connect_clock_in (DEVICE (cpu),"clk-in" , s->clock); -if (!qdev_realize_and_unref (DEVICE (cpu),NULL , errp)) { +if (!qdev_realize (DEVICE (cpu),NULL , errp)) {return ; }hw/ppc/e500.c +3
-2@@ -941,7 +941,8 @@ void ppce500_init(MachineState *machine)PowerPCCPU *cpu;CPUState *cs; - cpu =POWERPC_CPU (object_new (machine->cpu_type)); + cpu =POWERPC_CPU (object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type)); env = &cpu->env; cs =CPU (cpu);@@ -956,7 +957,7 @@ void ppce500_init(MachineState *machine)*/ object_property_set_bool (OBJECT (cs),"start-powered-off" , i !=0 , &error_abort); -qdev_realize_and_unref (DEVICE (cs),NULL , &error_fatal); +qdev_realize (DEVICE (cs),NULL , &error_fatal);if (!firstenv) { firstenv = env;hw/ppc/spapr.c +2
-2@@ -2776,7 +2776,8 @@ static void spapr_init_cpus(SpaprMachineState *spapr) }if (i < boot_cores_nr) { -Object *core =object_new (type); +Object *core =object_new_child (OBJECT (spapr),"cpu-core[*]" , + type);int nr_threads = smp_threads;/* Handle the partially filled core for older machine types */ @@ -2790,7 +2791,6 @@ static void spapr_init_cpus(SpaprMachineState *spapr) &error_fatal);qdev_realize (DEVICE (core),NULL , &error_fatal); -object_unref (core); } } }hw/riscv/cps.c +3
-2@@ -63,13 +63,14 @@ static void riscv_cps_realize(DeviceState *dev, Error **errp)int harts_in_cluster = s->num_hart * s->num_core;int num_of_clusters = s->num_vp / harts_in_cluster;for (i =0 ; i < s->num_vp; i++) { - cpu =RISCV_CPU (object_new (s->cpu_type)); + cpu =RISCV_CPU (object_new_child (OBJECT (s),"cpu[*]" , + s->cpu_type));/* All VPs are halted on reset. Leave powering up to CPC. */ object_property_set_bool (OBJECT (cpu),"start-powered-off" , true, &error_abort); -if (!qdev_realize_and_unref (DEVICE (cpu),NULL , errp)) { +if (!qdev_realize (DEVICE (cpu),NULL , errp)) {return ; }hw/riscv/microblaze-v-generic.c +2
-1@@ -65,7 +65,8 @@ static void mb_v_generic_init(MachineState *machine)qemu_irq irq[32 ];MemoryRegion *sysmem =get_system_memory (); - cpu =RISCV_CPU (object_new (machine->cpu_type)); + cpu =RISCV_CPU (object_new_child (OBJECT (machine),"cpu[0]" , + machine->cpu_type));object_property_set_bool (OBJECT (cpu),"h" , false,NULL );object_property_set_bool (OBJECT (cpu),"d" , false,NULL );qdev_realize (DEVICE (cpu),NULL , &error_abort);hw/s390x/s390-virtio-ccw.c +7
-9@@ -56,20 +56,18 @@ static Error *pv_mig_blocker;static S390CPU *s390x_new_cpu (const char *typename,uint32_t core_id,Error **errp) { -S390CPU *cpu =S390_CPU (object_new (typename)); -S390CPU *ret =NULL ; +S390CPU *cpu =S390_CPU (object_new_child (qdev_get_machine (),"cpu[*]" , + typename));if (!object_property_set_int (OBJECT (cpu),"core-id" , core_id, errp)) { - goto out; +object_unparent (OBJECT (cpu)); +return NULL ; }if (!qdev_realize (DEVICE (cpu),NULL , errp)) { - goto out; +object_unparent (OBJECT (cpu)); +return NULL ; } - ret = cpu; - -out: -object_unref (OBJECT (cpu)); -return ret; +return cpu; }static void s390_init_cpus (MachineState *machine)hw/sparc/leon3.c +2
-1@@ -278,7 +278,8 @@ static void leon3_generic_hw_init(MachineState *machine)for (i =0 ; i < machine->smp.cpus; i++) {/* Init CPU */ - cpu =SPARC_CPU (object_new (machine->cpu_type)); + cpu =SPARC_CPU (object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type));qdev_init_gpio_in_named (DEVICE (cpu), leon3_start_cpu,"start_cpu" ,1 );qdev_init_gpio_in_named (DEVICE (cpu), leon3_set_pil_in,"pil" ,1 );qdev_realize (DEVICE (cpu),NULL , &error_fatal);hw/sparc/sun4m.c +3
-2@@ -787,7 +787,8 @@ static DeviceState *cpu_devinit(const char *cpu_type, unsigned int id,CPUSPARCState *env;DeviceState *cpudev; - cpu =SPARC_CPU (object_new (cpu_type)); + cpu =SPARC_CPU (object_new_child (qdev_get_machine (),"cpu[*]" , + cpu_type)); env = &cpu->env; cpudev =DEVICE (cpu);@@ -795,7 +796,7 @@ static DeviceState *cpu_devinit(const char *cpu_type, unsigned int id,object_property_set_bool (OBJECT (cpu),"start-powered-off" , id !=0 , &error_abort);qdev_init_gpio_in_named (cpudev, cpu_set_irq,"pil" ,MAX_PILS ); -qdev_realize_and_unref (cpudev,NULL , &error_fatal); +qdev_realize (cpudev,NULL , &error_fatal);cpu_sparc_set_id (env, id); env->prom_addr = prom_addr;return cpudev;hw/sparc64/sparc64.c +2
-1@@ -272,7 +272,8 @@ SPARCCPU *sparc64_cpu_devinit(const char *cpu_type, uint64_t prom_addr)uint32_t stick_frequency =100 *1000000 ;uint32_t hstick_frequency =100 *1000000 ; - cpu =SPARC_CPU (object_new (cpu_type)); + cpu =SPARC_CPU (object_new_child (qdev_get_machine (),"cpu[0]" , + cpu_type));qdev_init_gpio_in_named (DEVICE (cpu), sparc64_cpu_set_ivec_irq,"ivec-irq" ,IVEC_MAX );qdev_realize (DEVICE (cpu),NULL , &error_fatal);
Re: [RFC PATCH 129/134] hw: Parent board-created CPUs under the machine
In reply to Alexander GrafQuoted 29 lines · Alexander Graf
A number of boards create CPUs via
object_new(cpu_type)followed by property setting andqdev_realize(NULL), rather than throughcpu_create(). These CPUs currently fall into /machine/unattached via thedevice_set_realized()fallback. Parent them explicitly under the machine (or the CPS/SoC container that owns them) as "cpu[*]", matching the naming convention used bycpu_create().The subsequent
object_unref()andqdev_realize_and_unref()calls are converted to plainqdev_realize()(or dropped) since the parent's child<> property now holds the reference. Error paths switch toobject_unparent().The transient introspection
object_new()inhw/arm/virt.cmachvirt_init()(probingpa_bits) is deliberately left as-is; it is unref'd immediately without being realized.hw/arm: integratorcp mps3r realview sbsa-ref versatilepb
vexpress virt xilinx-zynq
hw/hexagon:hexagon_dspvirt
hw/i386: x86-common xen-pvh
hw/loongarch: virthw/mips: cps hw/ppc: e500 spapr (cpu-core) hw/riscv: cps microblaze-v-generic hw/s390x: s390-virtio-ccw hw/sparc: leon3 sun4m hw/sparc64: sparc64
Quoted 3 lines
Assisted-by KiroSigned-off-by Alexander Graf <[email protected]>---
For hexagon,
Quoted 457 lines
hw/arm/integratorcp.c | 3 ++- hw/arm/mps3r.c | 4 ++-- hw/arm/realview.c | 3 ++- hw/arm/sbsa-ref.c | 4 ++-- hw/arm/versatilepb.c | 3 ++- hw/arm/vexpress.c | 3 ++- hw/arm/virt.c | 4 ++-- hw/arm/xilinx_zynq.c | 3 ++- hw/hexagon/hexagon_dsp.c | 5 +++-- hw/hexagon/virt.c | 5 +++-- hw/i386/x86-common.c | 9 ++++----- hw/i386/xen/xen-pvh.c | 5 ++--- hw/loongarch/virt.c | 5 +++-- hw/mips/cps.c | 5 +++-- hw/ppc/e500.c | 5 +++-- hw/ppc/spapr.c | 4 ++-- hw/riscv/cps.c | 5 +++-- hw/riscv/microblaze-v-generic.c | 3 ++- hw/s390x/s390-virtio-ccw.c | 16 +++++++--------- hw/sparc/leon3.c | 3 ++- hw/sparc/sun4m.c | 5 +++-- hw/sparc64/sparc64.c | 3 ++- 22 files changed, 58 insertions(+), 47 deletions(-)hw/arm/integratorcp.c +2
-1@@ -598,7 +598,8 @@ static void integratorcp_init(MachineState *machine)DriveInfo *dinfo;int i; - cpuobj =object_new (machine->cpu_type); + cpuobj =object_new_child (OBJECT (machine),"cpu[0]" , + machine->cpu_type);/* By default ARM1176 CPUs have EL3 enabled. This board does not * currently support EL3 so the CPU EL3 property is disabled before hw/arm/mps3r.c +2
-2@@ -388,13 +388,13 @@ static void mps3r_common_init(MachineState *machine)memory_region_add_subregion_overlap (&mms->cpu_sysmem[i],0 , &mms->sysmem_alias[i],-1 ); - mms->cpu[i] =object_new (machine->cpu_type); + mms->cpu[i] =object_new_child (OBJECT (mms),"cpu[*]" , + machine->cpu_type);object_property_set_link (mms->cpu[i],"memory" ,OBJECT (&mms->cpu_sysmem[i]), &error_abort);object_property_set_int (mms->cpu[i],"reset-cbar" ,PERIPHBASE , &error_abort);qdev_realize (DEVICE (mms->cpu[i]),NULL , &error_fatal); -object_unref (mms->cpu[i]);/* Per-CPU RAM */ memory_region_init_ram(&mms->cpu_ram[i], OBJECT(mms), ramname,hw/arm/realview.c +2
-1@@ -119,7 +119,8 @@ static void realview_init(MachineState *machine, }for (n =0 ; n < smp_cpus; n++) { -Object *cpuobj =object_new (machine->cpu_type); +Object *cpuobj =object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type);/* By default A9,A15 and ARM1176 CPUs have EL3 enabled. This board * does not currently support EL3 so the CPU EL3 property is disabled hw/arm/sbsa-ref.c +2
-2@@ -783,7 +783,8 @@ static void sbsa_ref_init(MachineState *machine)break ; } - cpuobj =object_new (possible_cpus->cpus[n].type); + cpuobj =object_new_child (OBJECT (sms),"cpu[*]" , + possible_cpus->cpus[n].type);object_property_set_int (cpuobj,"mp-affinity" , possible_cpus->cpus[n].arch_id,NULL );@@ -808,7 +809,6 @@ static void sbsa_ref_init(MachineState *machine) OBJECT(secure_sysmem), &error_abort);qdev_realize (DEVICE (cpuobj),NULL , &error_fatal); -object_unref (cpuobj); } memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base,hw/arm/versatilepb.c +2
-1@@ -208,7 +208,8 @@ static void versatile_init(MachineState *machine, int board_id)exit (1 ); } - cpuobj =object_new (machine->cpu_type); + cpuobj =object_new_child (OBJECT (machine),"cpu[0]" , + machine->cpu_type);/* By default ARM1176 CPUs have EL3 enabled. This board does not * currently support EL3 so the CPU EL3 property is disabled before hw/arm/vexpress.c +2
-1@@ -219,7 +219,8 @@ static void init_cpus(MachineState *ms, const char *cpu_type,/* Create the actual CPUs */ for (n =0 ; n < smp_cpus; n++) { -Object *cpuobj =object_new (cpu_type); +Object *cpuobj =object_new_child (qdev_get_machine (),"cpu[*]" , + cpu_type);if (!secure) {object_property_set_bool (cpuobj,"has_el3" , false,NULL );hw/arm/virt.c +2
-2@@ -3039,7 +3039,8 @@ static void machvirt_init(MachineState *machine)break ; } - cpuobj =object_new (possible_cpus->cpus[n].type); + cpuobj =object_new_child (OBJECT (vms),"cpu[*]" , + possible_cpus->cpus[n].type);object_property_set_int (cpuobj,"mp-affinity" , possible_cpus->cpus[n].arch_id,NULL );@@ -3139,7 +3140,6 @@ static void machvirt_init(MachineState *machine) }qdev_realize (DEVICE (cpuobj),NULL , &error_fatal); -object_unref (cpuobj); }/* Now we've created the CPUs we can see if they have the hypvirt timer */ hw/arm/xilinx_zynq.c +2
-1@@ -222,7 +222,8 @@ static void zynq_init(MachineState *machine) }for (n =0 ; n < smp_cpus; n++) { -Object *cpuobj =object_new (machine->cpu_type); +Object *cpuobj =object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type);object_property_set_int (cpuobj,"midr" ,ZYNQ_BOARD_MIDR , &error_fatal);hw/hexagon/hexagon_dsp.c +3
-2@@ -143,7 +143,8 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,sysbus_realize (SYS_BUS_DEVICE (tlb_dev), &error_fatal);for (int i =0 ; i < machine->smp.cpus; i++) { -HexagonCPU *cpu =HEXAGON_CPU (object_new (machine->cpu_type)); +HexagonCPU *cpu =HEXAGON_CPU (object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type));qemu_register_reset (do_cpu_reset, cpu);/* @@ -158,7 +159,7 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, OBJECT(glob_regs_dev), &error_fatal);object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (tlb_dev), &error_fatal); -qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal); +qdev_realize (DEVICE (cpu),NULL , &error_fatal); } rom_add_blob_fixed_as("config_table.rom", &m_cfg->cfgtable,hw/hexagon/virt.c +3
-2@@ -280,7 +280,8 @@ static void virt_init(MachineState *ms) cpu0 =NULL ;for (int i =0 ; i < ms->smp.cpus; i++) { -HexagonCPU *cpu =HEXAGON_CPU (object_new (ms->cpu_type)); +HexagonCPU *cpu =HEXAGON_CPU (object_new_child (OBJECT (ms),"cpu[*]" , + ms->cpu_type));qemu_register_reset (do_cpu_reset, cpu);if (i ==0 ) {@@ -300,7 +301,7 @@ static void virt_init(MachineState *ms)object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (tlb_dev), &error_fatal); -qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal); +qdev_realize (DEVICE (cpu),NULL , &error_fatal); }fdt_add_cpu_nodes (vms); clk_phandle =fdt_add_clocks (vms);hw/i386/x86-common.c +4
-5@@ -55,15 +55,14 @@ static size_t pvh_start_addr;static void x86_cpu_new (X86MachineState *x86ms,int64_t apic_id,Error **errp) { -Object *cpu =object_new (MACHINE (x86ms)->cpu_type); +Object *cpu =object_new_child (OBJECT (x86ms),"cpu[*]" , +MACHINE (x86ms)->cpu_type);if (!object_property_set_uint (cpu,"apic-id" , apic_id, errp)) { - goto out; +object_unparent (cpu); +return ; }qdev_realize (DEVICE (cpu),NULL , errp); - -out: -object_unref (cpu); }void x86_cpus_init (X86MachineState *x86ms,int default_cpu_version)hw/i386/xen/xen-pvh.c +2
-3@@ -29,12 +29,11 @@ struct XenPVHx86State {static DeviceState *xen_pvh_cpu_new (MachineState *ms,int64_t apic_id) { -Object *cpu =object_new (ms->cpu_type); +Object *cpu =object_new_child (OBJECT (ms),"cpu[*]" , + ms->cpu_type); -object_property_add_child (OBJECT (ms),"cpu[*]" , cpu);object_property_set_uint (cpu,"apic-id" , apic_id, &error_fatal);qdev_realize (DEVICE (cpu),NULL , &error_fatal); -object_unref (cpu);return DEVICE (cpu); }hw/loongarch/virt.c +3
-2@@ -948,13 +948,14 @@ static void virt_init(MachineState *machine)/* Init CPUs */ mc->possible_cpu_arch_ids (machine);for (i =0 ; i < machine->smp.cpus; i++) { - cpuobj =object_new (machine->cpu_type); + cpuobj =object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type);if (cpuobj ==NULL ) {error_report ("Fail to create object with type %s " , machine->cpu_type);exit (EXIT_FAILURE ); } -qdev_realize_and_unref (DEVICE (cpuobj),NULL , &error_fatal); +qdev_realize (DEVICE (cpuobj),NULL , &error_fatal); }virt_check_dmsi (machine);fw_cfg_add_memory (machine);hw/mips/cps.c +3
-2@@ -74,7 +74,8 @@ static void mips_cps_realize(DeviceState *dev, Error **errp) }for (int i =0 ; i < s->num_vp; i++) { -MIPSCPU *cpu =MIPS_CPU (object_new (s->cpu_type)); +MIPSCPU *cpu =MIPS_CPU (object_new_child (OBJECT (s),"cpu[*]" , + s->cpu_type));CPUMIPSState *env = &cpu->env; object_property_set_bool(OBJECT(cpu), "big-endian", s->cpu_is_bigendian,@@ -87,7 +88,7 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)/* All cores use the same clock tree */ qdev_connect_clock_in (DEVICE (cpu),"clk-in" , s->clock); -if (!qdev_realize_and_unref (DEVICE (cpu),NULL , errp)) { +if (!qdev_realize (DEVICE (cpu),NULL , errp)) {return ; }hw/ppc/e500.c +3
-2@@ -941,7 +941,8 @@ void ppce500_init(MachineState *machine)PowerPCCPU *cpu;CPUState *cs; - cpu =POWERPC_CPU (object_new (machine->cpu_type)); + cpu =POWERPC_CPU (object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type)); env = &cpu->env; cs =CPU (cpu);@@ -956,7 +957,7 @@ void ppce500_init(MachineState *machine)*/ object_property_set_bool (OBJECT (cs),"start-powered-off" , i !=0 , &error_abort); -qdev_realize_and_unref (DEVICE (cs),NULL , &error_fatal); +qdev_realize (DEVICE (cs),NULL , &error_fatal);if (!firstenv) { firstenv = env;hw/ppc/spapr.c +2
-2@@ -2776,7 +2776,8 @@ static void spapr_init_cpus(SpaprMachineState *spapr) }if (i < boot_cores_nr) { -Object *core =object_new (type); +Object *core =object_new_child (OBJECT (spapr),"cpu-core[*]" , + type);int nr_threads = smp_threads;/* Handle the partially filled core for older machine types */ @@ -2790,7 +2791,6 @@ static void spapr_init_cpus(SpaprMachineState *spapr) &error_fatal);qdev_realize (DEVICE (core),NULL , &error_fatal); -object_unref (core); } } }hw/riscv/cps.c +3
-2@@ -63,13 +63,14 @@ static void riscv_cps_realize(DeviceState *dev, Error **errp)int harts_in_cluster = s->num_hart * s->num_core;int num_of_clusters = s->num_vp / harts_in_cluster;for (i =0 ; i < s->num_vp; i++) { - cpu =RISCV_CPU (object_new (s->cpu_type)); + cpu =RISCV_CPU (object_new_child (OBJECT (s),"cpu[*]" , + s->cpu_type));/* All VPs are halted on reset. Leave powering up to CPC. */ object_property_set_bool (OBJECT (cpu),"start-powered-off" , true, &error_abort); -if (!qdev_realize_and_unref (DEVICE (cpu),NULL , errp)) { +if (!qdev_realize (DEVICE (cpu),NULL , errp)) {return ; }hw/riscv/microblaze-v-generic.c +2
-1@@ -65,7 +65,8 @@ static void mb_v_generic_init(MachineState *machine)qemu_irq irq[32 ];MemoryRegion *sysmem =get_system_memory (); - cpu =RISCV_CPU (object_new (machine->cpu_type)); + cpu =RISCV_CPU (object_new_child (OBJECT (machine),"cpu[0]" , + machine->cpu_type));object_property_set_bool (OBJECT (cpu),"h" , false,NULL );object_property_set_bool (OBJECT (cpu),"d" , false,NULL );qdev_realize (DEVICE (cpu),NULL , &error_abort);hw/s390x/s390-virtio-ccw.c +7
-9@@ -56,20 +56,18 @@ static Error *pv_mig_blocker;static S390CPU *s390x_new_cpu (const char *typename,uint32_t core_id,Error **errp) { -S390CPU *cpu =S390_CPU (object_new (typename)); -S390CPU *ret =NULL ; +S390CPU *cpu =S390_CPU (object_new_child (qdev_get_machine (),"cpu[*]" , + typename));if (!object_property_set_int (OBJECT (cpu),"core-id" , core_id, errp)) { - goto out; +object_unparent (OBJECT (cpu)); +return NULL ; }if (!qdev_realize (DEVICE (cpu),NULL , errp)) { - goto out; +object_unparent (OBJECT (cpu)); +return NULL ; } - ret = cpu; - -out: -object_unref (OBJECT (cpu)); -return ret; +return cpu; }static void s390_init_cpus (MachineState *machine)hw/sparc/leon3.c +2
-1@@ -278,7 +278,8 @@ static void leon3_generic_hw_init(MachineState *machine)for (i =0 ; i < machine->smp.cpus; i++) {/* Init CPU */ - cpu =SPARC_CPU (object_new (machine->cpu_type)); + cpu =SPARC_CPU (object_new_child (OBJECT (machine),"cpu[*]" , + machine->cpu_type));qdev_init_gpio_in_named (DEVICE (cpu), leon3_start_cpu,"start_cpu" ,1 );qdev_init_gpio_in_named (DEVICE (cpu), leon3_set_pil_in,"pil" ,1 );qdev_realize (DEVICE (cpu),NULL , &error_fatal);hw/sparc/sun4m.c +3
-2@@ -787,7 +787,8 @@ static DeviceState *cpu_devinit(const char *cpu_type, unsigned int id,CPUSPARCState *env;DeviceState *cpudev; - cpu =SPARC_CPU (object_new (cpu_type)); + cpu =SPARC_CPU (object_new_child (qdev_get_machine (),"cpu[*]" , + cpu_type)); env = &cpu->env; cpudev =DEVICE (cpu);@@ -795,7 +796,7 @@ static DeviceState *cpu_devinit(const char *cpu_type, unsigned int id,object_property_set_bool (OBJECT (cpu),"start-powered-off" , id !=0 , &error_abort);qdev_init_gpio_in_named (cpudev, cpu_set_irq,"pil" ,MAX_PILS ); -qdev_realize_and_unref (cpudev,NULL , &error_fatal); +qdev_realize (cpudev,NULL , &error_fatal);cpu_sparc_set_id (env, id); env->prom_addr = prom_addr;return cpudev;hw/sparc64/sparc64.c +2
-2@@ -272,7 +272,8 @@ SPARCCPU *sparc64_cpu_devinit(const char *cpu_type, uint64_t prom_addr)uint32_t stick_frequency =100 *1000000 ;uint32_t hstick_frequency =100 *1000000 ; - cpu =SPARC_CPU (object_new (cpu_type)); + cpu =SPARC_CPU (object_new_child (qdev_get_machine (),"cpu[0]" , + cpu_type));qdev_init_gpio_in_named (DEVICE (cpu), sparc64_cpu_set_ivec_irq,"ivec-irq" ,IVEC_MAX );qdev_realize (DEVICE (cpu),NULL , &error_fatal); --2.47.1
RFC PATCH 130/134 hw/pci-host/versatile: Use object_initialize_child() for pci_dev
In reply to Alexander GrafThe embedded versatile_pci_host device was initialized via object_initialize() without ever being parented, so it landed in /machine/unattached at realize time. Switch to object_initialize_child() so it becomes a proper child<> of the host bridge.
--- hw/pci-host/versatile.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/pci-host/versatile.c +2 -1
@@ -410,7 +410,8 @@ static void pci_vpb_realize(DeviceState *dev, Error **errp) PCI_DEVFN(11, 0), TYPE_PCI_BUS); h->bus = &s->pci_bus; -object_initialize (&s->pci_dev,sizeof (s->pci_dev),TYPE_VERSATILE_PCI_HOST ); +object_initialize_child (OBJECT (s),"pci-host" , &s->pci_dev, +TYPE_VERSATILE_PCI_HOST );for (i =0 ; i <4 ; i++) {sysbus_init_irq (sbd, &s->irq[i]);
Signature · 1 line
2.47.1
RFC PATCH 131/134 docs, qapi, scripts, iotests: Update /machine/unattached path references
In reply to Alexander GrafBoard-created devices no longer land in /machine/unattached and the next commit removes the container entirely. Update the in-tree consumers of the old paths:
scripts/arm_processor_error.py, scripts/qmp_helper.py
Search for CPUs directly under /machine.
docs/devel/s390-cpu-topology.rst, docs/system/cpu-hotplug.rst qapi/{block-core,block,machine,qom}.json
Refresh example qom-path strings.
tests/qemu-iotests/common.filter
_filter_qom_path() now normalizes any /machine/... device path so the reference outputs are stable across board naming changes.
tests/qemu-iotests/{172,186}.out
Regenerated against the new filter.
--- docs/devel/s390-cpu-topology.rst | 2 +- docs/system/cpu-hotplug.rst | 4 +- qapi/block-core.json | 12 +++--- qapi/block.json | 2 +- qapi/machine.json | 12 +++--- qapi/qom.json | 4 +- scripts/arm_processor_error.py | 3 +- scripts/qmp_helper.py | 2 +- tests/qemu-iotests/172.out | 72 ++++++++++++++++---------------- tests/qemu-iotests/186.out | 10 ++--- tests/qemu-iotests/common.filter | 2 +- 11 files changed, 62 insertions(+), 63 deletions(-)
docs/devel/s390-cpu-topology.rst +1 -1
@@ -40,7 +40,7 @@ modifiers for all configured vCPUs. }, "cpu-state": "operating", "entitlement": "medium", - "qom-path": "/machine/unattached/device[0]", + "qom-path": "/machine/cpu[0]", "cpu-index": 0, "target": "s390x" },
docs/system/cpu-hotplug.rst +2 -2
@@ -47,7 +47,7 @@ vCPU hotplug "socket-id": 0, "thread-id": 0 }, - "qom-path": "/machine/unattached/device[0]", + "qom-path": "/machine/cpu[0]", "type": "IvyBridge-IBRS-x86_64-cpu", "vcpus-count": 1 }
@@ -95,7 +95,7 @@ vCPU hotplug "socket-id": 0, "thread-id": 0 }, - "qom-path": "/machine/unattached/device[0]", + "qom-path": "/machine/cpu[0]", "target": "x86_64", "thread-id": 28957 },
qapi/block-core.json +6 -6
@@ -928,7 +928,7 @@ # "device":"ide1-cd0", # "locked":false, # "removable":true, -# "qdev": "/machine/unattached/device[23]", +# "qdev": "/machine/ide[1]/ide.1/cd0", # "tray_open": false, # "type":"unknown" # },
@@ -936,7 +936,7 @@ # "device":"floppy0", # "locked":false, # "removable":true, -# "qdev": "/machine/unattached/device[20]", +# "qdev": "/machine/fdc/floppy[0]", # "type":"unknown" # }, # {
@@ -1310,7 +1310,7 @@ # "account_invalid":true, # "account_failed":false # }, -# "qdev": "/machine/unattached/device[23]" +# "qdev": "/machine/ide[0]/ide.0/hd0" # }, # { # "device":"ide1-cd0",
@@ -1329,7 +1329,7 @@ # "account_invalid":false, # "account_failed":false # }, -# "qdev": "/machine/unattached/device[24]" +# "qdev": "/machine/ide[1]/ide.1/cd0" # }, # { # "device":"floppy0",
@@ -1348,7 +1348,7 @@ # "account_invalid":false, # "account_failed":false # }, -# "qdev": "/machine/unattached/device[16]" +# "qdev": "/machine/fdc/floppy[0]" # }, # { # "device":"sd0",
@@ -5750,7 +5750,7 @@ # .. qmp-example:: # # <- { "event": "BLOCK_IO_ERROR", -# "data": { "qom-path": "/machine/unattached/device[0]", +# "data": { "qom-path": "/machine/ide[0]/ide.0/hd1", # "device": "ide0-hd1", # "node-name": "#block212", # "operation": "write",
qapi/block.json +1 -1
@@ -404,7 +404,7 @@ # # <- { "event": "DEVICE_TRAY_MOVED", # "data": { "device": "ide1-cd0", -# "id": "/machine/unattached/device[22]", +# "id": "/machine/ide[1]/ide.1/cd0", # "tray-open": true # }, # "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
qapi/machine.json +6 -6
@@ -121,7 +121,7 @@ # "thread-id": 0, # "socket-id": 0 # }, -# "qom-path": "/machine/unattached/device[0]", +# "qom-path": "/machine/cpu[0]", # "target":"x86_64", # "cpu-index": 0 # },
@@ -132,7 +132,7 @@ # "thread-id": 0, # "socket-id": 1 # }, -# "qom-path": "/machine/unattached/device[2]", +# "qom-path": "/machine/cpu[1]", # "target":"x86_64", # "cpu-index": 1 # }
@@ -1028,7 +1028,7 @@ # { "props": { "core-id": 8 }, "type": "POWER8-spapr-cpu-core", # "vcpus-count": 1 }, # { "props": { "core-id": 0 }, "type": "POWER8-spapr-cpu-core", -# "vcpus-count": 1, "qom-path": "/machine/unattached/device[0]"} +# "vcpus-count": 1, "qom-path": "/machine/cpu[0]"} # ]} # # .. qmp-example::
@@ -1043,7 +1043,7 @@ # "props": {"core-id": 0, "socket-id": 1, "thread-id": 0} # }, # { -# "qom-path": "/machine/unattached/device[0]", +# "qom-path": "/machine/cpu[0]", # "type": "qemu64-x86_64-cpu", "vcpus-count": 1, # "props": {"core-id": 0, "socket-id": 0, "thread-id": 0} # }
@@ -1062,7 +1062,7 @@ # "props": { "core-id": 1 } # }, # { -# "qom-path": "/machine/unattached/device[0]", +# "qom-path": "/machine/cpu[0]", # "type": "qemu-s390x-cpu", "vcpus-count": 1, # "props": { "core-id": 0 } # }
@@ -1617,7 +1617,7 @@ # # <- { "event": "MEMORY_DEVICE_SIZE_CHANGE", # "data": { "id": "vm0", "size": 1073741824, -# "qom-path": "/machine/unattached/device[2]" }, +# "qom-path": "/machine/peripheral/vm0" }, # "timestamp": { "seconds": 1588168529, "microseconds": 201316 } } ## { 'event': 'MEMORY_DEVICE_SIZE_CHANGE',
qapi/qom.json +2 -2
@@ -135,7 +135,7 @@ # :title: Use absolute path # # -> { "execute": "qom-get", -# "arguments": { "path": "/machine/unattached/device[0]", +# "arguments": { "path": "/machine/cpu[0]", # "property": "hotplugged" } } # <- { "return": false } #
@@ -143,7 +143,7 @@ # :title: Use partial path # # -> { "execute": "qom-get", -# "arguments": { "path": "unattached/sysbus", +# "arguments": { "path": "machine/sysbus", # "property": "type" } } # <- { "return": "System" } ##
scripts/arm_processor_error.py +1 -2
@@ -244,8 +244,7 @@ def send_cper(self, args): qmp_cmd.set_args(args) is_cpu_type = re.compile(r"^([\w+]+\-)?arm\-cpu$") - cpus = qmp_cmd.search_qom("/machine/unattached/device", - "type", is_cpu_type) + cpus = qmp_cmd.search_qom("/machine/cpu", "type", is_cpu_type) cper = {} pei = {}
scripts/qmp_helper.py +1 -1
@@ -601,7 +601,7 @@ def search_qom(self, path, prop, regex): """ Return a list of devices that match path array like: - /machine/unattached/device + /machine/cpu /machine/peripheral-anon/device ... """
tests/qemu-iotests/172.out +36 -36
266 lines not on this page · raw message
tests/qemu-iotests/186.out +5 -5
@@ -404,7 +404,7 @@ Testing: -drive if=floppy QEMU X.Y.Z monitor - type 'help' for more information (qemu) info block floppy0: [not inserted] - Attached to: /machine/unattached/device[N] + Attached to: PATH Removable device: not locked, tray closed (qemu) quit
@@ -412,7 +412,7 @@ Testing: -drive if=floppy,driver=null-co,read-zeroes=on QEMU X.Y.Z monitor - type 'help' for more information (qemu) info block floppy0 (NODE_NAME): json:{"read-zeroes": "on", "driver": "null-co"} (null-co) - Attached to: /machine/unattached/device[N] + Attached to: PATH Removable device: not locked, tray closed Cache mode: writeback (qemu) quit
@@ -421,7 +421,7 @@ Testing: -drive if=ide,driver=null-co,read-zeroes=on QEMU X.Y.Z monitor - type 'help' for more information (qemu) info block ide0-hd0 (NODE_NAME): json:{"read-zeroes": "on", "driver": "null-co"} (null-co) - Attached to: /machine/unattached/device[N] + Attached to: PATH Cache mode: writeback (qemu) quit
@@ -429,7 +429,7 @@ Testing: -drive if=ide,media=cdrom QEMU X.Y.Z monitor - type 'help' for more information (qemu) info block ide0-cd0: [not inserted] - Attached to: /machine/unattached/device[N] + Attached to: PATH Removable device: not locked, tray closed (qemu) quit
@@ -437,7 +437,7 @@ Testing: -drive if=ide,driver=null-co,read-zeroes=on,media=cdrom QEMU X.Y.Z monitor - type 'help' for more information (qemu) info block ide0-cd0 (NODE_NAME): json:{"read-zeroes": "on", "driver": "null-co"} (null-co, read-only) - Attached to: /machine/unattached/device[N] + Attached to: PATH Removable device: not locked, tray closed Cache mode: writeback (qemu) quit
tests/qemu-iotests/common.filter +1 -1
@@ -37,7 +37,7 @@ _filter_generated_node_ids() _filter_qom_path() { - gsed -e '/Attached to:/s/\device[[0-9]\+\]/device[N]/g' + gsed -e '/Attached to:/s#/machine/.*#PATH#' } # replace occurrences of the actual TEST_DIR value with TEST_DIR
Signature · 1 line
2.47.1
RFC PATCH 132/134 qom: Delete /machine/unattached and error on unparented realize
In reply to Alexander GrafWith every board-created device, memory region, IRQ, and singleton now given an explicit QOM parent, the /machine/unattached container serves no legitimate purpose. Remove it and turn the device_set_realized() fallback into a hard error, so that any future orphan is caught at realize time rather than silently adopted into an anonymous bucket.
hw/core/qdev.c error out on !obj->parent instead of adopting
hw/core/qdev-user.c drop the fake unattached container
system/vl.c drop "unattached" from machine container list
hw/i386/pc.c search /machine recursively for the FDC instead
of the (unattached, peripheral, peripheral-anon) container triple
tests/unit/ parent test devices explicitly under /machine
After this commit, info qom-tree no longer shows /machine/unattached on any target/machine combination, and git grep '"unattached"' returns zero hits.
--- hw/core/qdev-user.c | 6 +----- hw/core/qdev.c | 20 ++++---------------- hw/i386/pc.c | 11 +---------- include/hw/core/qdev.h | 2 +- system/vl.c | 1 - tests/unit/test-qdev-global-props.c | 17 +++++++---------- tests/unit/test-qdev.c | 12 ++++-------- 7 files changed, 18 insertions(+), 51 deletions(-)
hw/core/qdev-user.c +1 -5
@@ -11,9 +11,5 @@void qdev_create_fake_machine (void ) { -Object *fake_machine_obj; - - fake_machine_obj =object_property_add_new_container (object_get_root (), -"machine" ); -object_property_add_new_container (fake_machine_obj,"unattached" ); +object_property_add_new_container (object_get_root (),"machine" ); }
hw/core/qdev.c +4 -16
@@ -485,8 +485,6 @@ static void device_set_realized(Object *obj, bool value, Error **errp)BusState *bus;NamedClockList *ncl;Error *local_err =NULL ; -bool unattached_parent = false; -static int unattached_count;if (dev->hotplugged && !dc->hotpluggable) { error_setg(errp, "Device '%s' does not support hotplugging",
@@ -500,12 +498,10 @@ static void device_set_realized(Object *obj, bool value, Error **errp) }if (!obj->parent) { -gchar *name =g_strdup_printf ("device[%d]" , unattached_count++); - -object_property_add_child (machine_get_container ("unattached" ), - name, obj); - unattached_parent = true; -g_free (name); +error_setg (errp,"device type '%s' has no QOM parent; " +"use qdev_new() with a parent" , +object_get_typename (obj)); +return ; } hotplug_ctrl =qdev_get_hotplug_handler (dev);
@@ -633,14 +629,6 @@ post_realize_fail: fail:error_propagate (errp, local_err); -if (unattached_parent) { -/* -* Beware, this doesn't just revert -* object_property_add_child(), it also runs bus_remove()! -*/ -object_unparent (OBJECT (dev)); - unattached_count--; - } }static bool device_get_hotpluggable (Object *obj,Error **errp)
hw/i386/pc.c +1 -10
@@ -368,24 +368,15 @@ static int check_fdc(Object *obj, void *opaque)return 0 ; } -static const char *const fdc_container_path[] = { -"unattached" ,"peripheral" ,"peripheral-anon" -}; -/* * Locate the FDC at IO address 0x3f0, in order to configure the CMOS registers * and ACPI objects. */ static ISADevice *pc_find_fdc0 (void ) { -int i; -Object *container;CheckFdcState state = {0 }; -for (i =0 ; i <ARRAY_SIZE (fdc_container_path); i++) { - container =machine_get_container (fdc_container_path[i]); -object_child_foreach (container, check_fdc, &state); - } +object_child_foreach_recursive (qdev_get_machine (), check_fdc, &state);if (state.multiple) { warn_report("multiple floppy disk controllers with "
include/hw/core/qdev.h +1 -1
@@ -462,7 +462,7 @@ static inline bool qdev_is_realized(DeviceState *dev)* initialization. * @dev must not be plugged into a bus already. * If @bus, plug @dev into @bus. This takes a reference to @dev. -* If @dev has no QOM parent, make one up, taking another reference. +* @dev must already have a QOM parent (see qdev_new()). * * If you created @dev via object_new() directly (holding a floating * reference), you probably want to use qdev_realize_and_unref() instead.
system/vl.c +0 -1
@@ -2192,7 +2192,6 @@ static void parse_memory_options(void)static void qemu_create_machine_containers (Object *machine) {static const char *const containers[] = { -"unattached" ,"peripheral" ,"peripheral-anon" , };
tests/unit/test-qdev-global-props.c +7 -10
@@ -78,25 +78,22 @@ static const TypeInfo subclass_type = {* inherit the global states of the parent process) will try to create qdev * and realize the device. * -* Realization of such anonymous qdev (with no parent object) requires both -* the machine object and its "unattached" container to be at least present. +* Realization requires that the device already has a QOM parent. */ static void test_init_machine (void ) {/* This is a fake machine - it doesn't need to be a machine object */ -Object *machine =object_property_add_new_container ( +object_property_add_new_container (object_get_root (),"machine" ); -/* This container must exist for anonymous qdevs to realize() */ -object_property_add_new_container (machine,"unattached" ); -} + }/* Test simple static property setting to default value */ static void test_static_prop_subprocess (void ) {MyType *mt; - mt =STATIC_TYPE (object_new (TYPE_STATIC_PROPS )); + mt =STATIC_TYPE (object_new_child (qdev_get_machine (),"dev[*]" ,TYPE_STATIC_PROPS ));qdev_realize (DEVICE (mt),NULL , &error_fatal); g_assert_cmpuint(mt->prop1, ==, PROP_DEFAULT);
@@ -131,7 +128,7 @@ static void test_static_globalprop_subprocess(void)register_global_properties (props); - mt =STATIC_TYPE (object_new (TYPE_STATIC_PROPS )); + mt =STATIC_TYPE (object_new_child (qdev_get_machine (),"dev[*]" ,TYPE_STATIC_PROPS ));qdev_realize (DEVICE (mt),NULL , &error_fatal); g_assert_cmpuint(mt->prop1, ==, 200);
@@ -249,7 +246,7 @@ static void test_dynamic_globalprop_subprocess(void)register_global_properties (props); - mt =DYNAMIC_TYPE (object_new (TYPE_DYNAMIC_PROPS )); + mt =DYNAMIC_TYPE (object_new_child (qdev_get_machine (),"dev[*]" ,TYPE_DYNAMIC_PROPS ));qdev_realize (DEVICE (mt),NULL , &error_fatal); g_assert_cmpuint(mt->prop1, ==, 101);
@@ -295,7 +292,7 @@ static void test_subclass_global_props(void)register_global_properties (props); - mt =STATIC_TYPE (object_new (TYPE_SUBCLASS )); + mt =STATIC_TYPE (object_new_child (qdev_get_machine (),"dev[*]" ,TYPE_SUBCLASS ));qdev_realize (DEVICE (mt),NULL , &error_fatal); g_assert_cmpuint(mt->prop1, ==, 102);
tests/unit/test-qdev.c +4 -8
@@ -44,24 +44,21 @@ static const TypeInfo my_dev_type_info = {/* * Initialize a fake machine, being prepared for future tests. * -* Realization of anonymous qdev (with no parent object) requires both -* the machine object and its "unattached" container to be at least present. +* Realization requires that the device already has a QOM parent. */ static void test_init_machine (void ) {/* This is a fake machine - it doesn't need to be a machine object */ -Object *machine =object_property_add_new_container ( +object_property_add_new_container (object_get_root (),"machine" ); -/* This container must exist for anonymous qdevs to realize() */ -object_property_add_new_container (machine,"unattached" ); -} + }static void test_qdev_free_properties (void ) {MyDev *mt; - mt =STATIC_TYPE (object_new (TYPE_MY_DEV )); + mt =STATIC_TYPE (object_new_child (qdev_get_machine (),"dev[*]" ,TYPE_MY_DEV )); object_set_props(OBJECT(mt), &error_fatal, "string", "something", "array-u32", "12,13",
@@ -75,7 +72,6 @@ static void test_qdev_free_properties(void) g_assert_cmpuint(mt->prop_array_u32[1], ==, 13);object_unparent (OBJECT (mt)); -object_unref (mt); }
Signature · 1 line
2.47.1
RFC PATCH 133/134 docs/devel/qom: Document the composition-tree parenting contract
In reply to Alexander GrafAdd a section to the QOM developer documentation explaining that every object must have a composition-tree parent before use, how to pick the parent (creator owns lifetime), how to name children, the reference-count contract for parented creators, and where the contract is enforced (device_set_realized, memory_region_do_init, qdev_connect_gpio_out_named).
--- docs/devel/qom.rst | 96 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+)
docs/devel/qom.rst +96 -0
@@ -27,6 +27,102 @@ that make up a QEMU "machine". You can view this tree by running objects created by the machine itself as well those created due to user configuration. +Composition-tree parenting contract +==================================== + +Every QOM object that participates in the running system must have a +composition-tree parent before it is used. The parent gives the object +a stable, canonical path such as ``/machine/soc/uart[0]`` that is +visible in ``info qom-tree`` and addressable via ``qom-get`` and +``qom-set``. Objects that reach ``realize`` (for devices), that are +wired to another object (for IRQ lines), or that are given a name (for +memory regions) without a parent are programming errors. + +Creating parented objects +------------------------- + +The standard creation helpers all take the composition-tree parent and +the child name as their first two arguments: + +.. code-block:: c + + Object *object_new_child(Object *parent, const char *id, + const char *typename); + DeviceState *qdev_new(Object *parent, const char *id, + const char *typename); + DeviceState *sysbus_create_simple(Object *parent, const char *id, + const char *type, hwaddr, qemu_irq); + PCIDevice *pci_new(Object *parent, const char *id, ...); + ISADevice *isa_new(Object *parent, const char *id, ...); + /* i2c_slave_new(), ssi_create_peripheral(), usb_new(), + cpu_create() etc. follow the same pattern. */ + +``object_new()`` remains available as the primitive allocator for +transient introspection objects and for ``qdev_device_add()``, which +parents the device via ``qdev_set_id()``. All other callers should use +one of the parented helpers above, or ``object_initialize_child()`` for +objects that are embedded by value in the parent's instance struct. + +Choosing the parent +------------------- + +The QOM parent is the object that owns the child's lifetime. In +practice this is the object whose code is creating the child: + +* Board code (``MachineClass.init``) parents onboard devices to the + machine: ``OBJECT(machine)``. +* A composite device's ``DeviceClass.realize`` parents the sub-devices + it creates to itself: ``OBJECT(dev)``. +* An SoC container likewise parents the devices it creates to the SoC + object. + +The bus a device is plugged into is *not* its composition-tree parent. +A device may sit on a bus owned by ``B`` without being a child of +``B``; the bus relationship is expressed through the ``parent_bus`` +link, not the ``child<>`` property. + +Choosing the child name +----------------------- + +* A single instance takes a bare noun: ``"uart"``, ``"gic"``, ``"rtc"``. +* A fixed number of identical instances take an explicit index: + ``"uart[0]"``, ``"uart[1]"``. +* When the caller does not care about the index, ``"uart[*]"`` lets + QOM allocate the next free slot in the ``uart[]`` array. +* Address-based names such as ``"eth@0x30000000"`` should only be used + when the address is genuinely the identity of the device. + +Child names share the parent's property namespace, so avoid names that +collide with class-defined properties of the parent (in particular, +machine class properties visible on ``/machine``). + +Reference-count contract +------------------------ + +``object_new_child()``, ``qdev_new()`` and the per-bus creators return +with the object's single reference held by the parent's ``child<>`` +property. The caller does *not* hold a reference of its own and must +therefore pair creation with plain ``qdev_realize()`` rather than +``qdev_realize_and_unref()``. The object is finalized when the parent +drops its ``child<>`` property, typically via ``object_unparent()``. + +Enforcement +----------- + +The parenting contract is enforced at the points where an unparented +object would first become visible or entangled with another object: + +* ``device_set_realized()`` fails with an ``Error`` if the device has + no composition-tree parent. +* ``memory_region_do_init()`` asserts that a memory region given a + non-empty name also has an owner. +* ``qdev_connect_gpio_out_named()`` asserts that the outbound IRQ + line being connected already has a composition-tree parent. + +There is no ``/machine/unattached`` fallback container; an object that +would previously have landed there now triggers one of the errors +above instead. + Creating a QOM class ====================
Signature · 1 line
2.47.1
RFC PATCH 134/134 MAINTAINERS: Add scripts/coccinelle/qom-parent/ under QOM
In reply to Alexander GrafThe Coccinelle scripts used to perform the tree-wide *_orphan() renames are stored under scripts/coccinelle/qom-parent/. Add the directory to the QOM MAINTAINERS entry.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -3636,6 +3636,7 @@ S: Supported F: docs/devel/qom.rst F: include/qom/ F: qapi/qom.json +F: scripts/coccinelle/qom-parent/ F: scripts/coccinelle/qom-parent-type.cocci F: scripts/qom-cast-macro-clean-cocci-gen.py F: qom/
Signature · 1 line
2.47.1
Am 11. Juli 2026 22:34:53 UTC schrieb Alexander Graf <[email protected]>:
Quoted 11 lines
Motivation
----------
Markus observed [1] that a device reaching realize without a composition-tree parent is a modeling bug, and that the /machine/unattached container that catches such devices today is a bug attractor rather than a safety net: it hides the fact that nobody decided "what is part of what", and it gives the object an unstable, implementation-defined QOM path that is useless for qom-get/qom-set and for management tools that want to address board-created devices.
Quoted 6 lines
This series makes composition-tree parenting mandatory. After it,
device_set_realized()errors on a device with no parent,memory_region_do_init()asserts that a named region has an owner,qdev_connect_gpio_out_named()asserts that the pin being wired has a parent, and /machine/unattached is deleted. Every board-created object has a stable, human-chosen path.
Hi Alex,
Thanks for the cleanup! I hope the series will eventually find its way into the codebase.
Quoted 10 lines
[1] https://lore.kernel.org/qemu-devel/[email protected]/
Approach
--------
Rather than add a parallel "parented" API and migrate callers over years, each creation helper is converted in a singlerename->reintroduce
pair: a tree-wide Coccinelle rename offoo()tofoo_orphan(), followed immediately by a patch that reintroducesfoo()with a leading (Object *parent, const char *id, ...) signature.
Perhaps I'd have appended the two parameters at the end. This way, the most interesting parameters, especially the type, stand out most, helping me mentally "parse" the code more easily. But maybe this is just me, so this comment shall be no blocker.
Quoted 74 lines
The tree builds after
every patch and never carries two spellings of the same helper.The bulk of the series then converts
*_orphan()call sites to the parented form, one hw/ subdirectory per patch. Most of those commits carry a per-callsite table in the commit message giving the chosen parent expression, the chosen child name, and the one-line reason ("board init -> machine", "realize of X -> X", ...); the smaller ones carry a prose summary of the same. Those tables are the substance the RFC is asking maintainers to review: the mechanical part is trivial, the modeling decisions are not.Some hw/arm commit messages carry wide per-callsite tables that exceed 76 columns; please view with a fixed-width, non-wrapping mail reader.
Once no
*_orphan()callers remain the_orphanvariants are deleted, the enforcement checks are armed, and /machine/unattached is removed.Series shape
------------
001-009 core API:object_new_child();rename->reintroduceforqdev_new, sysbus_create_*, pci_new*, isa_new*, i2c_slave_*, ssi/usb/sd/adb/virtio/hda/aux/spapr-vio, cpu_create 010-082 hw/*: convert *_orphan() call sites to the parented form, one subdirectory per patch, each with a per-callsite reasoning table (or prose summary) in the commit message 083-088 delete the qdev/sysbus/pci/isa/i2c/ssi/usb/cpu *_orphan() creator variants 089-107 memory: give the remaining owner==NULL memory regions an owner, then assert on owner==NULL for named regions108-116 irq:
rename->reintroduceqemu_allocate_irq*() with an
owner and name; convert callers; delete_orphanvariants
117-130 parent the remaining non-device singletons and per-device
helper objects (main-system-bus, accel, reset container, per-MR helpers, per-devfn IOMMU objects, board-created CPUs, ...)
131-132 arm the enforcement checks and delete /machine/unattached
133-134docs/devel/qom.rst: parenting contract;MAINTAINERSThe Coccinelle scripts used for the rename steps are included under
scripts/coccinelle/qom-parent/and referenced from the corresponding commit messages.Not converted in this series
----------------------------
A handful of long-lived objects are deliberately left path-less for now, each for a specific lifecycle reason called out in the relevant commit message:*
TYPE_MIGRATIONis aTYPE_DEVICEthat is never realized, per the upstream comment "TODO make thisTYPE_OBJECTonce QOM provides -global for objects". Parenting it under /machine trips theqdev_assert_realized_properly()walk. It can move under /machine once it becomes a plainTYPE_OBJECT.
* RamDiscardManager is unref'd frommemory_region_finalize()itself, so making it a child<> of the MR would use-after-free during MR teardown.
* TPM backends and VFIO IOMMU containers are user-configurable and dynamically created; they belong under /objects/<id> or a dedicated /machine/vfio container respectively, and are best handled in a follow-up on top of this series.
* QIOChannel* and per-mapping virtio-shmem objects remain path-less by design (transient, refcounted, no stable identity).Verification
------------
* The tree builds for 20 softmmu targets after every patch.
* Every machine type across those targets was smoke-tested with "-M <machine> -S"; none abort on the new assertions.
* "info qom-tree" on q35 and on aarch64 virt shows no /machine/unattached node after the final patch.
* grep -r 'machine_get_container("unattached")' returns no hits.
Quoted 1 line
AI-assistance disclosure (
docs/devel/code-provenance.rst)
This series seems to affect migration. For example, it gives the "ocram" memory region in various imx devices a parent which has been identified as migration breaking before [1]. Migration isn't an issue for imx devices, so no objection there.
How shall we deal with machines where we do care about migration compatibility? Or was migration always broken there due to unstable QOM paths, and so far we were just lucky?
Best regards,
Bernhard
Quoted 609 lines
----------------------------------------------------------
Every patch in this series was produced with AI assistance and reviewed by the human submitter. Each commit carries anAssisted-by Kirotrailer following the format documented in the Linux kernel's
Documentation/process/coding-assistants.rst. The tree-wide rename patches are Coccinelle-equivalent mechanical transforms; the per-callsite parent/name choices in the hw/* commits are the AI-assisted modeling decisions this RFC is asking maintainers to review.QEMU's current policy in
docs/devel/code-provenance.rstis to decline AI-generated contributions absent an explicit exception. This RFC is therefore posted to open that discussion: I am requesting an exception for this series (or, if the community prefers, will reauthor the parts the policy requires) and will not post a non-RFC v1 until that is resolved on qemu-devel. The Signed-off-by DCO certification is mine as the human reviewer taking full responsibility for the contribution.Alexander Graf (134):
qom: Introduceobject_new_child()
qdev: Rename qdev_new()/qdev_try_new() to*_orphan()
qdev: Reintroduceqdev_new()with a mandatory QOM parent
sysbus: Make sysbus_create_simple()/_varargs() take a QOM parent
pci: Make pci_new*()/pci_create_simple*() take a QOM parent
isa: Make isa_new()/isa_try_new()/isa_create_simple() take a QOM
parent
i2c: Make i2c_slave_new()/i2c_slave_create_simple() take a QOM parent ssi, usb: Make bus-layer creators take a QOM parent
cpu: Makecpu_create()take a QOM parent
hw/avr: Give onboard devices a QOM parent
hw/tricore: Give onboard devices a QOM parent
hw/xtensa: Give onboard devices a QOM parent
hw/alpha: Give onboard devices a QOM parent
hw/nitro: Give onboard devices a QOM parent
hw/vmapple: Give onboard devices a QOM parent
hw/hppa: Give onboard devices a QOM parent
hw/microblaze: Give onboard devices a QOM parent
hw/sh4: Give onboard devices a QOM parent
hw/s390x: Give onboard devices a QOM parent
hw/or1k: Give onboard devices a QOM parent
hw/loongarch: Give onboard devices a QOM parent
hw/intc: Give onboard devices a QOM parent
hw/pci-host: Give onboard devices a QOM parent
hw/core: Give onboard devices a QOM parent
hw/remote: Give onboard devices a QOM parent
hw/ufs: Give onboard devices a QOM parent
hw/nvme: Give onboard devices a QOM parent
hw/vfio: Give onboard devices a QOM parent
hw/mem: Give onboard devices a QOM parent
hw/cxl: Give onboard devices a QOM parent
hw/hexagon: Give onboard devices a QOM parent
hw/xen: Give onboard devices a QOM parent
hw/display: Give onboard devices a QOM parent
hw/nvram: Give onboard devices a QOM parent
hw/dma: Give onboard devices a QOM parent
hw/misc: Give onboard devices a QOM parent
hw/scsi: Give onboard devices a QOM parent
hw/net: Give onboard devices a QOM parent
hw/ide: Give onboard devices a QOM parent
hw/i3c: Give onboard devices a QOM parent
hw/pci-bridge: Give onboard devices a QOM parent hw/sparc64: Give onboard devices a QOM parent
hw/sparc: Give onboard devices a QOM parent
hw/m68k: Give onboard devices a QOM parent
hw/rtc: Give onboard devices a QOM parent
hw/i2c: Give onboard devices a QOM parent
hw/block: Give onboard devices a QOM parent
hw/char: Give onboard devices a QOM parent
hw/isa: Give onboard devices a QOM parent
hw/pci: Give onboard devices a QOM parent
hw/riscv: Give onboard devices a QOM parent
hw/mips: Give onboard devices a QOM parent
hw/i386: Give onboard devices a QOM parent
hw/ppc: Give onboard devices a QOM parent
hw/pci, hw/isa: Give VGA and slot-NIC helpers a QOM parent hw/arm/virt: Give onboard devices a QOM parent hw/arm/sbsa-ref: Give onboard devices a QOM parent hw/arm/xilinx-zynq: Give onboard devices a QOM parent hw/arm/xlnx-versal, xlnx-zynqmp: Give onboard devices a QOM parent hw/arm/realview, integratorcp: Give onboard devices a QOM parent hw/arm/npcm: Give onboard devices a QOM parent hw/arm/versatile, vexpress: Give onboard devices a QOM parent hw/arm/stellaris, musicpal: Give onboard devices a QOM parent hw/arm/exynos: Give onboard devices a QOM parent hw/arm/allwinner: Give onboard devices a QOM parent hw/arm/strongarm: Give onboard devices a QOM parent hw/arm/omap: Give onboard devices a QOM parent
hw/arm/mps2: Give onboard devices a QOM parent
hw/arm/imx: Give onboard devices a QOM parent
hw/arm/misc: Give onboard devices a QOM parent hw/arm/aspeed: Give onboard devices a QOM parent (part 1) hw/arm/aspeed: Give onboard devices a QOM parent (part 2) hw/nvram/at24c: Giveat24c_eeprom_init()a QOM parent hw/i386/pc: Give pcspk a QOM parent
hw/timer, hw/net: Give i8254 and isa-ne2000 helpers a QOM parent hw/misc/unimp: Givecreate_unimplemented_device()a QOM parent hw/usb: Give -usbdevice and auto-hub devices a QOM parent hw/audio: Give -audio model= devices a QOM parent
hw/xen: Give xenstore-driven backend devices a QOM parent hw/nitro: Give the vsock bridge a QOM parent
hw/isa: Give the isabus-bridge a QOM parent
net, target/mips: Give -nic and CPU-with-clock helpers a QOM parent usb, ssi, i2c: Remove*_orphan()creator variants
isa: Remove*_orphan()creator variants
pci: Remove*_orphan()creator variants
cpu: Removecpu_create_orphan()
sysbus: Remove*_orphan()creator variants
qdev: Removeqdev_new_orphan()andqdev_try_new_orphan()
memory: Accept non-device owners inmemory_region_init_ram()hw/misc-boards: Give memory regions an explicit owner hw/mips: Give memory regions an explicit owner
hw/riscv: Give memory regions an explicit owner
hw/i386: Give memory regions an explicit owner
hw/arm: Give memory regions an explicit owner
hw/arm/omap1: Give memory regions an explicit owner
hw/sh4: Give memory regions an explicit owner
hw/m68k: Give memory regions an explicit owner
hw/ppc: Give memory regions an explicit owner
hw/tricore: Give memory regions an explicit owner hw/xtensa: Give memory regions an explicit owner hw/display: Give memory regions an explicit owner hw/arm/omap: Give lcdc and dma memory regions an explicit owner hw/char: Give parallel and htif memory regions an explicit owner hw/remote: Give memory regions an explicit owner
system, backends: Give named memory regions an explicit owner hw/ide: Letide_init_ioport()take an explicit owner
memory: Require an owner for named memory regions
irq: Rename qemu_allocate_irq*() and friends to*_orphan()
irq: Reintroduce qemu_allocate_irq*() with a mandatory owner and name hw/pci, hw/usb, system: Give allocated IRQs an owner and name hw/i386, hw/xen: Give allocated IRQs an owner and name hw/arm: Give allocated IRQs an owner and name
hw/xtensa: Give allocated IRQs an owner and name
hw: Give allocated IRQs an owner and name
hw/core: Parent GPIO input IRQs and embedded IRQState via QOM
irq: Delete the*_orphan()IRQ allocation variants
sysbus: Parent main-system-bus directly under /machine
accel: Parent the accelerator singleton under /machine hw/core/reset: Give the root reset container and legacy shims a QOM
path
system: Parent per-MR helper objects under their owner hw/virtio, hw/display: Parent per-device helper objects hw/i386/amd_iommu: Parent internally-created AMDVI-PCI under the IOMMU hw/s390x, hw/remote: Parent per-devfn IOMMU objects hw/pci-host/raven: Parent the OR-IRQ under the host bridge hw/arm/mps2: Parent the OR-IRQ gates under the machine hw/arm/digic: Parent the DIGIC SoC under the machine hw/microblaze: Parent the CPU under the machine
hw: Pairobject_initialize_child()with plainrealize()
hw: Parent board-created CPUs under the machine hw/pci-host/versatile: Useobject_initialize_child()forpci_devdocs, qapi, scripts, iotests: Update /machine/unattached path
references
qom: Delete /machine/unattached and error on unparented realize docs/devel/qom: Document the composition-tree parenting contract
MAINTAINERS: Addscripts/coccinelle/qom-parent/under QOMMAINTAINERS | 1 + accel/accel-system.c | 4 +- backends/igvm.c | 6 +- bsd-user/main.c | 3 +- docs/devel/qom.rst | 96 +++++++ docs/devel/s390-cpu-topology.rst | 2 +- docs/system/cpu-hotplug.rst | 4 +- hw/alpha/alpha_sys.h | 3 +- hw/alpha/dp264.c | 16 +- hw/alpha/typhoon.c | 10 +- hw/arm/allwinner-a10.c | 4 +- hw/arm/allwinner-h3.c | 34 ++- hw/arm/allwinner-r40.c | 4 +- hw/arm/armsse.c | 13 +- hw/arm/aspeed.c | 39 +-- hw/arm/aspeed_ast1040_evb.c | 6 +- hw/arm/aspeed_ast10x0_evb.c | 12 +- hw/arm/aspeed_ast2400_palmetto.c | 8 +- hw/arm/aspeed_ast2400_quanta-q71l.c | 18 +- hw/arm/aspeed_ast2400_supermicrox11.c | 8 +- hw/arm/aspeed_ast2500_evb.c | 7 +- hw/arm/aspeed_ast2500_g220a.c | 11 +- hw/arm/aspeed_ast2500_romulus.c | 3 +- hw/arm/aspeed_ast2500_supermicro-x11spi.c | 8 +- hw/arm/aspeed_ast2500_tiogapass.c | 13 +- hw/arm/aspeed_ast2500_witherspoon.c | 34 +-- hw/arm/aspeed_ast2500_yosemitev2.c | 13 +- hw/arm/aspeed_ast2600_anacapa.c | 51 ++-- hw/arm/aspeed_ast2600_bletchley.c | 33 ++- hw/arm/aspeed_ast2600_catalina.c | 99 +++---- hw/arm/aspeed_ast2600_evb.c | 7 +- hw/arm/aspeed_ast2600_fby35.c | 20 +- hw/arm/aspeed_ast2600_fuji.c | 111 ++++---- hw/arm/aspeed_ast2600_gb200nvl.c | 24 +- hw/arm/aspeed_ast2600_rainier.c | 188 ++++++++------ hw/arm/aspeed_ast27x0-fc.c | 9 +- hw/arm/aspeed_ast27x0_evb.c | 3 +- hw/arm/aspeed_soc_common.c | 14 +- hw/arm/bananapi_m2u.c | 6 +- hw/arm/collie.c | 6 +- hw/arm/cubieboard.c | 6 +- hw/arm/digic_boards.c | 5 +- hw/arm/exynos4210.c | 70 ++--- hw/arm/exynos4_boards.c | 15 +- hw/arm/fsl-imx25.c | 2 +- hw/arm/fsl-imx31.c | 2 +- hw/arm/fsl-imx6.c | 7 +- hw/arm/fsl-imx6ul.c | 37 +-- hw/arm/fsl-imx7.c | 41 +-- hw/arm/fsl-imx8mm.c | 2 +- hw/arm/fsl-imx8mp.c | 2 +- hw/arm/imx25_pdk.c | 6 +- hw/arm/imx8mm-evk.c | 6 +- hw/arm/imx8mp-evk.c | 6 +- hw/arm/integratorcp.c | 56 ++-- hw/arm/kzm.c | 6 +- hw/arm/max78000_soc.c | 107 ++++---- hw/arm/max78000fthr.c | 5 +- hw/arm/mcimx6ul-evk.c | 4 +- hw/arm/mcimx7d-sabre.c | 4 +- hw/arm/mps2-tz.c | 27 +- hw/arm/mps2.c | 91 ++++--- hw/arm/mps3r.c | 20 +- hw/arm/msf2-soc.c | 24 +- hw/arm/msf2-som.c | 12 +- hw/arm/musca.c | 4 +- hw/arm/musicpal.c | 50 ++-- hw/arm/netduino2.c | 5 +- hw/arm/netduinoplus2.c | 5 +- hw/arm/npcm7xx.c | 95 +++---- hw/arm/npcm7xx_boards.c | 117 +++++---- hw/arm/npcm8xx.c | 147 +++++------ hw/arm/npcm8xx_boards.c | 19 +- hw/arm/nrf51_soc.c | 4 +- hw/arm/olimex-stm32-h405.c | 5 +- hw/arm/omap1.c | 244 ++++++++++-------- hw/arm/omap_sx1.c | 20 +- hw/arm/orangepi.c | 4 +- hw/arm/raspi.c | 4 +- hw/arm/realview.c | 113 ++++---- hw/arm/sabrelite.c | 5 +- hw/arm/sbsa-ref.c | 76 +++--- hw/arm/stellaris.c | 99 ++++--- hw/arm/stm32f100_soc.c | 62 ++--- hw/arm/stm32f205_soc.c | 2 +- hw/arm/stm32f405_soc.c | 88 +++---- hw/arm/stm32l4x5_soc.c | 88 +++---- hw/arm/stm32vldiscovery.c | 5 +- hw/arm/strongarm.c | 27 +- hw/arm/strongarm.h | 2 +- hw/arm/versatilepb.c | 85 +++--- hw/arm/vexpress.c | 87 ++++--- hw/arm/virt.c | 97 +++---- hw/arm/xilinx_zynq.c | 160 ++++++------ hw/arm/xlnx-versal-virt.c | 5 +- hw/arm/xlnx-versal.c | 197 ++++++-------- hw/arm/xlnx-zcu102.c | 14 +- hw/arm/xlnx-zynqmp.c | 8 +- hw/audio/intel-hda.c | 4 +- hw/audio/model.c | 5 +- hw/avr/atmega.c | 24 +- hw/block/fdc-sysbus.c | 13 +- hw/block/fdc.c | 4 +- hw/block/pflash_cfi01.c | 6 +- hw/block/pflash_cfi02.c | 6 +- hw/block/xen-block.c | 5 +- hw/char/diva-gsp.c | 3 +- hw/char/exynos4210_uart.c | 6 +- hw/char/mcf_uart.c | 11 +- hw/char/mchp_pfsoc_mmuart.c | 4 +- hw/char/omap_uart.c | 4 +- hw/char/parallel-isa.c | 10 +- hw/char/parallel.c | 5 +- hw/char/pl011.c | 6 +- hw/char/riscv_htif.c | 5 +- hw/char/serial-isa.c | 11 +- hw/char/serial-mm.c | 6 +- hw/char/sifive_uart.c | 8 +- hw/char/spapr_vty.c | 6 +- hw/char/xen_console.c | 7 +- hw/core/cpu-common.c | 6 +- hw/core/gpio.c | 24 +- hw/core/irq.c | 38 +-- hw/core/null-machine.c | 2 +- hw/core/qdev-user.c | 6 +- hw/core/qdev.c | 39 ++- hw/core/reset.c | 13 +- hw/core/sysbus.c | 22 +- hw/cxl/cxl-host.c | 9 +- hw/display/cg3.c | 2 +- hw/display/g364fb.c | 2 +- hw/display/macfb.c | 2 +- hw/display/omap_lcdc.c | 5 +- hw/display/sii9022.c | 2 +- hw/display/sm501.c | 6 +- hw/display/vhost-user-gpu.c | 12 +- hw/display/virtio-gpu-gl.c | 2 +- hw/display/vmware_vga.c | 2 +- hw/display/xlnx_dp.c | 14 +- hw/dma/i8257.c | 10 +- hw/dma/omap_dma.c | 9 +- hw/dma/rc4030.c | 7 +- hw/hexagon/hexagon_dsp.c | 21 +- hw/hexagon/virt.c | 29 +-- hw/hppa/machine.c | 96 ++++--- hw/i2c/aspeed_i2c.c | 4 +- hw/i2c/core.c | 22 +- hw/i2c/smbus_eeprom.c | 11 +- hw/i386/amd_iommu.c | 3 +- hw/i386/isapc.c | 17 +- hw/i386/kvm/clock.c | 4 +- hw/i386/kvm/clock.h | 2 +- hw/i386/kvm/i8259.c | 8 +- hw/i386/kvm/xen-stubs.c | 2 +- hw/i386/kvm/xen_evtchn.c | 6 +- hw/i386/kvm/xen_evtchn.h | 3 +- hw/i386/kvm/xen_gnttab.c | 6 +- hw/i386/kvm/xen_gnttab.h | 2 +- hw/i386/kvm/xen_overlay.c | 6 +- hw/i386/kvm/xen_overlay.h | 2 +- hw/i386/kvm/xen_primary_console.c | 5 +- hw/i386/kvm/xen_primary_console.h | 2 +- hw/i386/kvm/xen_xenstore.c | 5 +- hw/i386/kvm/xen_xenstore.h | 2 +- hw/i386/microvm.c | 34 +-- hw/i386/nitro_enclave.c | 9 +- hw/i386/pc.c | 96 +++---- hw/i386/pc_piix.c | 28 +- hw/i386/pc_q35.c | 42 +-- hw/i386/pc_sysfw.c | 16 +- hw/i386/sgx.c | 5 +- hw/i386/x86-common.c | 33 ++- hw/i386/x86-cpu.c | 4 +- hw/i386/xen/xen-hvm.c | 12 +- hw/i386/xen/xen-pvh.c | 5 +- hw/i386/xen/xen_pvdevice.c | 2 +- hw/i3c/core.c | 19 +- hw/ide/ahci.c | 2 +- hw/ide/ide-bus.c | 5 +- hw/ide/ide-internal.h | 2 +- hw/ide/ioport.c | 37 ++- hw/ide/isa.c | 9 +- hw/ide/pci.c | 2 +- hw/ide/piix.c | 2 +- hw/intc/apic_common.c | 3 +- hw/intc/exynos4210_gic.c | 4 +- hw/intc/i8259.c | 6 +- hw/intc/i8259_common.c | 7 +- hw/intc/riscv_aclint.c | 16 +- hw/intc/riscv_aplic.c | 13 +- hw/intc/riscv_imsic.c | 7 +- hw/intc/s390_flic.c | 12 +- hw/intc/sh_intc.c | 21 +- hw/intc/sifive_plic.c | 7 +- hw/ipack/ipack.c | 11 +- hw/ipmi/ipmi_bt.c | 2 +- hw/ipmi/ipmi_kcs.c | 2 +- hw/isa/i82378.c | 13 +- hw/isa/isa-bus.c | 44 ++-- hw/isa/isa-superio.c | 25 +- hw/isa/lpc_ich9.c | 2 +- hw/isa/piix.c | 4 +- hw/isa/vt82c686.c | 7 +- hw/loongarch/virt.c | 56 ++-- hw/m68k/an5206.c | 13 +- hw/m68k/mcf5206.c | 8 +- hw/m68k/mcf5208.c | 32 ++- hw/m68k/mcf_intc.c | 7 +- hw/m68k/next-cube.c | 26 +- hw/m68k/q800.c | 28 +- hw/m68k/virt.c | 25 +- hw/mem/sparse-mem.c | 6 +- hw/microblaze/petalogix_ml605_mmu.c | 40 ++- hw/microblaze/petalogix_s3adsp1800_mmu.c | 27 +- hw/microblaze/xlnx-zynqmp-pmu.c | 4 +- hw/mips/boston.c | 32 +-- hw/mips/cps.c | 5 +- hw/mips/fuloong2e.c | 24 +- hw/mips/jazz.c | 73 +++--- hw/mips/loongson3_virt.c | 40 +-- hw/mips/malta.c | 49 ++-- hw/mips/mips_int.c | 2 +- hw/misc/empty_slot.c | 7 +- hw/misc/led.c | 15 +- hw/misc/macio/macio.c | 2 +- hw/misc/sifive_e_prci.c | 6 +- hw/misc/sifive_test.c | 6 +- hw/net/can/can_kvaser_pci.c | 2 +- hw/net/imx_fec.c | 4 +- hw/net/lan9118.c | 10 +- hw/net/smc91c111.c | 6 +- hw/net/spapr_llan.c | 6 +- hw/net/xen_nic.c | 5 +- hw/nitro/machine.c | 11 +- hw/nitro/nitro-vsock-bus.c | 9 +- hw/nubus/nubus-virtio-mmio.c | 2 +- hw/nvme/ctrl.c | 2 +- hw/nvram/eeprom_at24c.c | 12 +- hw/nvram/fw_cfg.c | 16 +- hw/or1k/or1k-sim.c | 25 +- hw/or1k/virt.c | 43 +-- hw/pci-bridge/pci_expander_bridge.c | 13 +- hw/pci-host/articia.c | 6 +- hw/pci-host/astro.c | 8 +- hw/pci-host/bonito.c | 28 +- hw/pci-host/grackle.c | 2 +- hw/pci-host/gt64120.c | 5 +- hw/pci-host/i440fx.c | 2 +- hw/pci-host/mv64361.c | 4 +- hw/pci-host/pnv_phb.c | 5 +- hw/pci-host/pnv_phb3.c | 3 +- hw/pci-host/pnv_phb3_msi.c | 3 +- hw/pci-host/pnv_phb4.c | 3 +- hw/pci-host/pnv_phb4_pec.c | 3 +- hw/pci-host/ppc4xx_pci.c | 2 +- hw/pci-host/ppce500.c | 2 +- hw/pci-host/raven.c | 6 +- hw/pci-host/sabre.c | 12 +- hw/pci-host/sh_pci.c | 3 +- hw/pci-host/uninorth.c | 11 +- hw/pci-host/versatile.c | 3 +- hw/pci/pci.c | 60 +++-- hw/pci/pcie_sriov.c | 3 +- hw/ppc/amigaone.c | 24 +- hw/ppc/e500.c | 70 ++--- hw/ppc/mac_newworld.c | 58 +++-- hw/ppc/mac_oldworld.c | 32 +-- hw/ppc/pegasos.c | 22 +- hw/ppc/pnv.c | 33 +-- hw/ppc/pnv_bmc.c | 4 +- hw/ppc/pnv_lpc.c | 6 +- hw/ppc/pnv_psi.c | 6 +- hw/ppc/ppc440.h | 2 +- hw/ppc/ppc440_bamboo.c | 17 +- hw/ppc/ppc440_uc.c | 10 +- hw/ppc/ppc4xx_sdram.c | 34 +-- hw/ppc/prep.c | 50 ++-- hw/ppc/sam460ex.c | 72 +++--- hw/ppc/spapr.c | 37 +-- hw/ppc/spapr_irq.c | 6 +- hw/ppc/spapr_vio.c | 6 +- hw/ppc/virtex_ml507.c | 23 +- hw/remote/iommu.c | 5 +- hw/remote/machine.c | 6 +- hw/remote/memory.c | 3 +- hw/remote/vfio-user-obj.c | 2 +- hw/riscv/aia.c | 12 +- hw/riscv/aia.h | 3 +- hw/riscv/boston-aia.c | 31 ++- hw/riscv/cps.c | 14 +- hw/riscv/k230.c | 127 ++++----- hw/riscv/microblaze-v-generic.c | 51 ++-- hw/riscv/microchip_pfsoc.c | 90 +++---- hw/riscv/opentitan.c | 52 ++-- hw/riscv/shakti_c.c | 8 +- hw/riscv/sifive_e.c | 25 +- hw/riscv/sifive_u.c | 39 +-- hw/riscv/spike.c | 8 +- hw/riscv/tt_atlantis.c | 17 +- hw/riscv/virt.c | 57 ++-- hw/riscv/xiangshan_kmh.c | 20 +- hw/rtc/ls7a_rtc.c | 2 +- hw/rtc/mc146818rtc.c | 6 +- hw/rtc/sun4v-rtc.c | 6 +- hw/s390x/ap-bridge.c | 6 +- hw/s390x/css-bridge.c | 7 +- hw/s390x/s390-pci-bus.c | 12 +- hw/s390x/s390-virtio-ccw.c | 41 ++- hw/scsi/esp-pci.c | 2 +- hw/scsi/lasi_ncr710.c | 8 +- hw/scsi/lasi_ncr710.h | 4 +- hw/scsi/ncr53c710.c | 15 +- hw/scsi/ncr53c710.h | 7 +- hw/scsi/scsi-bus.c | 5 +- hw/scsi/spapr_vscsi.c | 6 +- hw/sh4/r2d.c | 38 +-- hw/sh4/sh7750.c | 35 +-- hw/sparc/leon3.c | 27 +- hw/sparc/sun4m.c | 167 ++++++------ hw/sparc64/niagara.c | 20 +- hw/sparc64/sparc64.c | 3 +- hw/sparc64/sun4u.c | 69 ++--- hw/ssi/ssi.c | 7 +- hw/timer/arm_timer.c | 6 +- hw/timer/sh_timer.c | 9 +- hw/tricore/tc27x_soc.c | 77 +++--- hw/tricore/tricore_testboard.c | 19 +- hw/ufs/lu.c | 5 +- hw/usb/bus.c | 15 +- hw/usb/dev-serial.c | 3 +- hw/usb/vt82c686-uhci-pci.c | 4 +- hw/vfio/igd.c | 5 +- hw/virtio/virtio-mem.c | 5 +- hw/vmapple/vmapple.c | 66 ++--- hw/xen/xen-bus.c | 5 +- hw/xen/xen-legacy-backend.c | 5 +- hw/xen/xen-pvh-common.c | 26 +- hw/xen/xen_pt_graphics.c | 3 +- hw/xtensa/mx_pic.c | 8 +- hw/xtensa/pic_cpu.c | 5 +- hw/xtensa/sim.c | 15 +- hw/xtensa/virt.c | 4 +- hw/xtensa/xtensa_memory.c | 5 +- hw/xtensa/xtensa_memory.h | 3 +- hw/xtensa/xtfpga.c | 51 ++-- include/hw/arm/aspeed.h | 6 +- include/hw/arm/aspeed_soc.h | 3 +- include/hw/arm/exynos4210.h | 2 +- include/hw/arm/omap.h | 11 +- include/hw/block/fdc.h | 5 +- include/hw/block/flash.h | 4 +- include/hw/char/mchp_pfsoc_mmuart.h | 2 +- include/hw/char/parallel.h | 5 +- include/hw/char/pl011.h | 2 +- include/hw/char/riscv_htif.h | 3 +- include/hw/char/serial-isa.h | 2 +- include/hw/char/serial-mm.h | 2 +- include/hw/char/sifive_uart.h | 4 +- include/hw/core/cpu.h | 11 +- include/hw/core/irq.h | 27 +- include/hw/core/qdev.h | 50 ++-- include/hw/core/sysbus.h | 29 ++- include/hw/i2c/i2c.h | 29 ++- include/hw/i2c/smbus_eeprom.h | 5 +- include/hw/i386/pc.h | 6 +- include/hw/i386/vmport.h | 5 - include/hw/i386/x86.h | 7 +- include/hw/i3c/i3c.h | 9 +- include/hw/ide/isa.h | 3 +- include/hw/intc/i8259.h | 4 +- include/hw/intc/riscv_aclint.h | 6 +- include/hw/intc/riscv_aplic.h | 5 +- include/hw/intc/riscv_imsic.h | 3 +- include/hw/intc/sifive_plic.h | 3 +- include/hw/isa/i8259_internal.h | 3 +- include/hw/isa/isa.h | 11 +- include/hw/m68k/mcf.h | 7 +- include/hw/mem/sparse-mem.h | 2 +- include/hw/mips/mips.h | 5 +- include/hw/misc/empty_slot.h | 3 +- include/hw/misc/sifive_e_prci.h | 2 +- include/hw/misc/sifive_test.h | 2 +- include/hw/misc/unimp.h | 9 +- include/hw/net/lan9118.h | 2 +- include/hw/net/ne2000-isa.h | 8 +- include/hw/net/smc91c111.h | 2 +- include/hw/nitro/nitro-vsock-bus.h | 2 +- include/hw/nvram/eeprom_at24c.h | 6 +- include/hw/pci/pci.h | 19 +- include/hw/ppc/pnv.h | 2 +- include/hw/ppc/spapr_vio.h | 8 +- include/hw/rtc/mc146818rtc.h | 2 +- include/hw/rtc/sun4v-rtc.h | 2 +- include/hw/sh4/sh.h | 3 +- include/hw/sh4/sh_intc.h | 3 +- include/hw/ssi/ssi.h | 3 +- include/hw/timer/i8254.h | 13 +- include/hw/timer/tmu012.h | 3 +- include/hw/usb/usb.h | 13 +- include/hw/xen/xen.h | 2 +- include/hw/xtensa/mx_pic.h | 4 +- include/net/net.h | 5 +- include/qom/object.h | 25 ++ linux-user/main.c | 6 +- net/net.c | 10 +- qapi/block-core.json | 12 +- qapi/block.json | 2 +- qapi/machine.json | 12 +- qapi/qom.json | 4 +- qom/object.c | 13 + scripts/arm_processor_error.py | 3 +- .../qom-parent/cpu-create-orphan.cocci | 13 + .../qom-parent/i2c-slave-new-orphan.cocci | 18 ++ .../coccinelle/qom-parent/irq-rename.cocci | 14 + .../qom-parent/isa-new-orphan.cocci | 23 ++ .../qom-parent/pci-new-orphan.cocci | 28 ++ .../qom-parent/qdev-new-orphan.cocci | 18 ++ .../qom-parent/ssi-usb-orphan.cocci | 18 ++ .../qom-parent/sysbus-create-orphan.cocci | 18 ++ scripts/qmp_helper.py | 2 +- stubs/xen-hw-stub.c | 2 +- system/ioport.c | 12 +- system/memory.c | 23 +- system/physmem.c | 4 +- system/qdev-monitor.c | 2 +- system/qtest.c | 2 +- system/ram-block-attributes.c | 7 +- system/vl.c | 3 +- target/mips/cpu.c | 5 +- target/mips/cpu.h | 3 +- target/xtensa/cpu.c | 11 - target/xtensa/cpu.h | 2 - tests/qemu-iotests/172.out | 72 +++--- tests/qemu-iotests/186.out | 10 +- tests/qemu-iotests/common.filter | 2 +- tests/qtest/fuzz/generic_fuzz.c | 2 +- tests/unit/test-qdev-global-props.c | 17 +- tests/unit/test-qdev.c | 12 +- 438 files changed, 4515 insertions(+), 3784 deletions(-)create mode 100644
scripts/coccinelle/qom-parent/cpu-create-orphan.coccicreate mode 100644scripts/coccinelle/qom-parent/i2c-slave-new-orphan.coccicreate mode 100644scripts/coccinelle/qom-parent/irq-rename.coccicreate mode 100644scripts/coccinelle/qom-parent/isa-new-orphan.coccicreate mode 100644scripts/coccinelle/qom-parent/pci-new-orphan.coccicreate mode 100644scripts/coccinelle/qom-parent/qdev-new-orphan.coccicreate mode 100644scripts/coccinelle/qom-parent/ssi-usb-orphan.coccicreate mode 100644scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci
v2 cover qom: Make composition-tree parenting mandatory
In reply to Alexander GrafEvery board-created device, memory region and IRQ in QEMU that isn't explicitly parented today ends up in /machine/unattached with an unstable device[N] name. This series makes composition-tree parenting mandatory: it introduces object_new_child() and per-bus qdev_new()/pci_new()/... variants that take a QOM parent + child<> name, converts every board and device that used the old API, gives every named MemoryRegion and IRQ an explicit owner, and finally removes the /machine/unattached fallback so device_set_realized() errors when a device has no QOM parent.
This is v2 of the RFC posted at [1].
RAMBlock idstrs and migration compatibility
--------------------------------------------
Bernhard and Thomas raised the concern that giving a MemoryRegion an owner changes its RAMBlock idstr and thus breaks cross-version migration on versioned machine types. Tracing the derivation:
idstr = [qdev_get_dev_path(dev) "/"] mr->name
where dev = object_dynamic_cast(owner, TYPE_DEVICE) (patch 089 already made this dynamic). qdev_get_dev_path() returns non-NULL only when the device's parent bus class implements .get_dev_path -- SysBus does not; PCI and several other bus classes (spapr-vio, virtual-css, USB, virtio, NuBus, VMBus, ...) do. So converting owner from NULL to a Machine or a SysBus device leaves the idstr unchanged. Only NULL to a device on one of those bus classes changes it.
Auditing all 78 NULL->owner RAM/ROM conversions on versioned machines (pc-*, q35-*, virt-*, pseries-*, s390-ccw-virtio-*, q800), exactly one is affected: hw/display/vmware_vga.c "vmsvga.fifo", whose owner becomes a PCI device. Patch 101 now uses the _nomigrate variant plus an explicit vmstate_register_ram_global() there, so the QOM owner is the PCI device but the migration idstr stays the historical bare "vmsvga.fifo".
To answer Bernhard's follow-up question directly: QOM canonical paths themselves are not part of the migration stream. Only RAMBlock idstrs and vmstate instance_ids are, and neither derives from the QOM canonical path -- idstrs go through the bus-class .get_dev_path hook as above, and CPU/device instance_ids come from cpu_index or qdev_set_legacy_instance_id().
Verified with -dump-vmstate and 'info ramblock' diffs between v11.1.0-rc0 and this branch on pc-i440fx-11.0/9.0, pc-q35-11.0/9.0 (with and without -device vmware-svga), virt-11.0/9.0, pseries-11.0, s390-ccw-virtio-11.0 and q800: all identical.
Changes since RFC v1
--------------------
- Rebased onto v11.1.0-rc0 (eca2c16212).
- object_new_child() (patch 001): drop the runtime g_assert(parent) and g_assert(id), annotate the prototype with __attribute__((nonnull(1,2,3), returns_nonnull)) instead (Richard, Peter). Add g_assert(id[0] && !strchr(id, '/')) to reject empty names and the QOM path separator; the qdev id_wellformed() grammar does not apply here since QOM child<> names legitimately use "[*]" (Daniel, Peter).
- sysbus_create_simple()/_varargs() (patch 004): add a doc-comment note that new code should prefer qdev_new() + sysbus_realize() (Philippe).
- hw/display (patch 101): preserve the "vmsvga.fifo" RAMBlock idstr as described above (Bernhard, Thomas).
- Every hw/<arch> "Give memory regions an explicit owner" commit now states in its message that RAMBlock idstrs are unchanged and why.
- Collected 14 Reviewed-by and 1 Acked-by tags from v1. The four scoped tags (imx-only on 094, coldfire/next-cube-only on 097, hexagon-only and e500-only on 129) are carried with a "# scope" suffix rather than splitting the patches; the migration analysis above shows the remaining hunks in those patches are also safe.
On the argument order of object_new_child(parent, id, typename):
kept as-is for consistency with object_initialize_child() and object_property_add_child(), which both take (parent, name, ...) first (Bernhard).
Structure
---------
001-009 Core: object_new_child() and per-bus qdev/pci/isa/i2c/
ssi/usb/cpu creators taking (parent, id, ...)
010-082 hw/*: convert every board's *_orphan() call sites, one
subdirectory per commit with a per-callsite rationale table
083-088 Delete *_orphan() device-creator variants; make
memory_region_register_ram() dynamic-cast the owner
089-107 hw/*: give every named MemoryRegion an explicit owner;
assert !name || owner in memory_region_do_init()
108-116 IRQ: qemu_allocate_irq*() take (owner, name, ...); convert
callers; delete _orphan() variants
117-130 Non-device singletons (sysbus root, reset container,
accel, per-devfn IOMMUs, board-created CPUs, ...)
131-132 Update in-tree /machine/unattached consumers; delete the
/machine/unattached container and error on unparented realize
133-134 docs/devel/qom.rst; MAINTAINERS
Not converted in this series
----------------------------
TYPE_MIGRATION (a never-realized pseudo-DeviceState used only for -global), RamDiscardManager (unref'd from within MemoryRegion finalize), TPM backends and VFIO containers (both belong under /objects and have their own lifecycle). These are noted as follow-ups.
Testing
-------
Builds cleanly for 20 softmmu targets. Every machine of every target boots to -S under qtest with no aborts. qtest-*/qom-test, qtest-*/device-introspect-test and qtest-*/test-hmp pass on all 20 targets. info qom-tree on q35 and aarch64 virt shows no /machine/unattached. -dump-vmstate and info ramblock are identical to the base on all versioned machines listed above. checkpatch reports three pre-existing false positives.
AI assistance disclosure
------------------------
This series was developed with substantial AI assistance (Kiro, an Amazon-internal agent built on Anthropic Claude). Every patch carries an AI-used-for: tag per the convention proposed in [2]. That proposal is not yet merged; the in-tree policy still declines AI-assisted contributions, so I am posting this as an RFC under the "large-scale changes / get in touch beforehand" experiment path for design review only. Where possible the conversion is scripted (scripts/coccinelle/qom-parent/); the AI was used to drive the non-mechanical residue. I have reviewed and take DCO responsibility for every change.
[1] https://lore.kernel.org/qemu-devel/[email protected]/
[2] https://lore.kernel.org/qemu-devel/[email protected]/
Alexander Graf (137):
qom: Introduce object_new_child()
qdev: Rename qdev_new()/qdev_try_new() to *_orphan()
qdev: Reintroduce qdev_new() with a mandatory QOM parent
sysbus: Make sysbus_create_simple()/_varargs() take a QOM parent
pci: Make pci_new*()/pci_create_simple*() take a QOM parent
isa: Make isa_new()/isa_try_new()/isa_create_simple() take a QOM
parent
i2c: Make i2c_slave_new()/i2c_slave_create_simple() take a QOM parent ssi, usb: Make bus-layer creators take a QOM parent
cpu: Make cpu_create() take a QOM parent
hw/avr: Give onboard devices a QOM parent
hw/tricore: Give onboard devices a QOM parent
hw/xtensa: Give onboard devices a QOM parent
hw/alpha: Give onboard devices a QOM parent
hw/nitro: Give onboard devices a QOM parent
hw/vmapple: Give onboard devices a QOM parent
hw/hppa: Give onboard devices a QOM parent
hw/microblaze: Give onboard devices a QOM parent
hw/sh4: Give onboard devices a QOM parent
hw/s390x: Give onboard devices a QOM parent
hw/or1k: Give onboard devices a QOM parent
hw/loongarch: Give onboard devices a QOM parent
hw/intc: Give onboard devices a QOM parent
hw/pci-host: Give onboard devices a QOM parent
hw/core: Give onboard devices a QOM parent
hw/remote: Give onboard devices a QOM parent
hw/ufs: Give onboard devices a QOM parent
hw/nvme: Give onboard devices a QOM parent
hw/vfio: Give onboard devices a QOM parent
hw/mem: Give onboard devices a QOM parent
hw/cxl: Give onboard devices a QOM parent
hw/hexagon: Give onboard devices a QOM parent
hw/xen: Give onboard devices a QOM parent
hw/display: Give onboard devices a QOM parent
hw/nvram: Give onboard devices a QOM parent
hw/dma: Give onboard devices a QOM parent
hw/misc: Give onboard devices a QOM parent
hw/scsi: Give onboard devices a QOM parent
hw/net: Give onboard devices a QOM parent
hw/ide: Give onboard devices a QOM parent
hw/i3c: Give onboard devices a QOM parent
hw/core/sysbus: Skip nested devices in foreach_dynamic_sysbus_device() hw/pci-bridge: Give onboard devices a QOM parent hw/sparc64: Give onboard devices a QOM parent
hw/sparc: Give onboard devices a QOM parent
hw/m68k: Give onboard devices a QOM parent
hw/rtc: Give onboard devices a QOM parent
hw/i2c: Give onboard devices a QOM parent
hw/block: Give onboard devices a QOM parent
hw/char: Give onboard devices a QOM parent
hw/isa: Give onboard devices a QOM parent
hw/pci: Give onboard devices a QOM parent
hw/riscv: Give onboard devices a QOM parent
hw/mips: Give onboard devices a QOM parent
hw/i386: Give onboard devices a QOM parent
hw/ppc: Give onboard devices a QOM parent
hw/pci, hw/isa: Give VGA and slot-NIC helpers a QOM parent hw/arm/virt: Give onboard devices a QOM parent hw/arm/sbsa-ref: Give onboard devices a QOM parent hw/arm/xilinx-zynq: Give onboard devices a QOM parent hw/arm/xlnx-versal, xlnx-zynqmp: Give onboard devices a QOM parent hw/arm/realview, integratorcp: Give onboard devices a QOM parent hw/arm/npcm: Give onboard devices a QOM parent hw/arm/versatile, vexpress: Give onboard devices a QOM parent hw/arm/stellaris, musicpal: Give onboard devices a QOM parent hw/arm/exynos: Give onboard devices a QOM parent hw/arm/allwinner: Give onboard devices a QOM parent hw/arm/strongarm: Give onboard devices a QOM parent hw/arm/omap: Give onboard devices a QOM parent hw/arm/mps2: Give onboard devices a QOM parent
hw/arm/imx: Give onboard devices a QOM parent
hw/arm/misc: Give onboard devices a QOM parent hw/arm/aspeed: Give onboard devices a QOM parent (part 1) hw/arm/aspeed: Give onboard devices a QOM parent (part 2) hw/nvram/at24c: Give at24c_eeprom_init() a QOM parent hw/i386/pc: Give pcspk a QOM parent
hw/timer, hw/net: Give i8254 and isa-ne2000 helpers a QOM parent hw/misc/unimp: Give create_unimplemented_device() a QOM parent hw/usb: Give -usbdevice and auto-hub devices a QOM parent hw/audio: Give -audio model= devices a QOM parent
hw/xen: Give xenstore-driven backend devices a QOM parent hw/nitro: Give the vsock bridge a QOM parent
hw/isa: Give the isabus-bridge a QOM parent
net, target/mips: Give -nic and CPU-with-clock helpers a QOM parent usb, ssi, i2c: Remove *_orphan() creator variants
isa: Remove *_orphan() creator variants
pci: Remove *_orphan() creator variants
cpu: Remove cpu_create_orphan()
sysbus: Remove *_orphan() creator variants
qdev: Remove qdev_new_orphan() and qdev_try_new_orphan()
memory: Accept non-device owners in memory_region_init_ram() hw/misc-boards: Give memory regions an explicit owner hw/mips: Give memory regions an explicit owner
hw/riscv: Give memory regions an explicit owner
hw/i386: Give memory regions an explicit owner
hw/arm: Give memory regions an explicit owner hw/arm/omap1: Give memory regions an explicit owner hw/sh4: Give memory regions an explicit owner
hw/m68k: Give memory regions an explicit owner
hw/ppc: Give memory regions an explicit owner
hw/tricore: Give memory regions an explicit owner hw/xtensa: Give memory regions an explicit owner hw/display: Give memory regions an explicit owner hw/arm/omap: Give lcdc and dma memory regions an explicit owner hw/char: Give parallel and htif memory regions an explicit owner hw/remote: Give memory regions an explicit owner
system, backends: Give named memory regions an explicit owner hw/ide: Let ide_init_ioport() take an explicit owner
memory: Require an owner for named memory regions
irq: Rename qemu_allocate_irq*() and friends to *_orphan()
irq: Reintroduce qemu_allocate_irq*() with a mandatory owner and name hw/pci, hw/usb, system: Give allocated IRQs an owner and name hw/i386, hw/xen: Give allocated IRQs an owner and name hw/arm: Give allocated IRQs an owner and name
hw/xtensa: Give allocated IRQs an owner and name
hw: Give allocated IRQs an owner and name
hw/core: Parent GPIO input IRQs and embedded IRQState via QOM
irq: Delete the *_orphan() IRQ allocation variants
sysbus: Parent main-system-bus directly under /machine
accel: Parent the accelerator singleton under /machine hw/intc/mips_gic: Register reset handler at realize, not instance_init hw/core/reset: Give the root reset container and legacy shims a QOM
path
system: Parent per-MR helper objects under their owner hw/virtio, hw/display: Parent per-device helper objects hw/i386/amd_iommu: Parent internally-created AMDVI-PCI under the IOMMU hw/s390x, hw/remote: Parent per-devfn IOMMU objects hw/pci-host/raven: Parent the OR-IRQ under the host bridge hw/arm/mps2: Parent the OR-IRQ gates under the machine hw/arm/digic: Parent the DIGIC SoC under the machine hw/microblaze: Parent the CPU under the machine
hw: Pair object_initialize_child() with plain realize()
hw: Parent board-created CPUs under the machine hw/pci-host/versatile: Use object_initialize_child() for pci_dev docs, qapi, scripts, iotests: Update /machine/unattached path
references
qom: Delete /machine/unattached and error on unparented realize tests/qtest/qom-test: Add smp-max init-time ceiling test docs/devel/qom: Document the composition-tree parenting contract
MAINTAINERS: Add scripts/coccinelle/qom-parent/ under QOM
MAINTAINERS | 1 + accel/accel-system.c | 4 +- backends/igvm.c | 6 +- bsd-user/main.c | 3 +- docs/devel/qom.rst | 96 +++++++ docs/devel/s390-cpu-topology.rst | 2 +- docs/system/cpu-hotplug.rst | 4 +- hw/alpha/alpha_sys.h | 3 +- hw/alpha/dp264.c | 16 +- hw/alpha/typhoon.c | 10 +- hw/arm/allwinner-a10.c | 4 +- hw/arm/allwinner-h3.c | 34 ++- hw/arm/allwinner-r40.c | 4 +- hw/arm/armsse.c | 13 +- hw/arm/aspeed.c | 39 +-- hw/arm/aspeed_ast1040_evb.c | 6 +- hw/arm/aspeed_ast10x0_evb.c | 12 +- hw/arm/aspeed_ast2400_palmetto.c | 8 +- hw/arm/aspeed_ast2400_quanta-q71l.c | 18 +- hw/arm/aspeed_ast2400_supermicrox11.c | 8 +- hw/arm/aspeed_ast2500_evb.c | 7 +- hw/arm/aspeed_ast2500_g220a.c | 11 +- hw/arm/aspeed_ast2500_romulus.c | 3 +- hw/arm/aspeed_ast2500_supermicro-x11spi.c | 8 +- hw/arm/aspeed_ast2500_tiogapass.c | 13 +- hw/arm/aspeed_ast2500_witherspoon.c | 34 +-- hw/arm/aspeed_ast2500_yosemitev2.c | 13 +- hw/arm/aspeed_ast2600_anacapa.c | 51 ++-- hw/arm/aspeed_ast2600_bletchley.c | 33 ++- hw/arm/aspeed_ast2600_catalina.c | 99 +++---- hw/arm/aspeed_ast2600_evb.c | 7 +- hw/arm/aspeed_ast2600_fby35.c | 20 +- hw/arm/aspeed_ast2600_fuji.c | 111 ++++---- hw/arm/aspeed_ast2600_gb200nvl.c | 24 +- hw/arm/aspeed_ast2600_rainier.c | 188 ++++++++------ hw/arm/aspeed_ast27x0-fc.c | 9 +- hw/arm/aspeed_ast27x0_evb.c | 3 +- hw/arm/aspeed_soc_common.c | 14 +- hw/arm/bananapi_m2u.c | 6 +- hw/arm/collie.c | 6 +- hw/arm/cubieboard.c | 6 +- hw/arm/digic_boards.c | 5 +- hw/arm/exynos4210.c | 70 ++--- hw/arm/exynos4_boards.c | 15 +- hw/arm/fsl-imx25.c | 2 +- hw/arm/fsl-imx31.c | 2 +- hw/arm/fsl-imx6.c | 7 +- hw/arm/fsl-imx6ul.c | 37 +-- hw/arm/fsl-imx7.c | 41 +-- hw/arm/fsl-imx8mm.c | 2 +- hw/arm/fsl-imx8mp.c | 2 +- hw/arm/imx25_pdk.c | 6 +- hw/arm/imx8mm-evk.c | 6 +- hw/arm/imx8mp-evk.c | 6 +- hw/arm/integratorcp.c | 56 ++-- hw/arm/kzm.c | 6 +- hw/arm/max78000_soc.c | 107 ++++---- hw/arm/max78000fthr.c | 5 +- hw/arm/mcimx6ul-evk.c | 4 +- hw/arm/mcimx7d-sabre.c | 4 +- hw/arm/mps2-tz.c | 27 +- hw/arm/mps2.c | 91 ++++--- hw/arm/mps3r.c | 20 +- hw/arm/msf2-soc.c | 24 +- hw/arm/msf2-som.c | 12 +- hw/arm/musca.c | 4 +- hw/arm/musicpal.c | 50 ++-- hw/arm/netduino2.c | 5 +- hw/arm/netduinoplus2.c | 5 +- hw/arm/npcm7xx.c | 95 +++---- hw/arm/npcm7xx_boards.c | 117 +++++---- hw/arm/npcm8xx.c | 147 +++++------ hw/arm/npcm8xx_boards.c | 19 +- hw/arm/nrf51_soc.c | 4 +- hw/arm/olimex-stm32-h405.c | 5 +- hw/arm/omap1.c | 244 ++++++++++-------- hw/arm/omap_sx1.c | 20 +- hw/arm/orangepi.c | 4 +- hw/arm/raspi.c | 4 +- hw/arm/realview.c | 113 ++++---- hw/arm/sabrelite.c | 5 +- hw/arm/sbsa-ref.c | 89 +++---- hw/arm/stellaris.c | 99 ++++--- hw/arm/stm32f100_soc.c | 62 ++--- hw/arm/stm32f205_soc.c | 2 +- hw/arm/stm32f405_soc.c | 88 +++---- hw/arm/stm32l4x5_soc.c | 88 +++---- hw/arm/stm32vldiscovery.c | 5 +- hw/arm/strongarm.c | 27 +- hw/arm/strongarm.h | 2 +- hw/arm/versatilepb.c | 85 +++--- hw/arm/vexpress.c | 87 ++++--- hw/arm/virt.c | 103 ++++---- hw/arm/xilinx_zynq.c | 160 ++++++------ hw/arm/xlnx-versal-virt.c | 5 +- hw/arm/xlnx-versal.c | 197 ++++++-------- hw/arm/xlnx-zcu102.c | 14 +- hw/arm/xlnx-zynqmp.c | 8 +- hw/audio/intel-hda.c | 4 +- hw/audio/model.c | 5 +- hw/avr/atmega.c | 24 +- hw/block/fdc-sysbus.c | 13 +- hw/block/fdc.c | 4 +- hw/block/pflash_cfi01.c | 6 +- hw/block/pflash_cfi02.c | 6 +- hw/block/xen-block.c | 5 +- hw/char/diva-gsp.c | 3 +- hw/char/exynos4210_uart.c | 6 +- hw/char/mcf_uart.c | 11 +- hw/char/mchp_pfsoc_mmuart.c | 4 +- hw/char/omap_uart.c | 4 +- hw/char/parallel-isa.c | 10 +- hw/char/parallel.c | 5 +- hw/char/pl011.c | 6 +- hw/char/riscv_htif.c | 5 +- hw/char/serial-isa.c | 11 +- hw/char/serial-mm.c | 6 +- hw/char/sifive_uart.c | 8 +- hw/char/spapr_vty.c | 6 +- hw/char/xen_console.c | 7 +- hw/core/cpu-common.c | 6 +- hw/core/gpio.c | 24 +- hw/core/irq.c | 38 +-- hw/core/null-machine.c | 2 +- hw/core/qdev-user.c | 6 +- hw/core/qdev.c | 40 ++- hw/core/reset.c | 13 +- hw/core/sysbus.c | 32 ++- hw/cxl/cxl-host.c | 9 +- hw/display/cg3.c | 2 +- hw/display/g364fb.c | 2 +- hw/display/macfb.c | 2 +- hw/display/omap_lcdc.c | 5 +- hw/display/sii9022.c | 2 +- hw/display/sm501.c | 6 +- hw/display/vhost-user-gpu.c | 12 +- hw/display/virtio-gpu-gl.c | 2 +- hw/display/vmware_vga.c | 12 +- hw/display/xlnx_dp.c | 14 +- hw/dma/i8257.c | 10 +- hw/dma/omap_dma.c | 9 +- hw/dma/rc4030.c | 7 +- hw/hexagon/hexagon_dsp.c | 21 +- hw/hexagon/virt.c | 29 +-- hw/hppa/machine.c | 96 ++++--- hw/i2c/aspeed_i2c.c | 4 +- hw/i2c/core.c | 22 +- hw/i2c/smbus_eeprom.c | 11 +- hw/i386/amd_iommu.c | 3 +- hw/i386/isapc.c | 17 +- hw/i386/kvm/clock.c | 4 +- hw/i386/kvm/clock.h | 2 +- hw/i386/kvm/i8259.c | 8 +- hw/i386/kvm/xen-stubs.c | 2 +- hw/i386/kvm/xen_evtchn.c | 6 +- hw/i386/kvm/xen_evtchn.h | 3 +- hw/i386/kvm/xen_gnttab.c | 6 +- hw/i386/kvm/xen_gnttab.h | 2 +- hw/i386/kvm/xen_overlay.c | 6 +- hw/i386/kvm/xen_overlay.h | 2 +- hw/i386/kvm/xen_primary_console.c | 5 +- hw/i386/kvm/xen_primary_console.h | 2 +- hw/i386/kvm/xen_xenstore.c | 5 +- hw/i386/kvm/xen_xenstore.h | 2 +- hw/i386/microvm.c | 34 +-- hw/i386/nitro_enclave.c | 9 +- hw/i386/pc.c | 96 +++---- hw/i386/pc_piix.c | 28 +- hw/i386/pc_q35.c | 42 +-- hw/i386/pc_sysfw.c | 16 +- hw/i386/sgx.c | 5 +- hw/i386/x86-common.c | 33 ++- hw/i386/x86-cpu.c | 4 +- hw/i386/xen/xen-hvm.c | 12 +- hw/i386/xen/xen-pvh.c | 5 +- hw/i386/xen/xen_pvdevice.c | 2 +- hw/i3c/core.c | 19 +- hw/ide/ahci.c | 2 +- hw/ide/ide-bus.c | 5 +- hw/ide/ide-internal.h | 2 +- hw/ide/ioport.c | 37 ++- hw/ide/isa.c | 9 +- hw/ide/pci.c | 2 +- hw/ide/piix.c | 2 +- hw/intc/apic_common.c | 3 +- hw/intc/exynos4210_gic.c | 4 +- hw/intc/i8259.c | 6 +- hw/intc/i8259_common.c | 7 +- hw/intc/mips_gic.c | 2 +- hw/intc/riscv_aclint.c | 16 +- hw/intc/riscv_aplic.c | 13 +- hw/intc/riscv_imsic.c | 7 +- hw/intc/s390_flic.c | 12 +- hw/intc/sh_intc.c | 21 +- hw/intc/sifive_plic.c | 7 +- hw/ipack/ipack.c | 11 +- hw/ipmi/ipmi_bt.c | 2 +- hw/ipmi/ipmi_kcs.c | 2 +- hw/isa/i82378.c | 13 +- hw/isa/isa-bus.c | 44 ++-- hw/isa/isa-superio.c | 25 +- hw/isa/lpc_ich9.c | 2 +- hw/isa/piix.c | 4 +- hw/isa/vt82c686.c | 7 +- hw/loongarch/virt.c | 62 +++-- hw/m68k/an5206.c | 13 +- hw/m68k/mcf5206.c | 8 +- hw/m68k/mcf5208.c | 32 ++- hw/m68k/mcf_intc.c | 7 +- hw/m68k/next-cube.c | 26 +- hw/m68k/q800.c | 28 +- hw/m68k/virt.c | 25 +- hw/mem/sparse-mem.c | 6 +- hw/microblaze/petalogix_ml605_mmu.c | 40 ++- hw/microblaze/petalogix_s3adsp1800_mmu.c | 27 +- hw/microblaze/xlnx-zynqmp-pmu.c | 4 +- hw/mips/boston.c | 32 +-- hw/mips/cps.c | 5 +- hw/mips/fuloong2e.c | 24 +- hw/mips/jazz.c | 73 +++--- hw/mips/loongson3_virt.c | 40 +-- hw/mips/malta.c | 49 ++-- hw/mips/mips_int.c | 2 +- hw/misc/empty_slot.c | 7 +- hw/misc/led.c | 15 +- hw/misc/macio/macio.c | 2 +- hw/misc/sifive_e_prci.c | 6 +- hw/misc/sifive_test.c | 6 +- hw/net/can/can_kvaser_pci.c | 2 +- hw/net/imx_fec.c | 4 +- hw/net/lan9118.c | 10 +- hw/net/smc91c111.c | 6 +- hw/net/spapr_llan.c | 6 +- hw/net/xen_nic.c | 5 +- hw/nitro/machine.c | 11 +- hw/nitro/nitro-vsock-bus.c | 9 +- hw/nubus/nubus-virtio-mmio.c | 2 +- hw/nvme/ctrl.c | 2 +- hw/nvram/eeprom_at24c.c | 12 +- hw/nvram/fw_cfg.c | 16 +- hw/or1k/or1k-sim.c | 25 +- hw/or1k/virt.c | 43 +-- hw/pci-bridge/pci_expander_bridge.c | 13 +- hw/pci-host/articia.c | 6 +- hw/pci-host/astro.c | 8 +- hw/pci-host/bonito.c | 28 +- hw/pci-host/grackle.c | 2 +- hw/pci-host/gt64120.c | 5 +- hw/pci-host/i440fx.c | 2 +- hw/pci-host/mv64361.c | 4 +- hw/pci-host/pnv_phb.c | 5 +- hw/pci-host/pnv_phb3.c | 3 +- hw/pci-host/pnv_phb3_msi.c | 3 +- hw/pci-host/pnv_phb4.c | 3 +- hw/pci-host/pnv_phb4_pec.c | 3 +- hw/pci-host/ppc4xx_pci.c | 2 +- hw/pci-host/ppce500.c | 2 +- hw/pci-host/raven.c | 6 +- hw/pci-host/sabre.c | 12 +- hw/pci-host/sh_pci.c | 3 +- hw/pci-host/uninorth.c | 11 +- hw/pci-host/versatile.c | 3 +- hw/pci/pci.c | 60 +++-- hw/pci/pcie_sriov.c | 5 +- hw/ppc/amigaone.c | 24 +- hw/ppc/e500.c | 70 ++--- hw/ppc/mac_newworld.c | 58 +++-- hw/ppc/mac_oldworld.c | 32 +-- hw/ppc/pegasos.c | 22 +- hw/ppc/pnv.c | 33 +-- hw/ppc/pnv_bmc.c | 4 +- hw/ppc/pnv_lpc.c | 6 +- hw/ppc/pnv_psi.c | 6 +- hw/ppc/ppc440.h | 2 +- hw/ppc/ppc440_bamboo.c | 17 +- hw/ppc/ppc440_uc.c | 10 +- hw/ppc/ppc4xx_sdram.c | 34 +-- hw/ppc/prep.c | 50 ++-- hw/ppc/sam460ex.c | 72 +++--- hw/ppc/spapr.c | 38 +-- hw/ppc/spapr_irq.c | 6 +- hw/ppc/spapr_vio.c | 6 +- hw/ppc/virtex_ml507.c | 23 +- hw/remote/iommu.c | 7 +- hw/remote/machine.c | 6 +- hw/remote/memory.c | 3 +- hw/remote/vfio-user-obj.c | 2 +- hw/riscv/aia.c | 12 +- hw/riscv/aia.h | 3 +- hw/riscv/boston-aia.c | 31 ++- hw/riscv/cps.c | 14 +- hw/riscv/k230.c | 127 ++++----- hw/riscv/microblaze-v-generic.c | 51 ++-- hw/riscv/microchip_pfsoc.c | 90 +++---- hw/riscv/opentitan.c | 52 ++-- hw/riscv/shakti_c.c | 8 +- hw/riscv/sifive_e.c | 25 +- hw/riscv/sifive_u.c | 39 +-- hw/riscv/spike.c | 8 +- hw/riscv/tt_atlantis.c | 17 +- hw/riscv/virt.c | 62 ++--- hw/riscv/xiangshan_kmh.c | 20 +- hw/rtc/ls7a_rtc.c | 2 +- hw/rtc/mc146818rtc.c | 6 +- hw/rtc/sun4v-rtc.c | 6 +- hw/s390x/ap-bridge.c | 6 +- hw/s390x/css-bridge.c | 7 +- hw/s390x/s390-pci-bus.c | 13 +- hw/s390x/s390-virtio-ccw.c | 41 ++- hw/scsi/esp-pci.c | 2 +- hw/scsi/lasi_ncr710.c | 8 +- hw/scsi/lasi_ncr710.h | 4 +- hw/scsi/ncr53c710.c | 15 +- hw/scsi/ncr53c710.h | 7 +- hw/scsi/scsi-bus.c | 5 +- hw/scsi/spapr_vscsi.c | 6 +- hw/sh4/r2d.c | 38 +-- hw/sh4/sh7750.c | 35 +-- hw/sparc/leon3.c | 27 +- hw/sparc/sun4m.c | 167 ++++++------ hw/sparc64/niagara.c | 20 +- hw/sparc64/sparc64.c | 3 +- hw/sparc64/sun4u.c | 69 ++--- hw/ssi/ssi.c | 7 +- hw/timer/arm_timer.c | 6 +- hw/timer/sh_timer.c | 9 +- hw/tricore/tc27x_soc.c | 77 +++--- hw/tricore/tricore_testboard.c | 19 +- hw/ufs/lu.c | 5 +- hw/usb/bus.c | 15 +- hw/usb/dev-serial.c | 3 +- hw/usb/vt82c686-uhci-pci.c | 4 +- hw/vfio/igd.c | 5 +- hw/virtio/virtio-mem.c | 5 +- hw/vmapple/vmapple.c | 66 ++--- hw/xen/xen-bus.c | 5 +- hw/xen/xen-legacy-backend.c | 5 +- hw/xen/xen-pvh-common.c | 26 +- hw/xen/xen_pt_graphics.c | 3 +- hw/xtensa/mx_pic.c | 8 +- hw/xtensa/pic_cpu.c | 5 +- hw/xtensa/sim.c | 15 +- hw/xtensa/virt.c | 4 +- hw/xtensa/xtensa_memory.c | 5 +- hw/xtensa/xtensa_memory.h | 3 +- hw/xtensa/xtfpga.c | 51 ++-- include/hw/arm/aspeed.h | 6 +- include/hw/arm/aspeed_soc.h | 3 +- include/hw/arm/exynos4210.h | 2 +- include/hw/arm/omap.h | 11 +- include/hw/block/fdc.h | 5 +- include/hw/block/flash.h | 4 +- include/hw/char/mchp_pfsoc_mmuart.h | 2 +- include/hw/char/parallel.h | 5 +- include/hw/char/pl011.h | 2 +- include/hw/char/riscv_htif.h | 3 +- include/hw/char/serial-isa.h | 2 +- include/hw/char/serial-mm.h | 2 +- include/hw/char/sifive_uart.h | 4 +- include/hw/core/cpu.h | 11 +- include/hw/core/irq.h | 27 +- include/hw/core/qdev.h | 50 ++-- include/hw/core/sysbus.h | 33 ++- include/hw/i2c/i2c.h | 29 ++- include/hw/i2c/smbus_eeprom.h | 5 +- include/hw/i386/pc.h | 6 +- include/hw/i386/vmport.h | 5 - include/hw/i386/x86.h | 7 +- include/hw/i3c/i3c.h | 9 +- include/hw/ide/isa.h | 3 +- include/hw/intc/i8259.h | 4 +- include/hw/intc/riscv_aclint.h | 6 +- include/hw/intc/riscv_aplic.h | 5 +- include/hw/intc/riscv_imsic.h | 3 +- include/hw/intc/sifive_plic.h | 3 +- include/hw/isa/i8259_internal.h | 3 +- include/hw/isa/isa.h | 11 +- include/hw/m68k/mcf.h | 7 +- include/hw/mem/sparse-mem.h | 2 +- include/hw/mips/mips.h | 5 +- include/hw/misc/empty_slot.h | 3 +- include/hw/misc/sifive_e_prci.h | 2 +- include/hw/misc/sifive_test.h | 2 +- include/hw/misc/unimp.h | 9 +- include/hw/net/lan9118.h | 2 +- include/hw/net/ne2000-isa.h | 8 +- include/hw/net/smc91c111.h | 2 +- include/hw/nitro/nitro-vsock-bus.h | 2 +- include/hw/nvram/eeprom_at24c.h | 6 +- include/hw/pci/pci.h | 19 +- include/hw/ppc/pnv.h | 2 +- include/hw/ppc/spapr_vio.h | 8 +- include/hw/rtc/mc146818rtc.h | 2 +- include/hw/rtc/sun4v-rtc.h | 2 +- include/hw/sh4/sh.h | 3 +- include/hw/sh4/sh_intc.h | 3 +- include/hw/ssi/ssi.h | 3 +- include/hw/timer/i8254.h | 13 +- include/hw/timer/tmu012.h | 3 +- include/hw/usb/usb.h | 13 +- include/hw/xen/xen.h | 2 +- include/hw/xtensa/mx_pic.h | 4 +- include/net/net.h | 5 +- include/qom/object.h | 32 +++ linux-user/main.c | 6 +- net/net.c | 10 +- qapi/block-core.json | 12 +- qapi/block.json | 2 +- qapi/machine.json | 12 +- qapi/qom.json | 4 +- qom/object.c | 12 + scripts/arm_processor_error.py | 3 +- .../qom-parent/cpu-create-orphan.cocci | 13 + .../qom-parent/i2c-slave-new-orphan.cocci | 18 ++ .../coccinelle/qom-parent/irq-rename.cocci | 15 ++ .../qom-parent/isa-new-orphan.cocci | 23 ++ .../qom-parent/pci-new-orphan.cocci | 28 ++ .../qom-parent/qdev-new-orphan.cocci | 18 ++ .../qom-parent/ssi-usb-orphan.cocci | 18 ++ .../qom-parent/sysbus-create-orphan.cocci | 18 ++ scripts/qmp_helper.py | 2 +- stubs/xen-hw-stub.c | 2 +- system/ioport.c | 12 +- system/memory.c | 24 +- system/physmem.c | 4 +- system/qdev-monitor.c | 2 +- system/qtest.c | 2 +- system/ram-block-attributes.c | 7 +- system/vl.c | 3 +- target/mips/cpu.c | 5 +- target/mips/cpu.h | 3 +- target/xtensa/cpu.c | 11 - target/xtensa/cpu.h | 2 - tests/qemu-iotests/172.out | 72 +++--- tests/qemu-iotests/186.out | 10 +- tests/qemu-iotests/common.filter | 2 +- tests/qtest/fuzz/generic_fuzz.c | 2 +- tests/qtest/qom-test.c | 35 +++ tests/unit/test-qdev-global-props.c | 17 +- tests/unit/test-qdev.c | 12 +- 440 files changed, 4588 insertions(+), 3817 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/cpu-create-orphan.cocci create mode 100644 scripts/coccinelle/qom-parent/i2c-slave-new-orphan.cocci create mode 100644 scripts/coccinelle/qom-parent/irq-rename.cocci create mode 100644 scripts/coccinelle/qom-parent/isa-new-orphan.cocci create mode 100644 scripts/coccinelle/qom-parent/pci-new-orphan.cocci create mode 100644 scripts/coccinelle/qom-parent/qdev-new-orphan.cocci create mode 100644 scripts/coccinelle/qom-parent/ssi-usb-orphan.cocci create mode 100644 scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci
base-commit: eca2c16212ef9dcb0871de39bb9d1c2efebe76be
Signature · 1 line
2.47.1
RFC PATCH v2 1/137 qom: Introduce object_new_child()
We already have two ways of creating a QOM object with a parent set from birth: object_initialize_child() for objects embedded in the parent struct, and object_new_with_props() for heap-allocated objects that also want a list of string properties applied. What we do not have is the plain heap-allocated dual of object_initialize_child():
create the object, add it as a child<> of a given parent under a given name, and hand the reference to the parent.
Board and composite-device code that heap-allocates children today therefore either open-codes object_new()+object_property_add_child() +object_unref(), or skips the parenting step entirely and lets device_set_realized() dump the object into /machine/unattached.
Add object_new_child(parent, id, typename) as that missing primitive. The reference created by object_new() is transferred to the parent's child<> property, so on return the sole reference is held by @parent and the caller does not need to unref. Later patches build the qdev and per-bus creation helpers on top of this.
@id must be a valid QOM child<> property name: non-empty and without the "/" QOM path separator. It may contain the "[*]" auto-index suffix; the qdev id_wellformed() grammar does not apply here. The compiler enforces non-NULL arguments via __attribute__((nonnull)) instead of runtime asserts, as suggested by Richard and Peter.
AI-used-for: code (refactoring)
--- include/qom/object.h | 32 ++++++++++++++++++++++++++++++++ qom/object.c | 12 ++++++++++++ 2 files changed, 44 insertions(+)
include/qom/object.h +32 -0
@@ -632,6 +632,38 @@ Object *object_new_with_class(ObjectClass *klass);*/ Object *object_new (const char *typename); +/** +* object_new_child: +* @parent: the QOM composition-tree parent +* @id: the child<> property name; the object's canonical QOM path +* becomes @parent's path plus "/" plus @id +* @typename: the name of the type of the object to instantiate +* +* Create a heap-allocated object and immediately add it to the QOM +* composition tree as a child of @parent. +* +* This is the heap-allocated dual of object_initialize_child(): use +* this when the child is a pointer member of the parent, and use +* object_initialize_child() when the child is embedded in the parent +* struct. See also object_new_with_props() for the variant that +* additionally sets a list of properties. +* +* The reference returned by object_new() is transferred to the child<> +* property of @parent, so the object has a reference count of 1 held +* by @parent, and the caller does not need to unref. +* +* The @id assert is a sanity check on the caller's string literal; +* the authoritative uniqueness check is object_property_add_child(), +* which will error_abort() on a duplicate @id under @parent. Use +* the "[*]" auto-index suffix when multiple children of the same +* kind may be created. +* +* Returns: the newly allocated, instantiated and parented object. +*/ +Object *object_new_child (Object *parent,const char *id, +const char *typename) + __attribute__((nonnull (1 ,2 ,3 ), returns_nonnull)); +/** * object_new_with_props: * @typename: The name of the type of the object to instantiate.
qom/object.c +12 -0
@@ -718,6 +718,18 @@ Object *object_new(const char *typename)return object_new_with_type (ti); } +Object *object_new_child (Object *parent,const char *id, +const char *typename) +{ +Object *obj; + +g_assert (id[0 ] && !strchr (id,'/' )); + + obj =object_new (typename); +object_property_add_child (parent, id, obj); +object_unref (obj); +return obj; +} Object *object_new_with_props(const char *typename, Object *parent,
Signature · 1 line
2.47.1
RFC PATCH v2 2/137 qdev: Rename qdev_new()/qdev_try_new() to *_orphan()
In reply to Alexander Grafqdev_new() creates a device on the heap without a QOM parent. If the caller does not add one before realize, device_set_realized() dumps the device into /machine/unattached with an unstable canonical path.
We want the short spelling qdev_new() to be the one that gets parenting right by construction. As a first step, rename the current functions to qdev_new_orphan() and qdev_try_new_orphan() tree-wide so that a subsequent commit can reintroduce qdev_new() with a mandatory (parent, id, type) signature.
Purely mechanical, generated by
spatch --sp-file scripts/coccinelle/qom-parent/qdev-new-orphan.cocci \
--in-place --include-headers --dir .
or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \
grep -v '^subprojects/' | \
xargs sed -i 's/\bqdev_try_new\b/qdev_try_new_orphan/g;
s/\bqdev_new\b/qdev_new_orphan/g'No functional change.
AI-used-for: code (refactoring)
--- hw/alpha/typhoon.c | 2 +- hw/arm/aspeed.c | 2 +- hw/arm/aspeed_soc_common.c | 4 +- hw/arm/bananapi_m2u.c | 2 +- hw/arm/cubieboard.c | 2 +- hw/arm/exynos4210.c | 12 ++-- hw/arm/imx25_pdk.c | 2 +- hw/arm/imx8mm-evk.c | 2 +- hw/arm/imx8mp-evk.c | 2 +- hw/arm/integratorcp.c | 8 +-- hw/arm/max78000fthr.c | 2 +- hw/arm/mcimx6ul-evk.c | 2 +- hw/arm/mcimx7d-sabre.c | 2 +- hw/arm/mps2-tz.c | 4 +- hw/arm/mps2.c | 4 +- hw/arm/msf2-som.c | 4 +- hw/arm/musicpal.c | 6 +- hw/arm/netduino2.c | 2 +- hw/arm/netduinoplus2.c | 2 +- hw/arm/npcm7xx_boards.c | 4 +- hw/arm/npcm8xx_boards.c | 2 +- hw/arm/olimex-stm32-h405.c | 2 +- hw/arm/omap1.c | 12 ++-- hw/arm/orangepi.c | 2 +- hw/arm/raspi.c | 2 +- hw/arm/realview.c | 18 ++--- hw/arm/sabrelite.c | 2 +- hw/arm/sbsa-ref.c | 20 +++--- hw/arm/stellaris.c | 20 +++--- hw/arm/stm32vldiscovery.c | 2 +- hw/arm/strongarm.c | 4 +- hw/arm/versatilepb.c | 14 ++-- hw/arm/vexpress.c | 14 ++-- hw/arm/virt.c | 24 +++---- hw/arm/xilinx_zynq.c | 26 +++---- hw/arm/xlnx-versal-virt.c | 2 +- hw/arm/xlnx-versal.c | 70 +++++++++---------- hw/arm/xlnx-zcu102.c | 6 +- hw/arm/xlnx-zynqmp.c | 2 +- hw/audio/intel-hda.c | 2 +- hw/audio/model.c | 2 +- hw/avr/atmega.c | 2 +- hw/block/fdc-sysbus.c | 4 +- hw/block/fdc.c | 2 +- hw/block/pflash_cfi01.c | 2 +- hw/block/pflash_cfi02.c | 2 +- hw/block/xen-block.c | 2 +- hw/char/exynos4210_uart.c | 2 +- hw/char/mcf_uart.c | 2 +- hw/char/mchp_pfsoc_mmuart.c | 2 +- hw/char/pl011.c | 2 +- hw/char/serial-mm.c | 2 +- hw/char/sifive_uart.c | 2 +- hw/char/spapr_vty.c | 2 +- hw/char/xen_console.c | 2 +- hw/core/qdev.c | 4 +- hw/core/sysbus.c | 2 +- hw/cxl/cxl-host.c | 2 +- hw/display/sm501.c | 2 +- hw/display/xlnx_dp.c | 4 +- hw/dma/rc4030.c | 2 +- hw/hexagon/hexagon_dsp.c | 4 +- hw/hexagon/virt.c | 6 +- hw/hppa/machine.c | 12 ++-- hw/i2c/core.c | 2 +- hw/i2c/smbus_eeprom.c | 2 +- hw/i386/microvm.c | 6 +- hw/i386/nitro_enclave.c | 4 +- hw/i386/pc.c | 2 +- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/i386/pc_sysfw.c | 2 +- hw/i386/sgx.c | 2 +- hw/i386/x86-common.c | 6 +- hw/i3c/core.c | 2 +- hw/ide/ide-bus.c | 2 +- hw/intc/exynos4210_gic.c | 2 +- hw/intc/riscv_aclint.c | 4 +- hw/intc/riscv_aplic.c | 2 +- hw/intc/riscv_imsic.c | 2 +- hw/intc/s390_flic.c | 4 +- hw/intc/sifive_plic.c | 2 +- hw/isa/isa-bus.c | 6 +- hw/loongarch/virt.c | 18 ++--- hw/m68k/an5206.c | 2 +- hw/m68k/mcf_intc.c | 2 +- hw/m68k/next-cube.c | 2 +- hw/m68k/q800.c | 4 +- hw/m68k/virt.c | 10 +-- hw/mem/sparse-mem.c | 2 +- hw/microblaze/petalogix_ml605_mmu.c | 12 ++-- hw/microblaze/petalogix_s3adsp1800_mmu.c | 8 +-- hw/mips/boston.c | 4 +- hw/mips/jazz.c | 12 ++-- hw/mips/loongson3_virt.c | 6 +- hw/mips/malta.c | 4 +- hw/misc/empty_slot.c | 2 +- hw/misc/led.c | 2 +- hw/misc/sifive_e_prci.c | 2 +- hw/misc/sifive_test.c | 2 +- hw/net/lan9118.c | 2 +- hw/net/smc91c111.c | 2 +- hw/net/spapr_llan.c | 2 +- hw/net/xen_nic.c | 2 +- hw/nitro/machine.c | 4 +- hw/nitro/nitro-vsock-bus.c | 2 +- hw/nvme/ctrl.c | 2 +- hw/nvram/fw_cfg.c | 4 +- hw/or1k/or1k-sim.c | 6 +- hw/or1k/virt.c | 8 +-- hw/pci-bridge/pci_expander_bridge.c | 4 +- hw/pci-host/astro.c | 2 +- hw/pci-host/bonito.c | 2 +- hw/pci-host/pnv_phb4_pec.c | 2 +- hw/pci/pci.c | 2 +- hw/ppc/amigaone.c | 2 +- hw/ppc/e500.c | 22 +++--- hw/ppc/mac_newworld.c | 18 ++--- hw/ppc/mac_oldworld.c | 8 +-- hw/ppc/pnv.c | 4 +- hw/ppc/pnv_bmc.c | 2 +- hw/ppc/ppc440_bamboo.c | 4 +- hw/ppc/prep.c | 4 +- hw/ppc/sam460ex.c | 16 ++--- hw/ppc/spapr.c | 4 +- hw/ppc/spapr_irq.c | 2 +- hw/ppc/spapr_vio.c | 2 +- hw/ppc/virtex_ml507.c | 6 +- hw/remote/machine.c | 2 +- hw/riscv/boston-aia.c | 4 +- hw/riscv/microblaze-v-generic.c | 14 ++-- hw/riscv/microchip_pfsoc.c | 2 +- hw/riscv/sifive_u.c | 4 +- hw/riscv/virt.c | 8 +-- hw/rtc/sun4v-rtc.c | 2 +- hw/s390x/ap-bridge.c | 2 +- hw/s390x/css-bridge.c | 2 +- hw/s390x/s390-pci-bus.c | 2 +- hw/s390x/s390-virtio-ccw.c | 6 +- hw/scsi/lasi_ncr710.c | 2 +- hw/scsi/ncr53c710.c | 4 +- hw/scsi/scsi-bus.c | 2 +- hw/scsi/spapr_vscsi.c | 2 +- hw/sh4/r2d.c | 6 +- hw/sh4/sh7750.c | 4 +- hw/sparc/leon3.c | 10 +-- hw/sparc/sun4m.c | 38 +++++----- hw/sparc64/sun4u.c | 14 ++-- hw/ssi/ssi.c | 2 +- hw/tricore/tricore_testboard.c | 2 +- hw/ufs/lu.c | 2 +- hw/usb/bus.c | 4 +- hw/usb/dev-serial.c | 2 +- hw/vmapple/vmapple.c | 20 +++--- hw/xen/xen-bus.c | 2 +- hw/xen/xen-legacy-backend.c | 2 +- hw/xen/xen-pvh-common.c | 2 +- hw/xtensa/virt.c | 2 +- hw/xtensa/xtfpga.c | 2 +- include/hw/core/qdev.h | 14 ++-- include/hw/i2c/i2c.h | 2 +- include/hw/misc/unimp.h | 2 +- include/hw/ssi/ssi.h | 2 +- include/hw/usb/usb.h | 2 +- migration/migration.c | 2 +- net/net.c | 4 +- .../qom-parent/qdev-new-orphan.cocci | 18 +++++ system/qdev-monitor.c | 2 +- target/mips/cpu.c | 2 +- target/xtensa/cpu.c | 2 +- 170 files changed, 459 insertions(+), 441 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/qdev-new-orphan.cocci
hw/alpha/typhoon.c +1 -1
@@ -830,7 +830,7 @@ PCIBus *typhoon_init(MemoryRegion *ram, qemu_irq *p_isa_irq,PCIBus *b;int i; - dev =qdev_new (TYPE_TYPHOON_PCI_HOST_BRIDGE ); + dev =qdev_new_orphan (TYPE_TYPHOON_PCI_HOST_BRIDGE ); s =TYPHOON_PCI_HOST_BRIDGE (dev); phb =PCI_HOST_BRIDGE (dev);
hw/arm/aspeed.c +1 -1
@@ -90,7 +90,7 @@ static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo, bool emmc,if (!dinfo) {return ; } - card =qdev_new (emmc ?TYPE_EMMC :TYPE_SD_CARD ); + card =qdev_new_orphan (emmc ?TYPE_EMMC :TYPE_SD_CARD );/* * Force the boot properties of the eMMC device only when the
hw/arm/aspeed_soc_common.c +2 -2
@@ -81,7 +81,7 @@ bool aspeed_soc_dram_init(AspeedSoCState *s, Error **errp)* SoC has. */ if (ram_size < max_ram_size) { -DeviceState *dev =qdev_new (TYPE_UNIMPLEMENTED_DEVICE ); +DeviceState *dev =qdev_new_orphan (TYPE_UNIMPLEMENTED_DEVICE );qdev_prop_set_string (dev,"name" ,"ram-empty" );qdev_prop_set_uint64 (dev,"size" , max_ram_size - ram_size);
@@ -128,7 +128,7 @@ void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,DriveInfo *dinfo =drive_get (IF_MTD ,0 , unit0 + i);DeviceState *dev; - dev =qdev_new (flashtype); + dev =qdev_new_orphan (flashtype);if (dinfo) {qdev_prop_set_drive (dev,"drive" ,blk_by_legacy_dinfo (dinfo)); }
hw/arm/bananapi_m2u.c +1 -1
@@ -50,7 +50,7 @@ static void mmc_attach_drive(AwR40State *s, AwSdHostState *mmc, int unit,exit (1 ); } - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal);
hw/arm/cubieboard.c +1 -1
@@ -89,7 +89,7 @@ static void cubieboard_init(MachineState *machine) bus =qdev_get_child_bus (DEVICE (a10),"sd-bus" );/* Plug in SD card */ - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal);
hw/arm/exynos4210.c +6 -6
@@ -519,7 +519,7 @@ static DeviceState *pl330_create(uint32_t base, OrIRQState *orgate,DeviceState *dev;int i; - dev =qdev_new ("pl330" ); + dev =qdev_new_orphan ("pl330" );object_property_set_link (OBJECT (dev),"memory" ,OBJECT (get_system_memory ()), &error_fatal);
@@ -687,7 +687,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) NULL);/* Multi Core Timer */ - dev =qdev_new ("exynos4210.mct" ); + dev =qdev_new_orphan ("exynos4210.mct" ); busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal);for (n =0 ; n <4 ; n++) {
@@ -713,7 +713,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) i2c_irq = s->irq_table[exynos4210_get_irq (EXYNOS4210_HDMI_INTG ,1 )]; } - dev =qdev_new ("exynos4210.i2c" ); + dev =qdev_new_orphan ("exynos4210.i2c" ); busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal);sysbus_connect_irq (busdev,0 , i2c_irq);
@@ -757,7 +757,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)* public datasheet which is very similar (implementing * MMC Specification Version 4.0 being the only difference noted) */ - dev =qdev_new (TYPE_S3C_SDHCI ); + dev =qdev_new_orphan (TYPE_S3C_SDHCI );qdev_prop_set_uint64 (dev,"capareg" ,EXYNOS4210_SDHCI_CAPABILITIES ); busdev =SYS_BUS_DEVICE (dev);
@@ -767,14 +767,14 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) di =drive_get (IF_SD ,0 , n); blk = di ?blk_by_legacy_dinfo (di) :NULL ; - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive (carddev,"drive" , blk);qdev_realize_and_unref (carddev,qdev_get_child_bus (dev,"sd-bus" ), &error_fatal); }/*** Display controller (FIMD) ***/ - dev =qdev_new ("exynos4210.fimd" ); + dev =qdev_new_orphan ("exynos4210.fimd" );object_property_set_link (OBJECT (dev),"framebuffer-memory" ,OBJECT (system_mem), &error_fatal); busdev =SYS_BUS_DEVICE (dev);
hw/arm/imx25_pdk.c +1 -1
@@ -127,7 +127,7 @@ static void imx25_pdk_init(MachineState *machine) di =drive_get (IF_SD ,0 , i); blk = di ?blk_by_legacy_dinfo (di) :NULL ; bus =qdev_get_child_bus (DEVICE (&s->soc.esdhc[i]),"sd-bus" ); - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal); }
hw/arm/imx8mm-evk.c +1 -1
@@ -97,7 +97,7 @@ static void imx8mm_evk_init(MachineState *machine) blk =blk_by_legacy_dinfo (di); bus =qdev_get_child_bus (DEVICE (&s->usdhc[i]),"sd-bus" ); - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal); }
hw/arm/imx8mp-evk.c +1 -1
@@ -110,7 +110,7 @@ static void imx8mp_evk_init(MachineState *machine) blk =blk_by_legacy_dinfo (di); bus =qdev_get_child_bus (DEVICE (&s->soc.usdhc[i]),"sd-bus" ); - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal); }
hw/arm/integratorcp.c +4 -4
@@ -621,7 +621,7 @@ static void integratorcp_init(MachineState *machine) 0, ram_size);memory_region_add_subregion (address_space_mem,0x80000000 , ram_alias); - dev =qdev_new (TYPE_INTEGRATOR_CM ); + dev =qdev_new_orphan (TYPE_INTEGRATOR_CM );qdev_prop_set_uint32 (dev,"memsz" , ram_size >>20 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map ((SysBusDevice *)dev,0 ,0x10000000 );
@@ -654,14 +654,14 @@ static void integratorcp_init(MachineState *machine)if (dinfo) {DeviceState *card; - card =qdev_new (TYPE_SD_CARD ); + card =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (card,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal);qdev_realize_and_unref (card,qdev_get_child_bus (dev,"sd-bus" ), &error_fatal); } - dev =qdev_new ("pl041" ); + dev =qdev_new_orphan ("pl041" );if (machine->audiodev) {qdev_prop_set_string (dev,"audiodev" , machine->audiodev); }
@@ -673,7 +673,7 @@ static void integratorcp_init(MachineState *machine)smc91c111_init (0xc8000000 , pic[27 ]); } - dev =qdev_new ("pl110" ); + dev =qdev_new_orphan ("pl110" );object_property_set_link (OBJECT (dev),"framebuffer-memory" ,OBJECT (address_space_mem), &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/arm/max78000fthr.c +1 -1
@@ -26,7 +26,7 @@ static void max78000_init(MachineState *machine) sysclk =clock_new (OBJECT (machine),"SYSCLK" );clock_set_hz (sysclk,SYSCLK_FRQ ); - dev =qdev_new (TYPE_MAX78000_SOC ); + dev =qdev_new_orphan (TYPE_MAX78000_SOC );object_property_add_child (OBJECT (machine),"soc" ,OBJECT (dev));qdev_connect_clock_in (dev,"sysclk" , sysclk);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/arm/mcimx6ul-evk.c +1 -1
@@ -59,7 +59,7 @@ static void mcimx6ul_evk_init(MachineState *machine) di =drive_get (IF_SD ,0 , i); blk = di ?blk_by_legacy_dinfo (di) :NULL ; bus =qdev_get_child_bus (DEVICE (&s->usdhc[i]),"sd-bus" ); - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal); }
hw/arm/mcimx7d-sabre.c +1 -1
@@ -59,7 +59,7 @@ static void mcimx7d_sabre_init(MachineState *machine) di =drive_get (IF_SD ,0 , i); blk = di ?blk_by_legacy_dinfo (di) :NULL ; bus =qdev_get_child_bus (DEVICE (&s->usdhc[i]),"sd-bus" ); - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal); }
hw/arm/mps2-tz.c +2 -2
@@ -508,7 +508,7 @@ static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque,/* In hardware this is a LAN9220; the LAN9118 is software compatible * except that it doesn't support the checksum-offload feature. */ - mms->lan9118 =qdev_new (TYPE_LAN9118 ); + mms->lan9118 =qdev_new_orphan (TYPE_LAN9118 );qemu_configure_nic_device (mms->lan9118, true,NULL ); s =SYS_BUS_DEVICE (mms->lan9118);
@@ -535,7 +535,7 @@ static MemoryRegion *make_eth_usb(MPS2TZMachineState *mms, void *opaque,* In hardware this is a LAN9220; the LAN9118 is software compatible * except that it doesn't support the checksum-offload feature. */ - mms->lan9118 =qdev_new (TYPE_LAN9118 ); + mms->lan9118 =qdev_new_orphan (TYPE_LAN9118 );qemu_configure_nic_device (mms->lan9118, true,NULL ); s =SYS_BUS_DEVICE (mms->lan9118);
hw/arm/mps2.c +2 -2
@@ -299,7 +299,7 @@ static void mps2_common_init(MachineState *machine) rxovrint =qdev_get_gpio_in (orgate_dev, i *2 +1 ); } - dev =qdev_new (TYPE_CMSDK_APB_UART ); + dev =qdev_new_orphan (TYPE_CMSDK_APB_UART ); s =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" ,serial_hd (i));qdev_prop_set_uint32 (dev,"pclk-frq" ,SYSCLK_FRQ );
@@ -343,7 +343,7 @@ static void mps2_common_init(MachineState *machine)qdev_connect_gpio_out (txrx_orgate_dev,0 ,qdev_get_gpio_in (armv7m, uart_txrx_irqno[i])); - dev =qdev_new (TYPE_CMSDK_APB_UART ); + dev =qdev_new_orphan (TYPE_CMSDK_APB_UART ); s =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" ,serial_hd (i));qdev_prop_set_uint32 (dev,"pclk-frq" ,SYSCLK_FRQ );
hw/arm/msf2-som.c +2 -2
@@ -59,7 +59,7 @@ static void emcraft_sf2_s2s010_init(MachineState *machine) &error_fatal);memory_region_add_subregion (sysmem,DDR_BASE_ADDRESS , ddr); - dev =qdev_new (TYPE_MSF2_SOC ); + dev =qdev_new_orphan (TYPE_MSF2_SOC );object_property_add_child (OBJECT (machine),"soc" ,OBJECT (dev));qdev_prop_set_string (dev,"part-name" ,"M2S010" );qdev_prop_set_uint64 (dev,"eNVM-size" ,M2S010_ENVM_SIZE );
@@ -83,7 +83,7 @@ static void emcraft_sf2_s2s010_init(MachineState *machine)/* Attach SPI flash to SPI0 controller */ spi_bus =qdev_get_child_bus (dev,"spi0" ); - spi_flash =qdev_new ("s25sl12801" );/* Spansion S25FL128SDPBHICO */ + spi_flash =qdev_new_orphan ("s25sl12801" );/* Spansion S25FL128SDPBHICO */ qdev_prop_set_uint8 (spi_flash,"spansion-cr2nv" ,0x8 );if (dinfo) { qdev_prop_set_drive_err(spi_flash, "drive",
hw/arm/musicpal.c +3 -3
@@ -1249,7 +1249,7 @@ static void musicpal_init(MachineState *machine) qdev_get_gpio_in(pic, MP_TIMER4_IRQ), NULL);/* Logically OR both UART IRQs together */ - uart_orgate =qdev_new (TYPE_OR_IRQ ); + uart_orgate =qdev_new_orphan (TYPE_OR_IRQ );object_property_set_int (OBJECT (uart_orgate),"num-lines" ,2 , &error_fatal);qdev_realize_and_unref (uart_orgate,NULL , &error_fatal); qdev_connect_gpio_out(uart_orgate, 0,
@@ -1288,7 +1288,7 @@ static void musicpal_init(MachineState *machine) }sysbus_create_simple (TYPE_MV88W8618_FLASHCFG ,MP_FLASHCFG_BASE ,NULL ); - dev =qdev_new (TYPE_MV88W8618_ETH ); + dev =qdev_new_orphan (TYPE_MV88W8618_ETH );qemu_configure_nic_device (dev, true,"mv88w8618" );object_property_set_link (OBJECT (dev),"dma-memory" ,OBJECT (get_system_memory ()), &error_fatal);
@@ -1333,7 +1333,7 @@ static void musicpal_init(MachineState *machine) }i2c_slave_realize_and_unref (wm8750_dev, i2c, &error_abort); - dev =qdev_new (TYPE_MV88W8618_AUDIO ); + dev =qdev_new_orphan (TYPE_MV88W8618_AUDIO ); s =SYS_BUS_DEVICE (dev);object_property_set_link (OBJECT (dev),"wm8750" ,OBJECT (wm8750_dev),NULL );
hw/arm/netduino2.c +1 -1
@@ -44,7 +44,7 @@ static void netduino2_init(MachineState *machine) sysclk =clock_new (OBJECT (machine),"SYSCLK" );clock_set_hz (sysclk,SYSCLK_FRQ ); - dev =qdev_new (TYPE_STM32F205_SOC ); + dev =qdev_new_orphan (TYPE_STM32F205_SOC );object_property_add_child (OBJECT (machine),"soc" ,OBJECT (dev));qdev_connect_clock_in (dev,"sysclk" , sysclk);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/arm/netduinoplus2.c +1 -1
@@ -44,7 +44,7 @@ static void netduinoplus2_init(MachineState *machine) sysclk =clock_new (OBJECT (machine),"SYSCLK" );clock_set_hz (sysclk,SYSCLK_FRQ ); - dev =qdev_new (TYPE_STM32F405_SOC ); + dev =qdev_new_orphan (TYPE_STM32F405_SOC );object_property_add_child (OBJECT (machine),"soc" ,OBJECT (dev));qdev_connect_clock_in (dev,"sysclk" , sysclk);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/arm/npcm7xx_boards.c +2 -2
@@ -84,7 +84,7 @@ static void npcm7xx_connect_flash(NPCM7xxFIUState *fiu, int cs_no,DeviceState *flash;qemu_irq flash_cs; - flash =qdev_new (flash_type); + flash =qdev_new_orphan (flash_type);if (dinfo) {qdev_prop_set_drive (flash,"drive" ,blk_by_legacy_dinfo (dinfo)); }
@@ -113,7 +113,7 @@ static void sdhci_attach_drive(SDHCIState *sdhci, int unit)exit (1 ); } -DeviceState *carddev =qdev_new (TYPE_SD_CARD ); +DeviceState *carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal); }
hw/arm/npcm8xx_boards.c +1 -1
@@ -61,7 +61,7 @@ static void npcm8xx_connect_flash(NPCM7xxFIUState *fiu, int cs_no,DeviceState *flash;qemu_irq flash_cs; - flash =qdev_new (flash_type); + flash =qdev_new_orphan (flash_type);if (dinfo) {qdev_prop_set_drive (flash,"drive" ,blk_by_legacy_dinfo (dinfo)); }
hw/arm/olimex-stm32-h405.c +1 -1
@@ -47,7 +47,7 @@ static void olimex_stm32_h405_init(MachineState *machine) sysclk =clock_new (OBJECT (machine),"SYSCLK" );clock_set_hz (sysclk,SYSCLK_FRQ ); - dev =qdev_new (TYPE_STM32F405_SOC ); + dev =qdev_new_orphan (TYPE_STM32F405_SOC );object_property_add_child (OBJECT (machine),"soc" ,OBJECT (dev));qdev_connect_clock_in (dev,"sysclk" , sysclk);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/arm/omap1.c +6 -6
@@ -3763,7 +3763,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram,omap_clkm_init (system_memory,0xfffece00 ,0xe1008000 , s); - s->ih[0 ] =qdev_new ("omap-intc" ); + s->ih[0 ] =qdev_new_orphan ("omap-intc" );qdev_prop_set_uint32 (s->ih[0 ],"size" ,0x100 );omap_intc_set_iclk (OMAP_INTC (s->ih[0 ]),omap_findclk (s,"arminth_ck" )); busdev =SYS_BUS_DEVICE (s->ih[0 ]);
@@ -3773,7 +3773,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram,sysbus_connect_irq (busdev,1 ,qdev_get_gpio_in (DEVICE (s->cpu),ARM_CPU_FIQ ));sysbus_mmio_map (busdev,0 ,0xfffecb00 ); - s->ih[1 ] =qdev_new ("omap-intc" ); + s->ih[1 ] =qdev_new_orphan ("omap-intc" );qdev_prop_set_uint32 (s->ih[1 ],"size" ,0x800 );omap_intc_set_iclk (OMAP_INTC (s->ih[1 ]),omap_findclk (s,"arminth_ck" )); busdev =SYS_BUS_DEVICE (s->ih[1 ]);
@@ -3876,7 +3876,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram,warn_report ("missing SecureDigital device" ); } - s->mmc =qdev_new (TYPE_OMAP_MMC ); + s->mmc =qdev_new_orphan (TYPE_OMAP_MMC );sysbus_realize_and_unref (SYS_BUS_DEVICE (s->mmc), &error_fatal);omap_mmc_set_clk (s->mmc,omap_findclk (s,"mmc_ck" ));
@@ -3888,7 +3888,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram, qdev_get_gpio_in(s->ih[1], OMAP_INT_OQN));if (dinfo) { -DeviceState *card =qdev_new (TYPE_SD_CARD ); +DeviceState *card =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (card,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal); qdev_realize_and_unref(card, qdev_get_child_bus(s->mmc, "sd-bus"),
@@ -3900,7 +3900,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram,qdev_get_gpio_in (s->ih[1 ],OMAP_INT_MPUIO ), omap_findclk(s, "clk32-kHz")); - s->gpio =qdev_new ("omap-gpio" ); + s->gpio =qdev_new_orphan ("omap-gpio" );omap_gpio_set_clk (OMAP1_GPIO (s->gpio),omap_findclk (s,"arm_gpio_ck" ));sysbus_realize_and_unref (SYS_BUS_DEVICE (s->gpio), &error_fatal); sysbus_connect_irq(SYS_BUS_DEVICE(s->gpio), 0,
@@ -3917,7 +3917,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram, s->pwt =omap_pwt_init (system_memory,0xfffb6000 ,omap_findclk (s,"armxor_ck" )); - s->i2c[0 ] =qdev_new ("omap_i2c" ); + s->i2c[0 ] =qdev_new_orphan ("omap_i2c" );qdev_prop_set_uint8 (s->i2c[0 ],"revision" ,0x11 );omap_i2c_set_fclk (OMAP_I2C (s->i2c[0 ]),omap_findclk (s,"mpuper_ck" )); busdev =SYS_BUS_DEVICE (s->i2c[0 ]);
hw/arm/orangepi.c +1 -1
@@ -85,7 +85,7 @@ static void orangepi_init(MachineState *machine) bus =qdev_get_child_bus (DEVICE (h3),"sd-bus" );/* Plug in SD card */ - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal);
hw/arm/raspi.c +1 -1
@@ -283,7 +283,7 @@ void raspi_base_machine_init(MachineState *machine,error_report ("No SD bus found in SOC object" );exit (1 ); } - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal);
hw/arm/realview.c +9 -9
@@ -61,7 +61,7 @@ static const int realview_board_id[] = {static void split_irq_from_named (DeviceState *src,const char * outname,qemu_irq out1,qemu_irq out2) { -DeviceState *splitter =qdev_new (TYPE_SPLIT_IRQ ); +DeviceState *splitter =qdev_new_orphan (TYPE_SPLIT_IRQ );qdev_prop_set_uint32 (splitter,"num-lines" ,2 );
@@ -180,7 +180,7 @@ static void realview_init(MachineState *machine, } sys_id = is_pb ?0x01780500 :0xc1400400 ; - sysctl =qdev_new ("realview_sysctl" ); + sysctl =qdev_new_orphan ("realview_sysctl" );qdev_prop_set_uint32 (sysctl,"sys_id" , sys_id);qdev_prop_set_uint32 (sysctl,"proc_id" , proc_id);sysbus_realize_and_unref (SYS_BUS_DEVICE (sysctl), &error_fatal);
@@ -188,10 +188,10 @@ static void realview_init(MachineState *machine,if (is_mpcore) {if (is_pb) { - dev =qdev_new (TYPE_A9MPCORE_PRIV ); + dev =qdev_new_orphan (TYPE_A9MPCORE_PRIV );qdev_prop_set_uint32 (dev,"num-irq" ,GIC_EXT_IRQS +GIC_INTERNAL ); }else { - dev =qdev_new ("realview_mpcore" ); + dev =qdev_new_orphan ("realview_mpcore" ); }qdev_prop_set_uint32 (dev,"num-cpu" , smp_cpus); busdev =SYS_BUS_DEVICE (dev);
@@ -212,7 +212,7 @@ static void realview_init(MachineState *machine, pic[n] =qdev_get_gpio_in (dev, n); } - pl041 =qdev_new ("pl041" ); + pl041 =qdev_new_orphan ("pl041" );qdev_prop_set_uint32 (pl041,"nc_fifo_depth" ,512 );if (machine->audiodev) {qdev_prop_set_string (pl041,"audiodev" , machine->audiodev);
@@ -230,7 +230,7 @@ static void realview_init(MachineState *machine,pl011_create (0x1000c000 , pic[15 ],serial_hd (3 ));/* DMA controller is optional, apparently. */ - dev =qdev_new ("pl081" ); + dev =qdev_new_orphan ("pl081" );object_property_set_link (OBJECT (dev),"downstream" ,OBJECT (sysmem), &error_fatal); busdev =SYS_BUS_DEVICE (dev);
@@ -245,7 +245,7 @@ static void realview_init(MachineState *machine,sysbus_create_simple ("pl061" ,0x10014000 , pic[7 ]); gpio2 =sysbus_create_simple ("pl061" ,0x10015000 , pic[8 ]); - dev =qdev_new ("pl111" ); + dev =qdev_new_orphan ("pl111" );object_property_set_link (OBJECT (dev),"framebuffer-memory" ,OBJECT (sysmem), &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -271,7 +271,7 @@ static void realview_init(MachineState *machine,if (dinfo) {DeviceState *card; - card =qdev_new (TYPE_SD_CARD ); + card =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (card,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal); qdev_realize_and_unref(card, qdev_get_child_bus(dev, "sd-bus"),
@@ -281,7 +281,7 @@ static void realview_init(MachineState *machine,sysbus_create_simple ("pl031" ,0x10017000 , pic[10 ]);if (!is_pb) { - dev =qdev_new ("realview_pci" ); + dev =qdev_new_orphan ("realview_pci" ); busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal);sysbus_mmio_map (busdev,0 ,0x10019000 );/* PCI controller registers */
hw/arm/sabrelite.c +1 -1
@@ -96,7 +96,7 @@ static void sabrelite_init(MachineState *machine)qemu_irq cs_line;DriveInfo *dinfo =drive_get (IF_MTD ,0 ,0 ); - flash_dev =qdev_new ("sst25vf016b" ); + flash_dev =qdev_new_orphan ("sst25vf016b" );if (dinfo) { qdev_prop_set_drive_err(flash_dev, "drive", blk_by_legacy_dinfo(dinfo),
hw/arm/sbsa-ref.c +10 -10
@@ -296,7 +296,7 @@ static PFlashCFI01 *sbsa_flash_create1(SBSAMachineState *sms,* Create a single flash device. We use the same parameters as * the flash devices on the Versatile Express board. */ -DeviceState *dev =qdev_new (TYPE_PFLASH_CFI01 ); +DeviceState *dev =qdev_new_orphan (TYPE_PFLASH_CFI01 );qdev_prop_set_uint64 (dev,"sector-length" ,SBSA_FLASH_SECTOR_SIZE );qdev_prop_set_uint8 (dev,"width" ,4 );
@@ -421,7 +421,7 @@ static void create_its(SBSAMachineState *sms)const char *itsclass =its_class_name ();DeviceState *dev; - dev =qdev_new (itsclass); + dev =qdev_new_orphan (itsclass);object_property_set_link (OBJECT (dev),"parent-gicv3" ,OBJECT (sms->gic), &error_abort);
@@ -440,7 +440,7 @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem) gictype =gicv3_class_name (); - sms->gic =qdev_new (gictype); + sms->gic =qdev_new_orphan (gictype);qdev_prop_set_uint32 (sms->gic,"revision" ,3 );qdev_prop_set_uint32 (sms->gic,"num-cpu" , smp_cpus);/*
@@ -522,7 +522,7 @@ static void create_uart(const SBSAMachineState *sms, int uart, {hwaddr base = sbsa_ref_memmap[uart].base;int irq = sbsa_ref_irqmap[uart]; -DeviceState *dev =qdev_new (TYPE_PL011 ); +DeviceState *dev =qdev_new_orphan (TYPE_PL011 );SysBusDevice *s =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" , chr);
@@ -544,7 +544,7 @@ static void create_wdt(const SBSAMachineState *sms) {hwaddr rbase = sbsa_ref_memmap[SBSA_GWDT_REFRESH ].base;hwaddr cbase = sbsa_ref_memmap[SBSA_GWDT_CONTROL ].base; -DeviceState *dev =qdev_new (TYPE_WDT_SBSA ); +DeviceState *dev =qdev_new_orphan (TYPE_WDT_SBSA );SysBusDevice *s =SYS_BUS_DEVICE (dev);int irq = sbsa_ref_irqmap[SBSA_GWDT_WS0 ];
@@ -590,7 +590,7 @@ static void create_ahci(const SBSAMachineState *sms)DriveInfo *hd[NUM_SATA_PORTS ];SysbusAHCIState *sysahci; - dev =qdev_new ("sysbus-ahci" ); + dev =qdev_new_orphan ("sysbus-ahci" );qdev_prop_set_uint32 (dev,"num-ports" ,NUM_SATA_PORTS );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , base);
@@ -605,7 +605,7 @@ static void create_xhci(const SBSAMachineState *sms) {hwaddr base = sbsa_ref_memmap[SBSA_XHCI ].base;int irq = sbsa_ref_irqmap[SBSA_XHCI ]; -DeviceState *dev =qdev_new (TYPE_XHCI_SYSBUS ); +DeviceState *dev =qdev_new_orphan (TYPE_XHCI_SYSBUS );qdev_prop_set_uint32 (dev,"slots" ,XHCI_MAXSLOTS );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -622,7 +622,7 @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus,DeviceState *dev;int i; - dev =qdev_new (TYPE_ARM_SMMUV3 ); + dev =qdev_new_orphan (TYPE_ARM_SMMUV3 );object_property_set_str (OBJECT (dev),"stage" ,"nested" , &error_abort); object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus),
@@ -658,7 +658,7 @@ static void create_pcie(SBSAMachineState *sms,PCIHostState *pci;int i; - dev =qdev_new (TYPE_GPEX_HOST ); + dev =qdev_new_orphan (TYPE_GPEX_HOST );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);/* Map ECAM space */
@@ -712,7 +712,7 @@ static void *sbsa_ref_dtb(const struct arm_boot_info *binfo, int *fdt_size)static void create_secure_ec (MemoryRegion *mem) {hwaddr base = sbsa_ref_memmap[SBSA_SECURE_EC ].base; -DeviceState *dev =qdev_new ("sbsa-ec" ); +DeviceState *dev =qdev_new_orphan ("sbsa-ec" );SysBusDevice *s =SYS_BUS_DEVICE (dev); memory_region_add_subregion(mem, base,
hw/arm/stellaris.c +10 -10
@@ -1096,7 +1096,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)* Create the system-registers object early, because we will * need its sysclk output. */ - ssys_dev =qdev_new (TYPE_STELLARIS_SYS ); + ssys_dev =qdev_new_orphan (TYPE_STELLARIS_SYS );object_property_add_child (soc_container,"sys" ,OBJECT (ssys_dev));/*
@@ -1123,7 +1123,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)qdev_prop_set_uint32 (ssys_dev,"dc4" , board->dc4);sysbus_realize_and_unref (SYS_BUS_DEVICE (ssys_dev), &error_fatal); - armv7m =qdev_new (TYPE_ARMV7M ); + armv7m =qdev_new_orphan (TYPE_ARMV7M );object_property_add_child (soc_container,"v7m" ,OBJECT (armv7m));qdev_prop_set_uint32 (armv7m,"num-irq" ,NUM_IRQ_LINES );qdev_prop_set_uint8 (armv7m,"num-prio-bits" ,NUM_PRIO_BITS );
@@ -1157,7 +1157,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)if (DEV_CAP (2 ,GPTM (i))) {SysBusDevice *sbd; - dev =qdev_new (TYPE_STELLARIS_GPTM ); + dev =qdev_new_orphan (TYPE_STELLARIS_GPTM ); sbd =SYS_BUS_DEVICE (dev);object_property_add_child (soc_container,"gptm[*]" ,OBJECT (dev)); qdev_connect_clock_in(dev, "clk",
@@ -1172,7 +1172,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) }if (DEV_CAP (1 ,WDT )) { - dev =qdev_new (TYPE_LUMINARY_WATCHDOG ); + dev =qdev_new_orphan (TYPE_LUMINARY_WATCHDOG );object_property_add_child (soc_container,"wdg" ,OBJECT (dev));qdev_connect_clock_in (dev,"WDOGCLK" ,qdev_get_clock_out (ssys_dev,"SYSCLK" ));
@@ -1216,7 +1216,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)if (DEV_CAP (2 ,UART (i))) {SysBusDevice *sbd; - dev =qdev_new ("pl011_luminary" ); + dev =qdev_new_orphan ("pl011_luminary" );object_property_add_child (soc_container,"uart[*]" ,OBJECT (dev)); sbd =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" ,serial_hd (i));
@@ -1304,18 +1304,18 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) dinfo =drive_get (IF_SD ,0 ,0 ); blk = dinfo ?blk_by_legacy_dinfo (dinfo) :NULL ; - carddev =qdev_new (TYPE_SD_CARD_SPI ); + carddev =qdev_new_orphan (TYPE_SD_CARD_SPI );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev,qdev_get_child_bus (sddev,"sd-bus" ), &error_fatal); - ssddev =qdev_new ("ssd0323" ); + ssddev =qdev_new_orphan ("ssd0323" );object_property_add_child (OBJECT (ms),"oled" ,OBJECT (ssddev));qdev_prop_set_uint8 (ssddev,"cs" ,1 );qdev_realize_and_unref (ssddev, bus, &error_fatal); - gpio_d_splitter =qdev_new (TYPE_SPLIT_IRQ ); + gpio_d_splitter =qdev_new_orphan (TYPE_SPLIT_IRQ );object_property_add_child (OBJECT (ms),"splitter" ,OBJECT (gpio_d_splitter));qdev_prop_set_uint32 (gpio_d_splitter,"num-lines" ,2 );
@@ -1337,7 +1337,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)if (DEV_CAP (4 ,EMAC )) {DeviceState *enet; - enet =qdev_new ("stellaris_enet" ); + enet =qdev_new_orphan ("stellaris_enet" );object_property_add_child (soc_container,"enet" ,OBJECT (enet));if (nd) {qdev_set_nic_properties (enet, nd);
@@ -1357,7 +1357,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) };DeviceState *gpad; - gpad =qdev_new (TYPE_STELLARIS_GAMEPAD ); + gpad =qdev_new_orphan (TYPE_STELLARIS_GAMEPAD );object_property_add_child (OBJECT (ms),"gamepad" ,OBJECT (gpad));for (i =0 ; i <ARRAY_SIZE (gpad_keycode); i++) {qlist_append_int (gpad_keycode_list, gpad_keycode[i]);
hw/arm/stm32vldiscovery.c +1 -1
@@ -47,7 +47,7 @@ static void stm32vldiscovery_init(MachineState *machine) sysclk =clock_new (OBJECT (machine),"SYSCLK" );clock_set_hz (sysclk,SYSCLK_FRQ ); - dev =qdev_new (TYPE_STM32F100_SOC ); + dev =qdev_new_orphan (TYPE_STM32F100_SOC );object_property_add_child (OBJECT (machine),"soc" ,OBJECT (dev));qdev_connect_clock_in (dev,"sysclk" , sysclk);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/arm/strongarm.c +2 -2
@@ -646,7 +646,7 @@ static DeviceState *strongarm_gpio_init(hwaddr base,DeviceState *dev;int i; - dev =qdev_new (TYPE_STRONGARM_GPIO ); + dev =qdev_new_orphan (TYPE_STRONGARM_GPIO );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , base);
@@ -1642,7 +1642,7 @@ StrongARMState *sa1110_init(const char *cpu_type) s->ppc =sysbus_create_varargs (TYPE_STRONGARM_PPC ,0x90060000 ,NULL );for (i =0 ; sa_serial[i].io_base; i++) { -DeviceState *dev =qdev_new (TYPE_STRONGARM_UART ); +DeviceState *dev =qdev_new_orphan (TYPE_STRONGARM_UART );qdev_prop_set_chr (dev,"chardev" ,serial_hd (i));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,
hw/arm/versatilepb.c +7 -7
@@ -226,7 +226,7 @@ static void versatile_init(MachineState *machine, int board_id)/* SDRAM at address zero. */ memory_region_add_subregion (sysmem,0 , machine->ram); - sysctl =qdev_new ("realview_sysctl" ); + sysctl =qdev_new_orphan ("realview_sysctl" );qdev_prop_set_uint32 (sysctl,"sys_id" ,0x41007004 );qdev_prop_set_uint32 (sysctl,"proc_id" ,0x02000000 );sysbus_realize_and_unref (SYS_BUS_DEVICE (sysctl), &error_fatal);
@@ -248,7 +248,7 @@ static void versatile_init(MachineState *machine, int board_id)sysbus_create_simple ("pl050_keyboard" ,0x10006000 , sic[3 ]);sysbus_create_simple ("pl050_mouse" ,0x10007000 , sic[4 ]); - dev =qdev_new ("versatile_pci" ); + dev =qdev_new_orphan ("versatile_pci" ); busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal);sysbus_mmio_map (busdev,0 ,0x10001000 );/* PCI controller regs */
@@ -284,7 +284,7 @@ static void versatile_init(MachineState *machine, int board_id)pl011_create (0x101f3000 , pic[14 ],serial_hd (2 ));pl011_create (0x10009000 , sic[6 ],serial_hd (3 )); - dev =qdev_new ("pl080" ); + dev =qdev_new_orphan ("pl080" );object_property_set_link (OBJECT (dev),"downstream" ,OBJECT (sysmem), &error_fatal); busdev =SYS_BUS_DEVICE (dev);
@@ -302,7 +302,7 @@ static void versatile_init(MachineState *machine, int board_id)/* The versatile/PB actually has a modified Color LCD controller that includes hardware cursor support from the PL111. */ - dev =qdev_new ("pl110_versatile" ); + dev =qdev_new_orphan ("pl110_versatile" );object_property_set_link (OBJECT (dev),"framebuffer-memory" ,OBJECT (sysmem), &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -317,7 +317,7 @@ static void versatile_init(MachineState *machine, int board_id)if (dinfo) {DeviceState *card; - card =qdev_new (TYPE_SD_CARD ); + card =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (card,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal); qdev_realize_and_unref(card, qdev_get_child_bus(dev, "sd-bus"),
@@ -329,7 +329,7 @@ static void versatile_init(MachineState *machine, int board_id)if (dinfo) {DeviceState *card; - card =qdev_new (TYPE_SD_CARD ); + card =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (card,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal); qdev_realize_and_unref(card, qdev_get_child_bus(dev, "sd-bus"),
@@ -344,7 +344,7 @@ static void versatile_init(MachineState *machine, int board_id)i2c_slave_create_simple (i2c,"ds1338" ,0x68 );/* Add PL041 AACI Interface to the LM4549 codec */ - pl041 =qdev_new ("pl041" ); + pl041 =qdev_new_orphan ("pl041" );qdev_prop_set_uint32 (pl041,"nc_fifo_depth" ,512 );if (machine->audiodev) {qdev_prop_set_string (pl041,"audiodev" , machine->audiodev);
hw/arm/vexpress.c +7 -7
@@ -241,7 +241,7 @@ static void init_cpus(MachineState *ms, const char *cpu_type,* this must happen after the CPUs are created because a15mpcore_priv * wires itself up to the CPU's generic_timer gpio out lines. */ - dev =qdev_new (privdev); + dev =qdev_new_orphan (privdev);qdev_prop_set_uint32 (dev,"num-cpu" , smp_cpus);qdev_prop_set_uint32 (dev,"num-irq" ,GIC_EXT_IRQS +GIC_INTERNAL ); busdev =SYS_BUS_DEVICE (dev);
@@ -301,7 +301,7 @@ static void a9_daughterboard_init(VexpressMachineState *vms,/* Daughterboard peripherals : 0x10020000 .. 0x20000000 */ /* 0x10020000 PL111 CLCD (daughterboard) */ - dev =qdev_new ("pl111" ); + dev =qdev_new_orphan ("pl111" );object_property_set_link (OBJECT (dev),"framebuffer-memory" ,OBJECT (sysmem), &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -517,7 +517,7 @@ static void vexpress_modify_dtb(const struct arm_boot_info *info, void *fdt)static PFlashCFI01 *ve_pflash_cfi01_register (hwaddr base,const char *name,DriveInfo *di) { -DeviceState *dev =qdev_new (TYPE_PFLASH_CFI01 ); +DeviceState *dev =qdev_new_orphan (TYPE_PFLASH_CFI01 );if (di) {qdev_prop_set_drive (dev,"drive" ,blk_by_legacy_dinfo (di));
@@ -592,7 +592,7 @@ static void vexpress_common_init(MachineState *machine) sys_id =0x1190f500 ; - sysctl =qdev_new ("realview_sysctl" ); + sysctl =qdev_new_orphan ("realview_sysctl" );qdev_prop_set_uint32 (sysctl,"sys_id" , sys_id);qdev_prop_set_uint32 (sysctl,"proc_id" , daughterboard->proc_id);
@@ -614,7 +614,7 @@ static void vexpress_common_init(MachineState *machine)/* VE_SP810: not modelled */ /* VE_SERIALPCI: not modelled */ - pl041 =qdev_new ("pl041" ); + pl041 =qdev_new_orphan ("pl041" );qdev_prop_set_uint32 (pl041,"nc_fifo_depth" ,512 );if (machine->audiodev) {qdev_prop_set_string (pl041,"audiodev" , machine->audiodev);
@@ -633,7 +633,7 @@ static void vexpress_common_init(MachineState *machine)if (dinfo) {DeviceState *card; - card =qdev_new (TYPE_SD_CARD ); + card =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (card,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal); qdev_realize_and_unref(card, qdev_get_child_bus(dev, "sd-bus"),
@@ -659,7 +659,7 @@ static void vexpress_common_init(MachineState *machine)/* VE_COMPACTFLASH: not modelled */ - dev =qdev_new ("pl111" ); + dev =qdev_new_orphan ("pl111" );object_property_set_link (OBJECT (dev),"framebuffer-memory" ,OBJECT (sysmem), &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/arm/virt.c +12 -12
@@ -1082,7 +1082,7 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms) event |=ACPI_GED_NVDIMM_HOTPLUG_EVT ; } - dev =qdev_new (TYPE_ACPI_GED ); + dev =qdev_new_orphan (TYPE_ACPI_GED );qdev_prop_set_uint32 (dev,"ged-event" , event);object_property_set_link (OBJECT (dev),"bus" ,OBJECT (vms->bus), &error_abort); sbdev =SYS_BUS_DEVICE (dev);
@@ -1120,7 +1120,7 @@ static void create_its(VirtMachineState *vms)return ; } - dev =qdev_new (its_class_name ()); + dev =qdev_new_orphan (its_class_name ());object_property_set_link (OBJECT (dev),"parent-gicv3" ,OBJECT (vms->gic), &error_abort);
@@ -1137,7 +1137,7 @@ static void create_v2m(VirtMachineState *vms)int irq = vms->irqmap[VIRT_GIC_V2M ];DeviceState *dev; - dev =qdev_new ("arm-gicv2m" ); + dev =qdev_new_orphan ("arm-gicv2m" );qdev_prop_set_uint32 (dev,"base-spi" , irq);qdev_prop_set_uint32 (dev,"num-spi" ,NUM_GICV2M_SPIS );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -1225,7 +1225,7 @@ static void create_gicv5(VirtMachineState *vms, MemoryRegion *mem)const char *gictype =gicv5_class_name ();QList *cpulist =qlist_new (), *iaffidlist =qlist_new (); - vms->gic =qdev_new (gictype); + vms->gic =qdev_new_orphan (gictype);qdev_prop_set_uint32 (vms->gic,"spi-range" ,NUM_IRQS ); object_property_set_link(OBJECT(vms->gic), "sysmem", OBJECT(mem),
@@ -1356,7 +1356,7 @@ static void create_gicv2(VirtMachineState *vms, MemoryRegion *mem)exit (1 ); } - vms->gic =qdev_new (gic_class_name ()); + vms->gic =qdev_new_orphan (gic_class_name ());qdev_prop_set_uint32 (vms->gic,"revision" ,2 );qdev_prop_set_uint32 (vms->gic,"num-cpu" , smp_cpus);/*
@@ -1412,7 +1412,7 @@ static void create_gicv3(VirtMachineState *vms, MemoryRegion *mem)exit (1 ); } - vms->gic =qdev_new (gicv3_class_name ()); + vms->gic =qdev_new_orphan (gicv3_class_name ());qdev_prop_set_uint32 (vms->gic,"revision" , revision);qdev_prop_set_uint32 (vms->gic,"num-cpu" , smp_cpus);/*
@@ -1509,7 +1509,7 @@ static void create_uart(const VirtMachineState *vms, int uart,int irq = vms->irqmap[uart];const char compat[] ="arm,pl011\0arm,primecell" ;const char clocknames[] ="uartclk\0apb_pclk" ; -DeviceState *dev =qdev_new (TYPE_PL011 ); +DeviceState *dev =qdev_new_orphan (TYPE_PL011 );SysBusDevice *s =SYS_BUS_DEVICE (dev);MachineState *ms =MACHINE (vms);
@@ -1670,7 +1670,7 @@ static void create_gpio_devices(const VirtMachineState *vms, int gpio,SysBusDevice *s;MachineState *ms =MACHINE (vms); - pl061_dev =qdev_new ("pl061" ); + pl061_dev =qdev_new_orphan ("pl061" );/* Pull lines down to 0 if not driven by the PL061 */ qdev_prop_set_uint8 (pl061_dev,"pullups" ,0 );qdev_prop_set_uint8 (pl061_dev,"pulldowns" ,0xff );
@@ -1786,7 +1786,7 @@ static PFlashCFI01 *virt_flash_create1(VirtMachineState *vms,* Create a single flash device. We use the same parameters as * the flash devices on the Versatile Express board. */ -DeviceState *dev =qdev_new (TYPE_PFLASH_CFI01 ); +DeviceState *dev =qdev_new_orphan (TYPE_PFLASH_CFI01 );qdev_prop_set_uint64 (dev,"sector-length" ,VIRT_FLASH_SECTOR_SIZE );qdev_prop_set_uint8 (dev,"width" ,4 );
@@ -2069,7 +2069,7 @@ static void create_smmu(const VirtMachineState *vms, PCIBus *bus)return ; } - dev =qdev_new (TYPE_ARM_SMMUV3 ); + dev =qdev_new_orphan (TYPE_ARM_SMMUV3 );if (!vmc->no_nested_smmu) {object_property_set_str (OBJECT (dev),"stage" ,"nested" , &error_fatal);
@@ -2162,7 +2162,7 @@ static void create_pcie(VirtMachineState *vms)MachineState *ms =MACHINE (vms);MachineClass *mc =MACHINE_GET_CLASS (ms); - dev =qdev_new (TYPE_GPEX_HOST ); + dev =qdev_new_orphan (TYPE_GPEX_HOST );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); ecam_id =VIRT_ECAM_ID (vms->highmem_ecam);
@@ -2290,7 +2290,7 @@ static void create_platform_bus(VirtMachineState *vms)int i;MemoryRegion *sysmem =get_system_memory (); - dev =qdev_new (TYPE_PLATFORM_BUS_DEVICE ); + dev =qdev_new_orphan (TYPE_PLATFORM_BUS_DEVICE ); dev->id =g_strdup (TYPE_PLATFORM_BUS_DEVICE );qdev_prop_set_uint32 (dev,"num_irqs" ,PLATFORM_BUS_NUM_IRQS );qdev_prop_set_uint32 (dev,"mmio_size" , vms->memmap[VIRT_PLATFORM_BUS ].size);
hw/arm/xilinx_zynq.c +13 -13
@@ -110,7 +110,7 @@ static void gem_init(uint32_t base, qemu_irq irq)DeviceState *dev;SysBusDevice *s; - dev =qdev_new (TYPE_CADENCE_GEM ); + dev =qdev_new_orphan (TYPE_CADENCE_GEM );qemu_configure_nic_device (dev, true,NULL );object_property_set_int (OBJECT (dev),"phy-addr" ,7 , &error_abort); s =SYS_BUS_DEVICE (dev);
@@ -131,7 +131,7 @@ static inline int zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq,int num_busses = is_qspi ?NUM_QSPI_BUSSES :1 ;int num_ss = is_qspi ?NUM_QSPI_FLASHES :NUM_SPI_FLASHES ; - dev =qdev_new (is_qspi ?"xlnx.ps7-qspi" :"xlnx.ps7-spi" ); + dev =qdev_new_orphan (is_qspi ?"xlnx.ps7-qspi" :"xlnx.ps7-spi" );qdev_prop_set_uint8 (dev,"num-txrx-bytes" , is_qspi ?4 :1 );qdev_prop_set_uint8 (dev,"num-ss-bits" , num_ss);qdev_prop_set_uint8 (dev,"num-busses" , num_busses);
@@ -152,7 +152,7 @@ static inline int zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq,for (j =0 ; j < num_ss; ++j) {DriveInfo *dinfo =drive_get (IF_MTD ,0 , unit++); - flash_dev =qdev_new ("n25q128" ); + flash_dev =qdev_new_orphan ("n25q128" );if (dinfo) { qdev_prop_set_drive_err(flash_dev, "drive", blk_by_legacy_dinfo(dinfo),
@@ -195,7 +195,7 @@ static void ddr_ctrl_init(uint32_t base)DeviceState *dev;SysBusDevice *busdev; - dev =qdev_new ("zynq.ddr-ctlr" ); + dev =qdev_new_orphan ("zynq.ddr-ctlr" ); busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal);sysbus_mmio_map (busdev,0 , base);
@@ -256,13 +256,13 @@ static void zynq_init(MachineState *machine)clock_set_hz (zynq_machine->ps_clk,PS_CLK_FREQUENCY );/* Create slcr, keep a pointer to connect clocks */ - slcr =qdev_new ("xilinx-zynq_slcr" ); + slcr =qdev_new_orphan ("xilinx-zynq_slcr" );qdev_connect_clock_in (slcr,"ps_clk" , zynq_machine->ps_clk);qdev_prop_set_uint8 (slcr,"boot-mode" , zynq_machine->boot_mode);sysbus_realize_and_unref (SYS_BUS_DEVICE (slcr), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (slcr),0 ,0xF8000000 ); - dev =qdev_new (TYPE_A9MPCORE_PRIV ); + dev =qdev_new_orphan (TYPE_A9MPCORE_PRIV );qdev_prop_set_uint32 (dev,"num-cpu" , smp_cpus);qdev_prop_set_uint32 (dev,"num-irq" ,GIC_EXT_IRQS +GIC_INTERNAL ); busdev =SYS_BUS_DEVICE (dev);
@@ -290,7 +290,7 @@ static void zynq_init(MachineState *machine)sysbus_create_simple (TYPE_CHIPIDEA ,0xE0002000 , pic[53 -GIC_INTERNAL ]);sysbus_create_simple (TYPE_CHIPIDEA ,0xE0003000 , pic[76 -GIC_INTERNAL ]); - dev =qdev_new (TYPE_CADENCE_UART ); + dev =qdev_new_orphan (TYPE_CADENCE_UART ); busdev =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 )); qdev_connect_clock_in(dev, "refclk",
@@ -298,7 +298,7 @@ static void zynq_init(MachineState *machine)sysbus_realize_and_unref (busdev, &error_fatal);sysbus_mmio_map (busdev,0 ,0xE0000000 );sysbus_connect_irq (busdev,0 , pic[59 -GIC_INTERNAL ]); - dev =qdev_new (TYPE_CADENCE_UART ); + dev =qdev_new_orphan (TYPE_CADENCE_UART ); busdev =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" ,serial_hd (1 )); qdev_connect_clock_in(dev, "refclk",
@@ -329,7 +329,7 @@ static void zynq_init(MachineState *machine)* - SDIO Specification Version 2.0 * - MMC Specification Version 3.31 */ - dev =qdev_new (TYPE_SYSBUS_SDHCI ); + dev =qdev_new_orphan (TYPE_SYSBUS_SDHCI );qdev_prop_set_uint8 (dev,"sd-spec-version" ,2 );qdev_prop_set_uint64 (dev,"capareg" ,ZYNQ_SDHCI_CAPABILITIES );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -338,18 +338,18 @@ static void zynq_init(MachineState *machine) di =drive_get (IF_SD ,0 , n); blk = di ?blk_by_legacy_dinfo (di) :NULL ; - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev,qdev_get_child_bus (dev,"sd-bus" ), &error_fatal); } - dev =qdev_new (TYPE_ZYNQ_XADC ); + dev =qdev_new_orphan (TYPE_ZYNQ_XADC );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,0xF8007100 );sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , pic[39 -GIC_INTERNAL ]); - dev =qdev_new ("pl330" ); + dev =qdev_new_orphan ("pl330" );object_property_set_link (OBJECT (dev),"memory" ,OBJECT (address_space_mem), &error_fatal);
@@ -372,7 +372,7 @@ static void zynq_init(MachineState *machine)sysbus_connect_irq (busdev, n +1 , pic[dma_irqs[n] -GIC_INTERNAL ]); } - dev =qdev_new ("xlnx.ps7-dev-cfg" ); + dev =qdev_new_orphan ("xlnx.ps7-dev-cfg" ); busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal);sysbus_connect_irq (busdev,0 , pic[40 -GIC_INTERNAL ]);
hw/arm/xlnx-versal-virt.c +1 -1
@@ -143,7 +143,7 @@ static void create_virtio_regions(VersalVirt *s)qemu_irq pic_irq; pic_irq =versal_get_reserved_irq (&s->soc, i, &dtb_irq); - dev =qdev_new ("virtio-mmio" ); + dev =qdev_new_orphan ("virtio-mmio" );object_property_add_child (OBJECT (s),"virtio-mmio[*]" ,OBJECT (dev));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , pic_irq);
hw/arm/xlnx-versal.c +35 -35
259 lines not on this page · raw message
hw/arm/xlnx-zcu102.c +3 -3
@@ -187,7 +187,7 @@ static void xlnx_zcu102_init(MachineState *machine)error_report ("No SD bus found for SD card %d" , i);exit (1 ); } - carddev =qdev_new (TYPE_SD_CARD ); + carddev =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (carddev,"drive" , blk, &error_fatal);qdev_realize_and_unref (carddev, bus, &error_fatal); }
@@ -202,7 +202,7 @@ static void xlnx_zcu102_init(MachineState *machine) spi_bus =qdev_get_child_bus (DEVICE (&s->soc), bus_name);g_free (bus_name); - flash_dev =qdev_new ("sst25wf080" ); + flash_dev =qdev_new_orphan ("sst25wf080" );if (dinfo) {qdev_prop_set_drive_err (flash_dev,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal);
@@ -226,7 +226,7 @@ static void xlnx_zcu102_init(MachineState *machine) spi_bus =qdev_get_child_bus (DEVICE (&s->soc), bus_name);g_free (bus_name); - flash_dev =qdev_new ("n25q512a11" ); + flash_dev =qdev_new_orphan ("n25q512a11" );if (dinfo) {qdev_prop_set_drive_err (flash_dev,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal);
hw/arm/xlnx-zynqmp.c +1 -1
@@ -365,7 +365,7 @@ static void xlnx_zynqmp_create_unimp_mmio(XlnxZynqMPState *s)for (nr =0 ; nr <ARRAY_SIZE (unimp_areas); nr++) {const struct UnimpInfo *info = &unimp_areas[nr]; -DeviceState *dev =qdev_new (TYPE_UNIMPLEMENTED_DEVICE ); +DeviceState *dev =qdev_new_orphan (TYPE_UNIMPLEMENTED_DEVICE );SysBusDevice *sbd =SYS_BUS_DEVICE (dev);assert (info->name && info->base && info->size >0 );
hw/audio/intel-hda.c +1 -1
@@ -1313,7 +1313,7 @@ static void intel_hda_and_codec_init(const char *audiodev) intel_hda =qdev_device_add_from_qdict (props, false, &error_fatal); hdabus =QLIST_FIRST (&intel_hda->child_bus); - codec =qdev_new ("hda-duplex" ); + codec =qdev_new_orphan ("hda-duplex" );qdev_prop_set_string (codec,"audiodev" , audiodev);qdev_realize_and_unref (codec, hdabus, &error_fatal);object_unref (intel_hda);
hw/audio/model.c +1 -1
@@ -110,7 +110,7 @@ void audio_model_init(void) }if (c->typename) { -DeviceState *dev =qdev_new (c->typename); +DeviceState *dev =qdev_new_orphan (c->typename);BusState *bus =qdev_find_default_bus (DEVICE_GET_CLASS (dev), &error_fatal);qdev_prop_set_string (dev,"audiodev" , audiodev_id);qdev_realize_and_unref (dev, bus, &error_fatal);
hw/avr/atmega.c +1 -1
@@ -284,7 +284,7 @@ static void atmega_realize(DeviceState *dev, Error **errp)* 0x20 - 0x5f: I/O memory * 0x60 - 0xff: Extended I/O */ - s->io =qdev_new (TYPE_UNIMPLEMENTED_DEVICE ); + s->io =qdev_new_orphan (TYPE_UNIMPLEMENTED_DEVICE );qdev_prop_set_string (s->io,"name" ,"I/O" );qdev_prop_set_uint64 (s->io,"size" , mc->io_size);sysbus_realize_and_unref (SYS_BUS_DEVICE (s->io), &error_fatal);
hw/block/fdc-sysbus.c +2 -2
@@ -102,7 +102,7 @@ void fdctrl_init_sysbus(qemu_irq irq, hwaddr mmio_base, DriveInfo **fds)SysBusDevice *sbd;FDCtrlSysBus *sys; - dev =qdev_new ("sysbus-fdc" ); + dev =qdev_new_orphan ("sysbus-fdc" ); sys =SYSBUS_FDC (dev); sbd =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sbd, &error_fatal);
@@ -118,7 +118,7 @@ void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base,DeviceState *dev;FDCtrlSysBus *sys; - dev =qdev_new ("sun-fdtwo" ); + dev =qdev_new_orphan ("sun-fdtwo" );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); sys =SYSBUS_FDC (dev);sysbus_connect_irq (SYS_BUS_DEVICE (sys),0 , irq);
hw/block/fdc.c +1 -1
@@ -2329,7 +2329,7 @@ void fdctrl_init_drives(FloppyBus *bus, DriveInfo **fds)for (i =0 ; i <MAX_FD ; i++) {if (fds[i]) { - dev =qdev_new ("floppy" ); + dev =qdev_new_orphan ("floppy" );qdev_prop_set_uint32 (dev,"unit" , i);qdev_prop_set_enum (dev,"drive-type" ,FLOPPY_DRIVE_TYPE_AUTO ); qdev_prop_set_drive_err(dev, "drive", blk_by_legacy_dinfo(fds[i]),
hw/block/pflash_cfi01.c +1 -1
@@ -958,7 +958,7 @@ PFlashCFI01 *pflash_cfi01_register(hwaddr base, uint16_t id2, uint16_t id3, int be) { - DeviceState *dev = qdev_new(TYPE_PFLASH_CFI01); + DeviceState *dev = qdev_new_orphan(TYPE_PFLASH_CFI01);if (blk) {qdev_prop_set_drive (dev,"drive" , blk);
hw/block/pflash_cfi02.c +1 -1
@@ -1005,7 +1005,7 @@ PFlashCFI02 *pflash_cfi02_register(hwaddr base, uint16_t unlock_addr1, int be) { -DeviceState *dev =qdev_new (TYPE_PFLASH_CFI02 ); +DeviceState *dev =qdev_new_orphan (TYPE_PFLASH_CFI02 );if (blk) {qdev_prop_set_drive (dev,"drive" , blk);
hw/block/xen-block.c +1 -1
@@ -1074,7 +1074,7 @@ static void xen_block_device_create(XenBackendInstance *backend, goto fail; } - xendev =XEN_DEVICE (qdev_new (type)); + xendev =XEN_DEVICE (qdev_new_orphan (type)); blockdev =XEN_BLOCK_DEVICE (xendev); if (!object_property_set_str(OBJECT(xendev), "vdev", vdev,
hw/char/exynos4210_uart.c +1 -1
@@ -659,7 +659,7 @@ DeviceState *exynos4210_uart_create(hwaddr addr,DeviceState *dev;SysBusDevice *bus; - dev =qdev_new (TYPE_EXYNOS4210_UART ); + dev =qdev_new_orphan (TYPE_EXYNOS4210_UART );qdev_prop_set_chr (dev,"chardev" , chr);qdev_prop_set_uint32 (dev,"channel" , channel);
hw/char/mcf_uart.c +1 -1
@@ -351,7 +351,7 @@ DeviceState *mcf_uart_create(qemu_irq irq, Chardev *chrdrv) {DeviceState *dev; - dev =qdev_new (TYPE_MCF_UART ); + dev =qdev_new_orphan (TYPE_MCF_UART );if (chrdrv) {qdev_prop_set_chr (dev,"chardev" , chrdrv); }
hw/char/mchp_pfsoc_mmuart.c +1 -1
@@ -150,7 +150,7 @@ MchpPfSoCMMUartState *mchp_pfsoc_mmuart_create(MemoryRegion *sysmem,hwaddr base, qemu_irq irq, Chardev *chr) { - DeviceState *dev = qdev_new(TYPE_MCHP_PFSOC_UART); + DeviceState *dev = qdev_new_orphan(TYPE_MCHP_PFSOC_UART);SysBusDevice *sbd =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" , chr);
hw/char/pl011.c +1 -1
@@ -38,7 +38,7 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr)DeviceState *dev;SysBusDevice *s; - dev =qdev_new ("pl011" ); + dev =qdev_new_orphan ("pl011" ); s =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" , chr);sysbus_realize_and_unref (s, &error_fatal);
hw/char/serial-mm.c +1 -1
@@ -99,7 +99,7 @@ SerialMM *serial_mm_init(MemoryRegion *address_space, qemu_irq irq, int baudbase, Chardev *chr, enum device_endian end) { - SerialMM *smm = SERIAL_MM(qdev_new(TYPE_SERIAL_MM)); + SerialMM *smm = SERIAL_MM(qdev_new_orphan(TYPE_SERIAL_MM));MemoryRegion *mr;qdev_prop_set_uint8 (DEVICE (smm),"regshift" , regshift);
hw/char/sifive_uart.c +1 -1
@@ -399,7 +399,7 @@ SiFiveUARTState *sifive_uart_create(MemoryRegion *address_space, hwaddr base,DeviceState *dev;SysBusDevice *s; - dev =qdev_new ("riscv.sifive.uart" ); + dev =qdev_new_orphan ("riscv.sifive.uart" ); s =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" , chr);sysbus_realize_and_unref (s, &error_fatal);
hw/char/spapr_vty.c +1 -1
@@ -158,7 +158,7 @@ void spapr_vty_create(SpaprVioBus *bus, Chardev *chardev) {DeviceState *dev; - dev =qdev_new ("spapr-vty" ); + dev =qdev_new_orphan ("spapr-vty" );qdev_prop_set_chr (dev,"chardev" , chardev);qdev_realize_and_unref (dev, &bus->bus, &error_fatal); }
hw/char/xen_console.c +1 -1
@@ -562,7 +562,7 @@ static void xen_console_device_create(XenBackendInstance *backend, goto fail; } - xendev =XEN_DEVICE (qdev_new (TYPE_XEN_CONSOLE_DEVICE )); + xendev =XEN_DEVICE (qdev_new_orphan (TYPE_XEN_CONSOLE_DEVICE )); con =XEN_CONSOLE_DEVICE (xendev); con->dev = number;
hw/core/qdev.c +2 -2
@@ -145,12 +145,12 @@ bool qdev_set_parent_bus(DeviceState *dev, BusState *bus, Error **errp)return true; } -DeviceState *qdev_new (const char *name) +DeviceState *qdev_new_orphan (const char *name) {return DEVICE (object_new (name)); } -DeviceState *qdev_try_new (const char *name) +DeviceState *qdev_try_new_orphan (const char *name) {ObjectClass *oc =module_object_class_by_name (name);if (!oc) {
hw/core/sysbus.c +1 -1
@@ -218,7 +218,7 @@ DeviceState *sysbus_create_varargs(const char *name,qemu_irq irq;int n; - dev =qdev_new (name); + dev =qdev_new_orphan (name); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);if (addr != (hwaddr)-1 ) {
hw/cxl/cxl-host.c +1 -1
@@ -26,7 +26,7 @@ static void cxl_fixed_memory_window_config(CXLFixedMemoryWindowOptions *object, int index, Error **errp) {ERRP_GUARD (); -DeviceState *dev =qdev_new (TYPE_CXL_FMW ); +DeviceState *dev =qdev_new_orphan (TYPE_CXL_FMW );CXLFixedWindow *fw =CXL_FMW (dev);strList *target;int i;
hw/display/sm501.c +1 -1
@@ -1956,7 +1956,7 @@ static void sm501_init(SM501State *s, DeviceState *dev,/* i2c */ s->i2c_bus =i2c_init_bus (dev,"sm501.i2c" );/* ddc */ -I2CDDCState *ddc =I2CDDC (qdev_new (TYPE_I2CDDC )); +I2CDDCState *ddc =I2CDDC (qdev_new_orphan (TYPE_I2CDDC ));i2c_slave_set_address (I2C_SLAVE (ddc),0x50 );qdev_realize_and_unref (DEVICE (ddc),BUS (s->i2c_bus), &error_abort);
hw/display/xlnx_dp.c +2 -2
@@ -1346,11 +1346,11 @@ static void xlnx_dp_init(Object *obj)* child properties of this device, we can drop the reference we * hold to them, leaving the child-property as the only reference. */ - s->dpcd =DPCD (qdev_new ("dpcd" )); + s->dpcd =DPCD (qdev_new_orphan ("dpcd" ));object_property_add_child (OBJECT (s),"dpcd" ,OBJECT (s->dpcd));object_unref (s->dpcd); - s->edid =I2CDDC (qdev_new ("i2c-ddc" )); + s->edid =I2CDDC (qdev_new_orphan ("i2c-ddc" ));i2c_slave_set_address (I2C_SLAVE (s->edid),0x50 );object_property_add_child (OBJECT (s),"edid" ,OBJECT (s->edid));object_unref (s->edid);
hw/dma/rc4030.c +1 -1
@@ -747,7 +747,7 @@ DeviceState *rc4030_init(rc4030_dma **dmas, IOMMUMemoryRegion **dma_mr) {DeviceState *dev; - dev =qdev_new (TYPE_RC4030 ); + dev =qdev_new_orphan (TYPE_RC4030 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); *dmas =rc4030_allocate_dmas (dev,4 );
hw/hexagon/hexagon_dsp.c +2 -2
@@ -131,14 +131,14 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, machine->ram_size, &error_fatal);memory_region_add_subregion (address_space,0x0 , &hms->ram); - glob_regs_dev =qdev_new (TYPE_HEXAGON_GLOBALREG ); + glob_regs_dev =qdev_new_orphan (TYPE_HEXAGON_GLOBALREG );object_property_add_child (OBJECT (machine),"global-regs" ,OBJECT (glob_regs_dev));qdev_prop_set_uint64 (glob_regs_dev,"config-table-addr" , m_cfg->cfgbase);qdev_prop_set_uint32 (glob_regs_dev,"dsp-rev" , rev);sysbus_realize_and_unref (SYS_BUS_DEVICE (glob_regs_dev), &error_fatal); - tlb_dev =qdev_new (TYPE_HEXAGON_TLB ); + tlb_dev =qdev_new_orphan (TYPE_HEXAGON_TLB );object_property_add_child (OBJECT (machine),"tlb" ,OBJECT (tlb_dev));qdev_prop_set_uint32 (tlb_dev,"num-entries" , m_cfg->cfgtable.jtlb_size_entries);
hw/hexagon/virt.c +3 -3
@@ -129,7 +129,7 @@ static void fdt_add_uart(const HexagonVirtMachineState *vms, int uart,DeviceState *dev;SysBusDevice *s; - dev =qdev_new (TYPE_PL011 ); + dev =qdev_new_orphan (TYPE_PL011 ); s =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 ));qdev_connect_clock_in (dev,"clk" , vms->apb_clk);
@@ -268,13 +268,13 @@ static void virt_init(MachineState *ms) &vms->parent_obj.cfgtable_rom);fdt_add_hvx (vms, m_cfg); - gsregs_dev =qdev_new (TYPE_HEXAGON_GLOBALREG ); + gsregs_dev =qdev_new_orphan (TYPE_HEXAGON_GLOBALREG );object_property_add_child (OBJECT (ms),"global-regs" ,OBJECT (gsregs_dev));qdev_prop_set_uint64 (gsregs_dev,"config-table-addr" , m_cfg->cfgbase);qdev_prop_set_uint32 (gsregs_dev,"dsp-rev" , v68_rev);sysbus_realize_and_unref (SYS_BUS_DEVICE (gsregs_dev), &error_fatal); - tlb_dev =qdev_new (TYPE_HEXAGON_TLB ); + tlb_dev =qdev_new_orphan (TYPE_HEXAGON_TLB );object_property_add_child (OBJECT (ms),"tlb" ,OBJECT (tlb_dev));qdev_prop_set_uint32 (tlb_dev,"num-entries" , m_cfg->cfgtable.jtlb_size_entries);
hw/hppa/machine.c +6 -6
@@ -265,7 +265,7 @@ static LasiState *lasi_init(void) {DeviceState *dev; - dev =qdev_new (TYPE_LASI_CHIP ); + dev =qdev_new_orphan (TYPE_LASI_CHIP );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);return LASI_CHIP (dev);
@@ -275,7 +275,7 @@ static DinoState *dino_init(MemoryRegion *addr_space) {DeviceState *dev; - dev =qdev_new (TYPE_DINO_PCI_HOST_BRIDGE ); + dev =qdev_new_orphan (TYPE_DINO_PCI_HOST_BRIDGE );object_property_set_link (OBJECT (dev),"memory-as" ,OBJECT (addr_space), &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -411,7 +411,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus, lasi_dev = hpm->lasi_dev;if (lasi_dev && machine->enable_graphics && vga_interface_type !=VGA_NONE ) { - dev =qdev_new ("artist" ); + dev =qdev_new_orphan ("artist" ); s =SYS_BUS_DEVICE (dev);bool disabled =object_property_get_bool (OBJECT (dev),"disable" ,NULL );if (!disabled) {
@@ -614,7 +614,7 @@ static void machine_HP_715_init(MachineState *machine) parallel_hds[0]);/* PS/2 Keyboard/Mouse */ - dev =qdev_new (TYPE_LASIPS2 ); + dev =qdev_new_orphan (TYPE_LASIPS2 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 ,qdev_get_gpio_in (lasi_dev,LASI_IRQ_PS2KBD_HPA ));
@@ -706,7 +706,7 @@ static void machine_HP_B160L_init(MachineState *machine) parallel_hds[0]);/* PS/2 Keyboard/Mouse */ - dev =qdev_new (TYPE_LASIPS2 ); + dev =qdev_new_orphan (TYPE_LASIPS2 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 ,qdev_get_gpio_in (lasi_dev,LASI_IRQ_PS2KBD_HPA ));
@@ -733,7 +733,7 @@ static AstroState *astro_init(void) {DeviceState *dev; - dev =qdev_new (TYPE_ASTRO_CHIP ); + dev =qdev_new_orphan (TYPE_ASTRO_CHIP );object_property_set_int (OBJECT (dev),"phys-addr-bits" ,hppa_phys_addr_bits (&cpu[0 ]->env), &error_abort);
hw/i2c/core.c +1 -1
@@ -368,7 +368,7 @@ I2CSlave *i2c_slave_new(const char *name, uint8_t addr) {DeviceState *dev; - dev =qdev_new (name); + dev =qdev_new_orphan (name);qdev_prop_set_uint8 (dev,"address" , addr);return I2C_SLAVE (dev); }
hw/i2c/smbus_eeprom.c +1 -1
@@ -164,7 +164,7 @@ void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf) {DeviceState *dev; - dev =qdev_new (TYPE_SMBUS_EEPROM ); + dev =qdev_new_orphan (TYPE_SMBUS_EEPROM );qdev_prop_set_uint8 (dev,"address" , address);/* FIXME: use an array of byte or block backend property? */ SMBUS_EEPROM (dev)->init_data = eeprom_buf;
hw/i386/microvm.c +3 -3
@@ -108,7 +108,7 @@ static void create_gpex(MicrovmMachineState *mms)DeviceState *dev;int i; - dev =qdev_new (TYPE_GPEX_HOST ); + dev =qdev_new_orphan (TYPE_GPEX_HOST );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);/* Map only the first size_ecam bytes of ECAM space */
@@ -204,7 +204,7 @@ static void microvm_devices_init(MicrovmMachineState *mms)/* Optional and legacy devices */ if (x86_machine_is_acpi_enabled (x86ms)) { -DeviceState *dev =qdev_new (TYPE_ACPI_GED ); +DeviceState *dev =qdev_new_orphan (TYPE_ACPI_GED );qdev_prop_set_uint32 (dev,"ged-event" ,ACPI_GED_PWR_DOWN_EVT );sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,GED_MMIO_BASE );
@@ -216,7 +216,7 @@ static void microvm_devices_init(MicrovmMachineState *mms) }if (x86_machine_is_acpi_enabled (x86ms) &&machine_usb (MACHINE (mms))) { -DeviceState *dev =qdev_new (TYPE_XHCI_SYSBUS ); +DeviceState *dev =qdev_new_orphan (TYPE_XHCI_SYSBUS );qdev_prop_set_uint32 (dev,"intrs" ,1 );qdev_prop_set_uint32 (dev,"slots" ,XHCI_MAXSLOTS );qdev_prop_set_uint32 (dev,"p2" ,8 );
hw/i386/nitro_enclave.c +2 -2
@@ -46,7 +46,7 @@ static BusState *find_free_virtio_mmio_bus(void)static void vhost_user_vsock_init (NitroEnclaveMachineState *nems) { -DeviceState *dev =qdev_new (TYPE_VHOST_USER_VSOCK ); +DeviceState *dev =qdev_new_orphan (TYPE_VHOST_USER_VSOCK );VHostUserVSock *vsock =VHOST_USER_VSOCK (dev);BusState *bus;
@@ -75,7 +75,7 @@ static void vhost_user_vsock_init(NitroEnclaveMachineState *nems)static void virtio_nsm_init (NitroEnclaveMachineState *nems) { -DeviceState *dev =qdev_new (TYPE_VIRTIO_NSM ); +DeviceState *dev =qdev_new_orphan (TYPE_VIRTIO_NSM );VirtIONSM *vnsm =VIRTIO_NSM (dev);BusState *bus =find_free_virtio_mmio_bus ();
hw/i386/pc.c +1 -1
@@ -1065,7 +1065,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,if (pcms->hpet_enabled) {qemu_irq rtc_irq; - hpet =qdev_try_new (TYPE_HPET ); + hpet =qdev_try_new_orphan (TYPE_HPET );if (!hpet) {error_report ("couldn't create HPET device" );exit (1 );
hw/i386/pc_piix.c +1 -1
@@ -193,7 +193,7 @@ static void pc_init1(MachineState *machine, const char *pci_type) pci_memory =g_new (MemoryRegion,1 );memory_region_init (pci_memory,NULL ,"pci" ,UINT64_MAX ); - phb =OBJECT (qdev_new (TYPE_I440FX_PCI_HOST_BRIDGE )); + phb =OBJECT (qdev_new_orphan (TYPE_I440FX_PCI_HOST_BRIDGE ));object_property_add_child (OBJECT (machine),"i440fx" , phb);object_property_set_link (phb,PCI_HOST_PROP_RAM_MEM ,OBJECT (ram_memory), &error_fatal);
hw/i386/pc_q35.c +1 -1
@@ -199,7 +199,7 @@ static void pc_q35_init(MachineState *machine) }/* create pci host bus */ - phb =OBJECT (qdev_new (TYPE_Q35_HOST_DEVICE )); + phb =OBJECT (qdev_new_orphan (TYPE_Q35_HOST_DEVICE )); pci_hole64_size = object_property_get_uint(phb, PCI_HOST_PROP_PCI_HOLE64_SIZE,
hw/i386/pc_sysfw.c +1 -1
@@ -79,7 +79,7 @@ static PFlashCFI01 *pc_pflash_create(PCMachineState *pcms,const char *name, const char *alias_prop_name) { - DeviceState *dev = qdev_new(TYPE_PFLASH_CFI01); + DeviceState *dev = qdev_new_orphan(TYPE_PFLASH_CFI01);qdev_prop_set_uint64 (dev,"sector-length" ,FLASH_SECTOR_SIZE );qdev_prop_set_uint8 (dev,"width" ,1 );
hw/i386/sgx.c +1 -1
@@ -311,7 +311,7 @@ void pc_machine_init_sgx_epc(PCMachineState *pcms) &sgx_epc->mr);for (list = x86ms->sgx_epc_list; list; list = list->next) { -DeviceState *dev =qdev_new (TYPE_SGX_EPC ); +DeviceState *dev =qdev_new_orphan (TYPE_SGX_EPC );/* set the memdev link with memory backend */ object_property_parse(OBJECT(dev), SGX_EPC_MEMDEV_PROP,
hw/i386/x86-common.c +3 -3
@@ -505,9 +505,9 @@ void ioapic_init_gsi(GSIState *gsi_state, Object *parent)assert (parent);if (kvm_ioapic_in_kernel ()) { - dev =qdev_new (TYPE_KVM_IOAPIC ); + dev =qdev_new_orphan (TYPE_KVM_IOAPIC ); }else { - dev =qdev_new (TYPE_IOAPIC ); + dev =qdev_new_orphan (TYPE_IOAPIC ); }object_property_add_child (parent,"ioapic" ,OBJECT (dev)); d =SYS_BUS_DEVICE (dev);
@@ -525,7 +525,7 @@ DeviceState *ioapic_init_secondary(GSIState *gsi_state)SysBusDevice *d;unsigned int i; - dev =qdev_new (TYPE_IOAPIC ); + dev =qdev_new_orphan (TYPE_IOAPIC ); d =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (d, &error_fatal);sysbus_mmio_map (d,0 ,IO_APIC_SECONDARY_ADDRESS );
hw/i3c/core.c +1 -1
@@ -547,7 +547,7 @@ I3CTarget *i3c_target_new(const char *name, uint8_t addr, uint8_t dcr, {DeviceState *dev; - dev =qdev_new (name); + dev =qdev_new_orphan (name);qdev_prop_set_uint8 (dev,"static-address" , addr);qdev_prop_set_uint8 (dev,"dcr" , dcr);qdev_prop_set_uint8 (dev,"bcr" , bcr);
hw/ide/ide-bus.c +1 -1
@@ -75,7 +75,7 @@ IDEDevice *ide_bus_create_drive(IDEBus *bus, int unit, DriveInfo *drive) {DeviceState *dev; - dev =qdev_new (drive->media_cd ?"ide-cd" :"ide-hd" ); + dev =qdev_new_orphan (drive->media_cd ?"ide-cd" :"ide-hd" );qdev_prop_set_uint32 (dev,"unit" , unit);qdev_prop_set_drive_err (dev,"drive" ,blk_by_legacy_dinfo (drive), &error_fatal);
hw/intc/exynos4210_gic.c +1 -1
@@ -60,7 +60,7 @@ static void exynos4210_gic_realize(DeviceState *dev, Error **errp)uint32_t n = s->num_cpu;uint32_t i; - s->gic =qdev_new ("arm_gic" ); + s->gic =qdev_new_orphan ("arm_gic" );qdev_prop_set_uint32 (s->gic,"num-cpu" , s->num_cpu);qdev_prop_set_uint32 (s->gic,"num-irq" ,EXYNOS4210_GIC_NIRQ ); gicbusdev =SYS_BUS_DEVICE (s->gic);
hw/intc/riscv_aclint.c +2 -2
@@ -377,7 +377,7 @@ DeviceState *riscv_aclint_mtimer_create(hwaddr addr, hwaddr size, bool provide_rdtime) {int i; -DeviceState *dev =qdev_new (TYPE_RISCV_ACLINT_MTIMER ); +DeviceState *dev =qdev_new_orphan (TYPE_RISCV_ACLINT_MTIMER );RISCVAclintMTimerState *s =RISCV_ACLINT_MTIMER (dev);assert (num_harts <=RISCV_ACLINT_MAX_HARTS );
@@ -560,7 +560,7 @@ DeviceState *riscv_aclint_swi_create(hwaddr addr, uint32_t hartid_base, uint32_t num_harts, bool sswi) { int i; -DeviceState *dev =qdev_new (TYPE_RISCV_ACLINT_SWI ); +DeviceState *dev =qdev_new_orphan (TYPE_RISCV_ACLINT_SWI );assert (num_harts <=RISCV_ACLINT_MAX_HARTS );assert (!(addr &0x3 ));
hw/intc/riscv_aplic.c +1 -1
@@ -1113,7 +1113,7 @@ DeviceState *riscv_aplic_create(hwaddr addr, hwaddr size, uint32_t hartid_base, uint32_t num_harts, uint32_t num_sources, uint32_t iprio_bits, bool msimode, bool mmode, DeviceState *parent) { - DeviceState *dev = qdev_new(TYPE_RISCV_APLIC); + DeviceState *dev = qdev_new_orphan(TYPE_RISCV_APLIC);uint32_t i;assert (num_harts <APLIC_MAX_IDC );
hw/intc/riscv_imsic.c +1 -1
@@ -498,7 +498,7 @@ type_init(riscv_imsic_register_types)DeviceState *riscv_imsic_create (hwaddr addr,uint32_t hartid,bool mmode,uint32_t num_pages,uint32_t num_ids) { -DeviceState *dev =qdev_new (TYPE_RISCV_IMSIC ); +DeviceState *dev =qdev_new_orphan (TYPE_RISCV_IMSIC );CPUState *cpu =cpu_by_arch_id (hartid);uint32_t i;
hw/intc/s390_flic.c +2 -2
@@ -62,11 +62,11 @@ void s390_flic_init(void)DeviceState *dev;if (kvm_enabled ()) { - dev =qdev_new (TYPE_KVM_S390_FLIC ); + dev =qdev_new_orphan (TYPE_KVM_S390_FLIC );object_property_add_child (qdev_get_machine (),TYPE_KVM_S390_FLIC ,OBJECT (dev)); }else { - dev =qdev_new (TYPE_QEMU_S390_FLIC ); + dev =qdev_new_orphan (TYPE_QEMU_S390_FLIC );object_property_add_child (qdev_get_machine (),TYPE_QEMU_S390_FLIC ,OBJECT (dev)); }
hw/intc/sifive_plic.c +1 -1
@@ -481,7 +481,7 @@ DeviceState *sifive_plic_create(hwaddr addr, char *hart_config, uint32_t enable_stride, uint32_t context_base, uint32_t context_stride, uint32_t aperture_size) { - DeviceState *dev = qdev_new(TYPE_SIFIVE_PLIC); + DeviceState *dev = qdev_new_orphan(TYPE_SIFIVE_PLIC);int i;SiFivePLICState *plic;
hw/isa/isa-bus.c +3 -3
@@ -59,7 +59,7 @@ ISABus *isa_bus_new(DeviceState *dev, MemoryRegion* address_space,return NULL ; }if (!dev) { - bridge =qdev_new ("isabus-bridge" ); + bridge =qdev_new_orphan ("isabus-bridge" ); dev = bridge; }
@@ -155,12 +155,12 @@ int isa_register_portio_list(ISADevice *dev,ISADevice *isa_new (const char *name) { -return ISA_DEVICE (qdev_new (name)); +return ISA_DEVICE (qdev_new_orphan (name)); }ISADevice *isa_try_new (const char *name) { -return ISA_DEVICE (qdev_try_new (name)); +return ISA_DEVICE (qdev_try_new_orphan (name)); }ISADevice *isa_create_simple (ISABus *bus,const char *name)
hw/loongarch/virt.c +9 -9
@@ -150,7 +150,7 @@ static PFlashCFI01 *virt_flash_create1(LoongArchVirtMachineState *lvms,const char *name, const char *alias_prop_name) { - DeviceState *dev = qdev_new(TYPE_PFLASH_CFI01); + DeviceState *dev = qdev_new_orphan(TYPE_PFLASH_CFI01);qdev_prop_set_uint64 (dev,"sector-length" ,VIRT_FLASH_SECTOR_SIZE );qdev_prop_set_uint8 (dev,"width" ,4 );
@@ -295,7 +295,7 @@ static DeviceState *create_acpi_ged(DeviceState *pch_pic, event |=ACPI_GED_CPU_HOTPLUG_EVT ; } - dev =qdev_new (TYPE_ACPI_GED ); + dev =qdev_new_orphan (TYPE_ACPI_GED );qdev_prop_set_uint32 (dev,"ged-event" , event);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -322,7 +322,7 @@ static DeviceState *create_platform_bus(DeviceState *pch_pic)int i, irq;MemoryRegion *sysmem =get_system_memory (); - dev =qdev_new (TYPE_PLATFORM_BUS_DEVICE ); + dev =qdev_new_orphan (TYPE_PLATFORM_BUS_DEVICE ); dev->id =g_strdup (TYPE_PLATFORM_BUS_DEVICE );qdev_prop_set_uint32 (dev,"num_irqs" ,VIRT_PLATFORM_BUS_NUM_IRQS );qdev_prop_set_uint32 (dev,"mmio_size" ,VIRT_PLATFORM_BUS_SIZE );
@@ -400,7 +400,7 @@ static void virt_devices_init(DeviceState *pch_pic,hwaddr mmio_base, mmio_size;int i, irq; - gpex_dev =qdev_new (TYPE_GPEX_HOST ); + gpex_dev =qdev_new_orphan (TYPE_GPEX_HOST ); d =SYS_BUS_DEVICE (gpex_dev);sysbus_realize_and_unref (d, &error_fatal); pci_bus =PCI_HOST_BRIDGE (gpex_dev)->bus;
@@ -601,20 +601,20 @@ static void virt_irq_init(LoongArchVirtMachineState *lvms)*/ /* Create IPI device */ - ipi =qdev_new (TYPE_LOONGARCH_IPI ); + ipi =qdev_new_orphan (TYPE_LOONGARCH_IPI ); lvms->ipi = ipi;sysbus_realize_and_unref (SYS_BUS_DEVICE (ipi), &error_fatal);/* Create DINTC device*/ if (virt_has_dmsi (lvms)) { - dintc =qdev_new (TYPE_LOONGARCH_DINTC ); + dintc =qdev_new_orphan (TYPE_LOONGARCH_DINTC ); lvms->dintc = dintc;sysbus_realize_and_unref (SYS_BUS_DEVICE (dintc), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dintc),0 ,VIRT_DINTC_BASE ); }/* Create EXTIOI device */ - extioi =qdev_new (TYPE_LOONGARCH_EXTIOI ); + extioi =qdev_new_orphan (TYPE_LOONGARCH_EXTIOI ); lvms->extioi = extioi;if (virt_is_veiointc_enabled (lvms)) {qdev_prop_set_bit (extioi,"has-virtualization-extension" , true);
@@ -622,13 +622,13 @@ static void virt_irq_init(LoongArchVirtMachineState *lvms)sysbus_realize_and_unref (SYS_BUS_DEVICE (extioi), &error_fatal);virt_cpu_irq_init (lvms); - pch_pic =qdev_new (TYPE_LOONGARCH_PIC ); + pch_pic =qdev_new_orphan (TYPE_LOONGARCH_PIC ); num =VIRT_PCH_PIC_IRQ_NUM ;qdev_prop_set_uint32 (pch_pic,"pch_pic_irq_num" , num); d =SYS_BUS_DEVICE (pch_pic);sysbus_realize_and_unref (d, &error_fatal); - pch_msi =qdev_new (TYPE_LOONGARCH_PCH_MSI ); + pch_msi =qdev_new_orphan (TYPE_LOONGARCH_PCH_MSI ); start = num; num =EXTIOI_IRQS - start;qdev_prop_set_uint32 (pch_msi,"msi_irq_base" , start);
hw/m68k/an5206.c +1 -1
@@ -25,7 +25,7 @@ static void mcf5206_init(M68kCPU *cpu, MemoryRegion *sysmem, uint32_t base)DeviceState *dev;SysBusDevice *s; - dev =qdev_new (TYPE_MCF5206_MBAR ); + dev =qdev_new_orphan (TYPE_MCF5206_MBAR );object_property_set_link (OBJECT (dev),"m68k-cpu" ,OBJECT (cpu), &error_abort); s =SYS_BUS_DEVICE (dev);
hw/m68k/mcf_intc.c +1 -1
@@ -211,7 +211,7 @@ DeviceState *mcf_intc_init(MemoryRegion *sysmem, hwaddr base, M68kCPU *cpu) {DeviceState *dev; - dev =qdev_new (TYPE_MCF_INTC ); + dev =qdev_new_orphan (TYPE_MCF_INTC );object_property_set_link (OBJECT (dev),"m68k-cpu" ,OBJECT (cpu), &error_abort);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/m68k/next-cube.c +1 -1
@@ -1272,7 +1272,7 @@ static void next_cube_init(MachineState *machine) env->sr =0x2700 ;/* Peripheral Controller */ - pcdev =qdev_new (TYPE_NEXT_PC ); + pcdev =qdev_new_orphan (TYPE_NEXT_PC );object_property_set_link (OBJECT (pcdev),"cpu" ,OBJECT (cpu), &error_abort);sysbus_realize_and_unref (SYS_BUS_DEVICE (pcdev), &error_fatal);
hw/m68k/q800.c +2 -2
@@ -355,9 +355,9 @@ static void q800_machine_init(MachineState *machine) "auxmode", 0)); adb_bus =qdev_get_child_bus (DEVICE (&m->via1),"adb.0" ); - dev =qdev_new (TYPE_ADB_KEYBOARD ); + dev =qdev_new_orphan (TYPE_ADB_KEYBOARD );qdev_realize_and_unref (dev, adb_bus, &error_fatal); - dev =qdev_new (TYPE_ADB_MOUSE ); + dev =qdev_new_orphan (TYPE_ADB_MOUSE );qdev_realize_and_unref (dev, adb_bus, &error_fatal);/* VIA 2 */
hw/m68k/virt.c +5 -5
@@ -155,7 +155,7 @@ static void virt_init(MachineState *machine)/* IRQ Controller */ - irqc_dev =qdev_new (TYPE_M68K_IRQC ); + irqc_dev =qdev_new_orphan (TYPE_M68K_IRQC );object_property_set_link (OBJECT (irqc_dev),"m68k-cpu" ,OBJECT (cpu), &error_abort);sysbus_realize_and_unref (SYS_BUS_DEVICE (irqc_dev), &error_fatal);
@@ -169,7 +169,7 @@ static void virt_init(MachineState *machine)*/ io_base =VIRT_GF_PIC_MMIO_BASE ;for (i =0 ; i <VIRT_GF_PIC_NB ; i++) { - pic_dev[i] =qdev_new (TYPE_GOLDFISH_PIC ); + pic_dev[i] =qdev_new_orphan (TYPE_GOLDFISH_PIC ); sysbus =SYS_BUS_DEVICE (pic_dev[i]);qdev_prop_set_uint8 (pic_dev[i],"index" , i);sysbus_realize_and_unref (sysbus, &error_fatal);
@@ -183,7 +183,7 @@ static void virt_init(MachineState *machine)/* goldfish-rtc */ io_base =VIRT_GF_RTC_MMIO_BASE ;for (i =0 ; i <VIRT_GF_RTC_NB ; i++) { - dev =qdev_new (TYPE_GOLDFISH_RTC ); + dev =qdev_new_orphan (TYPE_GOLDFISH_RTC );qdev_prop_set_bit (dev,"big-endian" , true); sysbus =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sysbus, &error_fatal);
@@ -194,7 +194,7 @@ static void virt_init(MachineState *machine) }/* goldfish-tty */ - dev =qdev_new (TYPE_GOLDFISH_TTY ); + dev =qdev_new_orphan (TYPE_GOLDFISH_TTY ); sysbus =SYS_BUS_DEVICE (dev);qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 ));sysbus_realize_and_unref (sysbus, &error_fatal);
@@ -208,7 +208,7 @@ static void virt_init(MachineState *machine)/* virtio-mmio */ io_base =VIRT_VIRTIO_MMIO_BASE ;for (i =0 ; i <128 ; i++) { - dev =qdev_new (TYPE_VIRTIO_MMIO ); + dev =qdev_new_orphan (TYPE_VIRTIO_MMIO );qdev_prop_set_bit (dev,"force-legacy" , false); sysbus =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sysbus, &error_fatal);
hw/mem/sparse-mem.c +1 -1
@@ -108,7 +108,7 @@ MemoryRegion *sparse_mem_init(uint64_t addr, uint64_t length) {DeviceState *dev; - dev =qdev_new (TYPE_SPARSE_MEM ); + dev =qdev_new_orphan (TYPE_SPARSE_MEM );qdev_prop_set_uint64 (dev,"baseaddr" , addr);qdev_prop_set_uint64 (dev,"length" , length);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/microblaze/petalogix_ml605_mmu.c +6 -6
@@ -110,7 +110,7 @@ petalogix_ml605_init(MachineState *machine) 64 * KiB, 2, 0x89, 0x18, 0x0000, 0x0, 0); - dev =qdev_new ("xlnx.xps-intc" ); + dev =qdev_new_orphan ("xlnx.xps-intc" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint32 (dev,"kind-of-intr" ,1 <<TIMER_IRQ );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -126,7 +126,7 @@ petalogix_ml605_init(MachineState *machine) DEVICE_LITTLE_ENDIAN);/* 2 timers at irq 2 @ 100 Mhz. */ - dev =qdev_new ("xlnx.xps-timer" ); + dev =qdev_new_orphan ("xlnx.xps-timer" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,100 *1000000 );
@@ -135,8 +135,8 @@ petalogix_ml605_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[TIMER_IRQ ]);/* axi ethernet and dma initialization. */ - eth0 =qdev_new ("xlnx.axi-ethernet" ); - dma =qdev_new ("xlnx.axi-dma" ); + eth0 =qdev_new_orphan ("xlnx.axi-ethernet" ); + dma =qdev_new_orphan ("xlnx.axi-dma" );/* FIXME: attach to the sysbus instead */ object_property_add_child (qdev_get_machine (),"xilinx-eth" ,OBJECT (eth0));
@@ -174,7 +174,7 @@ petalogix_ml605_init(MachineState *machine) {SSIBus *spi; - dev =qdev_new ("xlnx.xps-spi" ); + dev =qdev_new_orphan ("xlnx.xps-spi" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint8 (dev,"num-ss-bits" ,NUM_SPI_FLASHES ); busdev =SYS_BUS_DEVICE (dev);
@@ -188,7 +188,7 @@ petalogix_ml605_init(MachineState *machine) dinfo =drive_get (IF_MTD ,0 , i);qemu_irq cs_line; - dev =qdev_new ("n25q128" ); + dev =qdev_new_orphan ("n25q128" );if (dinfo) { qdev_prop_set_drive_err(dev, "drive", blk_by_legacy_dinfo(dinfo),
hw/microblaze/petalogix_s3adsp1800_mmu.c +4 -4
@@ -107,7 +107,7 @@ petalogix_s3adsp1800_init(MachineState *machine) dinfo ?blk_by_legacy_dinfo (dinfo) :NULL , 64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1); - dev =qdev_new ("xlnx.xps-intc" ); + dev =qdev_new_orphan ("xlnx.xps-intc" );qdev_prop_set_enum (dev,"endianness" , endianness);qdev_prop_set_uint32 (dev,"kind-of-intr" ,1 <<ETHLITE_IRQ |1 <<UARTLITE_IRQ );
@@ -119,7 +119,7 @@ petalogix_s3adsp1800_init(MachineState *machine) irq[i] =qdev_get_gpio_in (dev, i); } - dev =qdev_new (TYPE_XILINX_UARTLITE ); + dev =qdev_new_orphan (TYPE_XILINX_UARTLITE );qdev_prop_set_enum (dev,"endianness" , endianness);qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 ));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -127,7 +127,7 @@ petalogix_s3adsp1800_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[UARTLITE_IRQ ]);/* 2 timers at irq 2 @ 62 Mhz. */ - dev =qdev_new ("xlnx.xps-timer" ); + dev =qdev_new_orphan ("xlnx.xps-timer" );qdev_prop_set_enum (dev,"endianness" , endianness);qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,62 *1000000 );
@@ -135,7 +135,7 @@ petalogix_s3adsp1800_init(MachineState *machine)sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,TIMER_BASEADDR );sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[TIMER_IRQ ]); - dev =qdev_new ("xlnx.xps-ethernetlite" ); + dev =qdev_new_orphan ("xlnx.xps-ethernetlite" );qdev_prop_set_enum (dev,"endianness" , endianness);qemu_configure_nic_device (dev, true,NULL );qdev_prop_set_uint32 (dev,"tx-ping-pong" ,0 );
hw/mips/boston.c +2 -2
@@ -432,7 +432,7 @@ xilinx_pcie_init(MemoryRegion *sys_mem, uint32_t bus_nr,DeviceState *dev;MemoryRegion *cfg, *mmio; - dev =qdev_new (TYPE_XILINX_PCIE_HOST ); + dev =qdev_new_orphan (TYPE_XILINX_PCIE_HOST );qdev_prop_set_uint32 (dev,"bus_nr" , bus_nr);qdev_prop_set_uint64 (dev,"cfg_base" , cfg_base);
@@ -688,7 +688,7 @@ static void boston_mach_init(MachineState *machine)exit (1 ); } - dev =qdev_new (TYPE_BOSTON ); + dev =qdev_new_orphan (TYPE_BOSTON );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); s =BOSTON (dev);
hw/mips/jazz.c +6 -6
@@ -127,7 +127,7 @@ static void mips_jazz_init_net(IOMMUMemoryRegion *rc4030_dma_mr,return ; } - dev =qdev_new ("dp8393x" ); + dev =qdev_new_orphan ("dp8393x" );qdev_set_nic_properties (dev, nd);qdev_prop_set_uint8 (dev,"it_shift" ,2 );qdev_prop_set_bit (dev,"big_endian" ,TARGET_BIG_ENDIAN );
@@ -296,7 +296,7 @@ static void mips_jazz_init(MachineState *machine,/* Video card */ switch (jazz_model) {case JAZZ_MAGNUM : - dev =qdev_new ("sysbus-g364" ); + dev =qdev_new_orphan ("sysbus-g364" ); sysbus =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sysbus, &error_fatal);sysbus_mmio_map (sysbus,0 ,0x60080000 );
@@ -313,7 +313,7 @@ static void mips_jazz_init(MachineState *machine, }break ;case JAZZ_PICA61 : - dev =qdev_new (TYPE_VGA_MMIO ); + dev =qdev_new_orphan (TYPE_VGA_MMIO );qdev_prop_set_uint8 (dev,"it_shift" ,0 ); sysbus =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sysbus, &error_fatal);
@@ -329,7 +329,7 @@ static void mips_jazz_init(MachineState *machine,mips_jazz_init_net (rc4030_dma_mr, rc4030, dp8393x_prom);/* SCSI adapter */ - dev =qdev_new (TYPE_SYSBUS_ESP ); + dev =qdev_new_orphan (TYPE_SYSBUS_ESP ); sysbus_esp =SYSBUS_ESP (dev); esp = &sysbus_esp->esp; esp->dma_memory_read = rc4030_dma_read;
@@ -359,7 +359,7 @@ static void mips_jazz_init(MachineState *machine,memory_region_add_subregion (address_space,0x80004000 , rtc);/* Keyboard (i8042) */ - i8042 =I8042_MMIO (qdev_new (TYPE_I8042_MMIO )); + i8042 =I8042_MMIO (qdev_new_orphan (TYPE_I8042_MMIO ));qdev_prop_set_uint64 (DEVICE (i8042),"mask" ,1 );qdev_prop_set_uint32 (DEVICE (i8042),"size" ,0x1000 );sysbus_realize_and_unref (SYS_BUS_DEVICE (i8042), &error_fatal);
@@ -389,7 +389,7 @@ static void mips_jazz_init(MachineState *machine,/* FIXME: missing Jazz sound at 0x8000c000, rc4030[2] */ /* NVRAM */ - dev =qdev_new ("ds1225y" ); + dev =qdev_new_orphan ("ds1225y" ); sysbus =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sysbus, &error_fatal);sysbus_mmio_map (sysbus,0 ,0x80009000 );
hw/mips/loongson3_virt.c +3 -3
@@ -424,7 +424,7 @@ static inline void loongson3_virt_devices_init(MachineState *machine,MachineClass *mc =MACHINE_GET_CLASS (machine);LoongsonMachineState *s =LOONGSON_MACHINE (machine); - dev =qdev_new (TYPE_GPEX_HOST ); + dev =qdev_new_orphan (TYPE_GPEX_HOST );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); pci_bus =PCI_HOST_BRIDGE (dev)->bus;
@@ -519,7 +519,7 @@ static void mips_loongson3_virt_init(MachineState *machine)memory_region_init (iocsr,OBJECT (machine),"loongson3.iocsr" ,UINT32_MAX ); - ipi =qdev_new (TYPE_LOONGSON_IPI ); + ipi =qdev_new_orphan (TYPE_LOONGSON_IPI );qdev_prop_set_uint32 (ipi,"num-cpu" , machine->smp.cpus);sysbus_realize_and_unref (SYS_BUS_DEVICE (ipi), &error_fatal); memory_region_add_subregion(iocsr, SMP_IPI_MAILBOX,
@@ -527,7 +527,7 @@ static void mips_loongson3_virt_init(MachineState *machine)memory_region_add_subregion (iocsr,MAIL_SEND_ADDR ,sysbus_mmio_get_region (SYS_BUS_DEVICE (ipi),1 )); - liointc =qdev_new ("loongson.liointc" ); + liointc =qdev_new_orphan ("loongson.liointc" );sysbus_realize_and_unref (SYS_BUS_DEVICE (liointc), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (liointc),0 , virt_memmap[VIRT_LIOINTC ].base);
hw/mips/malta.c +2 -2
@@ -1098,7 +1098,7 @@ void mips_malta_init(MachineState *machine)PCIDevice *piix4;DeviceState *dev; - s =MIPS_MALTA (qdev_new (TYPE_MIPS_MALTA )); + s =MIPS_MALTA (qdev_new_orphan (TYPE_MIPS_MALTA ));sysbus_realize_and_unref (SYS_BUS_DEVICE (s), &error_fatal);/* create CPU */
@@ -1226,7 +1226,7 @@ void mips_malta_init(MachineState *machine)stl_p (memory_region_get_ram_ptr (bios_copy) +0x10 ,0x00000420 );/* Northbridge */ - dev =qdev_new ("gt64120" ); + dev =qdev_new_orphan ("gt64120" );qdev_prop_set_bit (dev,"cpu-little-endian" , !TARGET_BIG_ENDIAN );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); pci_bus =PCI_BUS (qdev_get_child_bus (dev,"pci" ));
hw/misc/empty_slot.c +1 -1
@@ -58,7 +58,7 @@ void empty_slot_init(const char *name, hwaddr addr, uint64_t slot_size)/* Only empty slots larger than 0 byte need handling. */ DeviceState *dev; - dev =qdev_new (TYPE_EMPTY_SLOT ); + dev =qdev_new_orphan (TYPE_EMPTY_SLOT );qdev_prop_set_uint64 (dev,"size" , slot_size);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/misc/led.c +1 -1
@@ -141,7 +141,7 @@ LEDState *led_create_simple(Object *parentobj, g_autofree char *name = NULL;DeviceState *dev; - dev =qdev_new (TYPE_LED ); + dev =qdev_new_orphan (TYPE_LED );qdev_prop_set_bit (dev,"gpio-active-high" , gpio_polarity ==GPIO_POLARITY_ACTIVE_HIGH );qdev_prop_set_string (dev,"color" , led_color_name[color]);
hw/misc/sifive_e_prci.c +1 -1
@@ -117,7 +117,7 @@ type_init(sifive_e_prci_register_types)*/ DeviceState *sifive_e_prci_create (hwaddr addr) { -DeviceState *dev =qdev_new (TYPE_SIFIVE_E_PRCI ); +DeviceState *dev =qdev_new_orphan (TYPE_SIFIVE_E_PRCI );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , addr);return dev;
hw/misc/sifive_test.c +1 -1
@@ -97,7 +97,7 @@ type_init(sifive_test_register_types)*/ DeviceState *sifive_test_create (hwaddr addr) { -DeviceState *dev =qdev_new (TYPE_SIFIVE_TEST ); +DeviceState *dev =qdev_new_orphan (TYPE_SIFIVE_TEST );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , addr);return dev;
hw/net/lan9118.c +1 -1
@@ -1339,7 +1339,7 @@ void lan9118_init(uint32_t base, qemu_irq irq)DeviceState *dev;SysBusDevice *s; - dev =qdev_new (TYPE_LAN9118 ); + dev =qdev_new_orphan (TYPE_LAN9118 );qemu_configure_nic_device (dev, true,NULL ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);
hw/net/smc91c111.c +1 -1
@@ -954,7 +954,7 @@ void smc91c111_init(uint32_t base, qemu_irq irq)DeviceState *dev;SysBusDevice *s; - dev =qdev_new (TYPE_SMC91C111 ); + dev =qdev_new_orphan (TYPE_SMC91C111 );qemu_configure_nic_device (dev, true,NULL ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);
hw/net/spapr_llan.c +1 -1
@@ -371,7 +371,7 @@ void spapr_vlan_create(SpaprVioBus *bus, NICInfo *nd) {DeviceState *dev; - dev =qdev_new ("spapr-vlan" ); + dev =qdev_new_orphan ("spapr-vlan" );qdev_set_nic_properties (dev, nd);
hw/net/xen_nic.c +1 -1
@@ -619,7 +619,7 @@ static void xen_net_device_create(XenBackendInstance *backend, goto fail; } - xendev =XEN_DEVICE (qdev_new (TYPE_XEN_NET_DEVICE )); + xendev =XEN_DEVICE (qdev_new_orphan (TYPE_XEN_NET_DEVICE )); net =XEN_NET_DEVICE (xendev); net->dev = number;
hw/nitro/machine.c +2 -2
@@ -197,7 +197,7 @@ static void nitro_machine_init(MachineState *machine)NitroVsockBridge *bridge =nitro_vsock_bridge_create ();/* Nitro Enclaves require a heartbeat device. Provide one. */ -qdev_realize (qdev_new (TYPE_NITRO_HEARTBEAT ), +qdev_realize (qdev_new_orphan (TYPE_NITRO_HEARTBEAT ),BUS (&bridge->bus), &error_fatal);/*
@@ -209,7 +209,7 @@ static void nitro_machine_init(MachineState *machine)Chardev *chr =serial_hd (0 );if (chr) { -DeviceState *dev =qdev_new (TYPE_NITRO_SERIAL_VSOCK ); +DeviceState *dev =qdev_new_orphan (TYPE_NITRO_SERIAL_VSOCK );qdev_prop_set_chr (dev,"chardev" , chr);qdev_realize (dev,BUS (&bridge->bus), &error_fatal);
hw/nitro/nitro-vsock-bus.c +1 -1
@@ -48,7 +48,7 @@ void nitro_vsock_bridge_start_enclave(NitroVsockBridge *bridge,NitroVsockBridge *nitro_vsock_bridge_create (void ) { -DeviceState *dev =qdev_new (TYPE_NITRO_VSOCK_BRIDGE ); +DeviceState *dev =qdev_new_orphan (TYPE_NITRO_VSOCK_BRIDGE );qdev_set_id (dev,g_strdup ("nitro-vsock" ), &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/nvme/ctrl.c +1 -1
@@ -9556,7 +9556,7 @@ static int nvme_init_subsys(NvmeCtrl *n, Error **errp)int cntlid;if (!n->subsys) { -DeviceState *dev =qdev_new (TYPE_NVME_SUBSYS ); +DeviceState *dev =qdev_new_orphan (TYPE_NVME_SUBSYS );qdev_prop_set_string (dev,"nqn" , n->params.serial);
hw/nvram/fw_cfg.c +2 -2
@@ -1029,7 +1029,7 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, AddressSpace *dma_as)assert (dma_as); - dev =qdev_new (TYPE_FW_CFG_IO ); + dev =qdev_new_orphan (TYPE_FW_CFG_IO );object_property_add_child (OBJECT (qdev_get_machine ()),TYPE_FW_CFG ,OBJECT (dev));
@@ -1061,7 +1061,7 @@ static FWCfgState *fw_cfg_init_mem_internal(hwaddr ctl_addr,FWCfgState *s;bool dma_requested = dma_addr && dma_as; - dev =qdev_new (TYPE_FW_CFG_MEM ); + dev =qdev_new_orphan (TYPE_FW_CFG_MEM );qdev_prop_set_uint32 (dev,"data_width" , data_width);if (!dma_requested) {qdev_prop_set_bit (dev,"dma_enabled" , false);
hw/or1k/or1k-sim.c +3 -3
@@ -186,7 +186,7 @@ static void openrisc_sim_net_init(Or1ksimState *state, hwaddr base, hwaddr size, s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);if (num_cpus >1 ) { -DeviceState *splitter =qdev_new (TYPE_SPLIT_IRQ ); +DeviceState *splitter =qdev_new_orphan (TYPE_SPLIT_IRQ );qdev_prop_set_uint32 (splitter,"num-lines" , num_cpus);qdev_realize_and_unref (splitter,NULL , &error_fatal);for (i =0 ; i < num_cpus; i++) {
@@ -221,7 +221,7 @@ static void openrisc_sim_ompic_init(Or1ksimState *state, hwaddr base,char *nodename;int i; - dev =qdev_new ("or1k-ompic" ); + dev =qdev_new_orphan ("or1k-ompic" );qdev_prop_set_uint32 (dev,"num-cpus" , num_cpus); s =SYS_BUS_DEVICE (dev);
@@ -254,7 +254,7 @@ static void openrisc_sim_serial_init(Or1ksimState *state, hwaddr base,int i;if (num_cpus >1 ) { -DeviceState *splitter =qdev_new (TYPE_SPLIT_IRQ ); +DeviceState *splitter =qdev_new_orphan (TYPE_SPLIT_IRQ );qdev_prop_set_uint32 (splitter,"num-lines" , num_cpus);qdev_realize_and_unref (splitter,NULL , &error_fatal);for (i =0 ; i < num_cpus; i++) {
hw/or1k/virt.c +4 -4
@@ -110,7 +110,7 @@ static qemu_irq get_per_cpu_irq(OpenRISCCPU *cpus[], int num_cpus, int irq_pin)int i;if (num_cpus >1 ) { -DeviceState *splitter =qdev_new (TYPE_SPLIT_IRQ ); +DeviceState *splitter =qdev_new_orphan (TYPE_SPLIT_IRQ );qdev_prop_set_uint32 (splitter,"num-lines" , num_cpus);qdev_realize_and_unref (splitter,NULL , &error_fatal);for (i =0 ; i < num_cpus; i++) {
@@ -206,7 +206,7 @@ static void openrisc_virt_ompic_init(OR1KVirtState *state, hwaddr base,char *nodename;int i; - dev =qdev_new ("or1k-ompic" ); + dev =qdev_new_orphan ("or1k-ompic" );qdev_prop_set_uint32 (dev,"num-cpus" , num_cpus); s =SYS_BUS_DEVICE (dev);
@@ -379,7 +379,7 @@ static void openrisc_virt_pcie_init(OR1KVirtState *state,qemu_irq pcie_irq;int i; - dev =qdev_new (TYPE_GPEX_HOST ); + dev =qdev_new_orphan (TYPE_GPEX_HOST );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);/* Map ECAM space. */
@@ -451,7 +451,7 @@ static void openrisc_virt_virtio_init(OR1KVirtState *state, hwaddr base,qemu_irq virtio_irq =get_per_cpu_irq (cpus, num_cpus, irq_pin);/* VirtIO MMIO devices */ - dev =qdev_new (TYPE_VIRTIO_MMIO ); + dev =qdev_new_orphan (TYPE_VIRTIO_MMIO );qdev_prop_set_bit (dev,"force-legacy" , false); sysbus =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sysbus, &error_fatal);
hw/pci-bridge/pci_expander_bridge.c +2 -2
@@ -359,7 +359,7 @@ static bool pxb_dev_realize_common(PCIDevice *dev, enum BusType type, dev_name = dev->qdev.id; } - ds =qdev_new (type ==CXL ?TYPE_PXB_CXL_HOST :TYPE_PXB_HOST ); + ds =qdev_new_orphan (type ==CXL ?TYPE_PXB_CXL_HOST :TYPE_PXB_HOST );if (type ==PCIE ) { bus =pci_root_bus_new (ds, dev_name,NULL ,NULL ,0 ,TYPE_PXB_PCIE_BUS ); }else if (type ==CXL ) {
@@ -368,7 +368,7 @@ static bool pxb_dev_realize_common(PCIDevice *dev, enum BusType type,PXB_CXL_DEV (dev)->cxl_host_bridge =PXB_CXL_HOST (ds); }else { bus =pci_root_bus_new (ds,"pxb-internal" ,NULL ,NULL ,0 ,TYPE_PXB_BUS ); - bds =qdev_new ("pci-bridge" ); + bds =qdev_new_orphan ("pci-bridge" ); bds->id =g_strdup (dev_name);qdev_prop_set_uint8 (bds,PCI_BRIDGE_DEV_PROP_CHASSIS_NR , pxb->bus_nr);qdev_prop_set_bit (bds,PCI_BRIDGE_DEV_PROP_SHPC , false);
hw/pci-host/astro.c +1 -1
@@ -521,7 +521,7 @@ static ElroyState *elroy_init(int num) {DeviceState *dev; - dev =qdev_new (TYPE_ELROY_PCI_HOST_BRIDGE ); + dev =qdev_new_orphan (TYPE_ELROY_PCI_HOST_BRIDGE ); dev->id =g_strdup_printf ("elroy%d" , num);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/pci-host/bonito.c +1 -1
@@ -741,7 +741,7 @@ PCIBus *bonito_init(qemu_irq *pic)PCIBonitoState *s;PCIDevice *d; - dev =qdev_new (TYPE_BONITO_PCI_HOST_BRIDGE ); + dev =qdev_new_orphan (TYPE_BONITO_PCI_HOST_BRIDGE ); phb =PCI_HOST_BRIDGE (dev); pcihost =BONITO_PCI_HOST_BRIDGE (dev); pcihost->pic = pic;
hw/pci-host/pnv_phb4_pec.c +1 -1
@@ -180,7 +180,7 @@ static PnvPHB *pnv_pec_default_phb_realize(PnvPhb4PecState *pec,int stack_no, Error **errp) { - PnvPHB *phb = PNV_PHB(qdev_new(TYPE_PNV_PHB)); + PnvPHB *phb = PNV_PHB(qdev_new_orphan(TYPE_PNV_PHB));int phb_id =pnv_phb4_pec_get_phb_id (pec, stack_no);object_property_add_child (OBJECT (pec),"phb[*]" ,OBJECT (phb));
hw/pci/pci.c +1 -1
@@ -2393,7 +2393,7 @@ static PCIDevice *pci_new_internal(int devfn, bool multifunction, {DeviceState *dev; - dev =qdev_new (name); + dev =qdev_new_orphan (name);qdev_prop_set_int32 (dev,"addr" , devfn);qdev_prop_set_bit (dev,"multifunction" , multifunction);return PCI_DEVICE (dev);
hw/ppc/amigaone.c +1 -1
@@ -302,7 +302,7 @@ static void amigaone_init(MachineState *machine) }/* nvram */ - dev =qdev_new (TYPE_A1_NVRAM ); + dev =qdev_new_orphan (TYPE_A1_NVRAM ); di =drive_get (IF_MTD ,0 ,0 );if (di) {qdev_prop_set_drive (dev,"drive" ,blk_by_legacy_dinfo (di));
hw/ppc/e500.c +11 -11
@@ -815,7 +815,7 @@ static DeviceState *ppce500_init_mpic_qemu(PPCE500MachineState *pms,unsigned int smp_cpus = machine->smp.cpus;const PPCE500MachineClass *pmc =PPCE500_MACHINE_GET_CLASS (pms); - dev =qdev_new (TYPE_OPENPIC ); + dev =qdev_new_orphan (TYPE_OPENPIC );object_property_add_child (OBJECT (machine),"pic" ,OBJECT (dev));qdev_prop_set_uint32 (dev,"model" , pmc->mpic_version);qdev_prop_set_uint32 (dev,"nb_cpus" , smp_cpus);
@@ -840,7 +840,7 @@ static DeviceState *ppce500_init_mpic_kvm(const PPCE500MachineClass *pmc,DeviceState *dev;CPUState *cs; - dev =qdev_new (TYPE_KVM_OPENPIC ); + dev =qdev_new_orphan (TYPE_KVM_OPENPIC );qdev_prop_set_uint32 (dev,"model" , pmc->mpic_version);if (!sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), errp)) {
@@ -993,7 +993,7 @@ void ppce500_init(MachineState *machine)/* Register Memory */ memory_region_add_subregion (address_space_mem,0 , machine->ram); - dev =qdev_new ("e500-ccsr" ); + dev =qdev_new_orphan ("e500-ccsr" ); s =SYS_BUS_DEVICE (dev);object_property_add_child (OBJECT (machine),"e500-ccsr" ,OBJECT (dev));sysbus_realize_and_unref (s, &error_fatal);
@@ -1018,7 +1018,7 @@ void ppce500_init(MachineState *machine) }/* I2C */ - dev =qdev_new ("mpc-i2c" ); + dev =qdev_new_orphan ("mpc-i2c" ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);sysbus_connect_irq (s,0 ,qdev_get_gpio_in (mpicdev,MPC8544_I2C_IRQ ));
@@ -1029,7 +1029,7 @@ void ppce500_init(MachineState *machine)/* eSDHC */ if (pmc->has_esdhc) { - dev =qdev_new (TYPE_UNIMPLEMENTED_DEVICE ); + dev =qdev_new_orphan (TYPE_UNIMPLEMENTED_DEVICE );qdev_prop_set_string (dev,"name" ,"esdhc" );qdev_prop_set_uint64 (dev,"size" ,MPC85XX_ESDHC_REGS_SIZE ); s =SYS_BUS_DEVICE (dev);
@@ -1037,7 +1037,7 @@ void ppce500_init(MachineState *machine)memory_region_add_subregion (ccsr_addr_space,MPC85XX_ESDHC_REGS_OFFSET ,sysbus_mmio_get_region (s,0 )); - dev =qdev_new (TYPE_FSL_ESDHC_BE ); + dev =qdev_new_orphan (TYPE_FSL_ESDHC_BE ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);sysbus_connect_irq (s,0 ,qdev_get_gpio_in (mpicdev,MPC85XX_ESDHC_IRQ ));
@@ -1046,14 +1046,14 @@ void ppce500_init(MachineState *machine) }/* General Utility device */ - dev =qdev_new ("mpc8544-guts" ); + dev =qdev_new_orphan ("mpc8544-guts" ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);memory_region_add_subregion (ccsr_addr_space,MPC8544_UTIL_OFFSET ,sysbus_mmio_get_region (s,0 ));/* PCI */ - dev =qdev_new ("e500-pcihost" ); + dev =qdev_new_orphan ("e500-pcihost" );object_property_add_child (OBJECT (machine),"pci-host" ,OBJECT (dev));qdev_prop_set_uint32 (dev,"first_slot" , pmc->pci_first_slot);qdev_prop_set_uint32 (dev,"first_pin_irq" , pci_irq_nrs[0 ]);
@@ -1081,7 +1081,7 @@ void ppce500_init(MachineState *machine)if (pmc->has_mpc8xxx_gpio) {qemu_irq poweroff_irq; - dev =qdev_new ("mpc8xxx_gpio" ); + dev =qdev_new_orphan ("mpc8xxx_gpio" ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);sysbus_connect_irq (s,0 ,qdev_get_gpio_in (mpicdev,MPC8XXX_GPIO_IRQ ));
@@ -1094,7 +1094,7 @@ void ppce500_init(MachineState *machine) }/* Platform Bus Device */ - dev =qdev_new (TYPE_PLATFORM_BUS_DEVICE ); + dev =qdev_new_orphan (TYPE_PLATFORM_BUS_DEVICE ); dev->id =g_strdup (TYPE_PLATFORM_BUS_DEVICE );qdev_prop_set_uint32 (dev,"num_irqs" , pmc->platform_bus_num_irqs);qdev_prop_set_uint32 (dev,"mmio_size" , pmc->platform_bus_size);
@@ -1136,7 +1136,7 @@ void ppce500_init(MachineState *machine)exit (1 ); } - dev =qdev_new (TYPE_PFLASH_CFI01 ); + dev =qdev_new_orphan (TYPE_PFLASH_CFI01 );qdev_prop_set_drive (dev,"drive" , blk);qdev_prop_set_uint32 (dev,"num-blocks" , size / sector_len);qdev_prop_set_uint64 (dev,"sector-length" , sector_len);
hw/ppc/mac_newworld.c +9 -9
@@ -286,7 +286,7 @@ static void ppc_core99_init(MachineState *machine) }/* UniN init */ - s =SYS_BUS_DEVICE (qdev_new (TYPE_UNI_NORTH )); + s =SYS_BUS_DEVICE (qdev_new_orphan (TYPE_UNI_NORTH ));sysbus_realize_and_unref (s, &error_fatal);memory_region_add_subregion (get_system_memory (),0xf8000000 ,sysbus_mmio_get_region (s,0 ));
@@ -295,7 +295,7 @@ static void ppc_core99_init(MachineState *machine) machine_arch =ARCH_MAC99_U3 ;/* 970 gets a U3 bus */ /* Uninorth AGP bus */ - uninorth_pci_dev =qdev_new (TYPE_U3_AGP_HOST_BRIDGE ); + uninorth_pci_dev =qdev_new_orphan (TYPE_U3_AGP_HOST_BRIDGE ); s =SYS_BUS_DEVICE (uninorth_pci_dev);sysbus_realize_and_unref (s, &error_fatal);sysbus_mmio_map (s,0 ,0xf0800000 );
@@ -310,14 +310,14 @@ static void ppc_core99_init(MachineState *machine) machine_arch =ARCH_MAC99 ;/* Use values found on a real PowerMac */ /* Uninorth AGP bus */ - uninorth_agp_dev =qdev_new (TYPE_UNI_NORTH_AGP_HOST_BRIDGE ); + uninorth_agp_dev =qdev_new_orphan (TYPE_UNI_NORTH_AGP_HOST_BRIDGE ); s =SYS_BUS_DEVICE (uninorth_agp_dev);sysbus_realize_and_unref (s, &error_fatal);sysbus_mmio_map (s,0 ,0xf0800000 );sysbus_mmio_map (s,1 ,0xf0c00000 );/* Uninorth internal bus */ - uninorth_internal_dev =qdev_new ( + uninorth_internal_dev =qdev_new_orphan (TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE ); s =SYS_BUS_DEVICE (uninorth_internal_dev);sysbus_realize_and_unref (s, &error_fatal);
@@ -325,7 +325,7 @@ static void ppc_core99_init(MachineState *machine)sysbus_mmio_map (s,1 ,0xf4c00000 );/* Uninorth main bus - this must be last to make it the default */ - uninorth_pci_dev =qdev_new (TYPE_UNI_NORTH_PCI_HOST_BRIDGE ); + uninorth_pci_dev =qdev_new_orphan (TYPE_UNI_NORTH_PCI_HOST_BRIDGE );qdev_prop_set_uint32 (uninorth_pci_dev,"ofw-addr" ,0xf2000000 ); s =SYS_BUS_DEVICE (uninorth_pci_dev);sysbus_realize_and_unref (s, &error_fatal);
@@ -408,10 +408,10 @@ static void ppc_core99_init(MachineState *machine) } adb_bus =qdev_get_child_bus (dev,"adb.0" ); - dev =qdev_new (TYPE_ADB_KEYBOARD ); + dev =qdev_new_orphan (TYPE_ADB_KEYBOARD );qdev_realize_and_unref (dev, adb_bus, &error_fatal); - dev =qdev_new (TYPE_ADB_MOUSE ); + dev =qdev_new_orphan (TYPE_ADB_MOUSE );qdev_realize_and_unref (dev, adb_bus, &error_fatal); }
@@ -453,7 +453,7 @@ static void ppc_core99_init(MachineState *machine)move the NVRAM out of ROM again for KVM */ nvram_addr =0xFFE00000 ; } - dev =qdev_new (TYPE_MACIO_NVRAM ); + dev =qdev_new_orphan (TYPE_MACIO_NVRAM );qdev_prop_set_uint32 (dev,"size" ,MACIO_NVRAM_SIZE );qdev_prop_set_uint32 (dev,"it_shift" ,1 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -462,7 +462,7 @@ static void ppc_core99_init(MachineState *machine)pmac_format_nvram_partition (nvr,MACIO_NVRAM_SIZE );/* No PCI init: the BIOS will do it */ - dev =qdev_new (TYPE_FW_CFG_MEM ); + dev =qdev_new_orphan (TYPE_FW_CFG_MEM ); fw_cfg =FW_CFG (dev);qdev_prop_set_uint32 (dev,"data_width" ,1 );qdev_prop_set_bit (dev,"dma_enabled" , false);
hw/ppc/mac_oldworld.c +4 -4
@@ -212,7 +212,7 @@ static void ppc_heathrow_init(MachineState *machine) }/* Grackle PCI host bridge */ - grackle_dev =qdev_new (TYPE_GRACKLE_PCI_HOST_BRIDGE ); + grackle_dev =qdev_new_orphan (TYPE_GRACKLE_PCI_HOST_BRIDGE );qdev_prop_set_uint32 (grackle_dev,"ofw-addr" ,0x80000000 ); s =SYS_BUS_DEVICE (grackle_dev);sysbus_realize_and_unref (s, &error_fatal);
@@ -279,9 +279,9 @@ static void ppc_heathrow_init(MachineState *machine)/* MacIO CUDA/ADB */ dev =DEVICE (object_resolve_path_component (macio,"cuda" )); adb_bus =qdev_get_child_bus (dev,"adb.0" ); - dev =qdev_new (TYPE_ADB_KEYBOARD ); + dev =qdev_new_orphan (TYPE_ADB_KEYBOARD );qdev_realize_and_unref (dev, adb_bus, &error_fatal); - dev =qdev_new (TYPE_ADB_MOUSE ); + dev =qdev_new_orphan (TYPE_ADB_MOUSE );qdev_realize_and_unref (dev, adb_bus, &error_fatal);if (machine_usb (machine)) {
@@ -303,7 +303,7 @@ static void ppc_heathrow_init(MachineState *machine)/* No PCI init: the BIOS will do it */ - dev =qdev_new (TYPE_FW_CFG_MEM ); + dev =qdev_new_orphan (TYPE_FW_CFG_MEM ); fw_cfg =FW_CFG (dev);qdev_prop_set_uint32 (dev,"data_width" ,1 );qdev_prop_set_bit (dev,"dma_enabled" , false);
hw/ppc/pnv.c +2 -2
@@ -1127,7 +1127,7 @@ static void pnv_init(MachineState *machine)/* * Create our simple PNOR device */ - dev =qdev_new (TYPE_PNV_PNOR ); + dev =qdev_new_orphan (TYPE_PNV_PNOR ); pnor =drive_get (IF_MTD ,0 ,0 );if (!pnor &&defaults_enabled ()) { fw_filename =qemu_find_file (QEMU_FILE_TYPE_BIOS ,PNOR_FILE_NAME );
@@ -1269,7 +1269,7 @@ static void pnv_init(MachineState *machine) pnv->chips = g_new0(PnvChip *, pnv->num_chips);for (i =0 ; i < pnv->num_chips; i++) {char chip_name[32 ]; -Object *chip =OBJECT (qdev_new (chip_typename)); +Object *chip =OBJECT (qdev_new_orphan (chip_typename));uint64_t chip_ram_size =pnv_chip_get_ram_size (pnv, i); pnv->chips[i] =PNV_CHIP (chip);
hw/ppc/pnv_bmc.c +1 -1
@@ -299,7 +299,7 @@ IPMIBmc *pnv_bmc_create(PnvPnor *pnor) {DeviceState *dev; - dev =qdev_new (TYPE_IPMI_BMC_SIMULATOR ); + dev =qdev_new_orphan (TYPE_IPMI_BMC_SIMULATOR );qdev_realize (dev,NULL , &error_fatal);pnv_bmc_set_pnor (IPMI_BMC (dev), pnor);
hw/ppc/ppc440_bamboo.c +2 -2
@@ -162,7 +162,7 @@ static void bamboo_init(MachineState *machine)ppc_dcr_init (env,NULL ,NULL );/* interrupt controller */ - uicdev =qdev_new (TYPE_PPC_UIC ); + uicdev =qdev_new_orphan (TYPE_PPC_UIC );ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (uicdev), cpu, &error_fatal);object_unref (OBJECT (uicdev)); uicsbd =SYS_BUS_DEVICE (uicdev);
@@ -172,7 +172,7 @@ static void bamboo_init(MachineState *machine) qdev_get_gpio_in(DEVICE(cpu), PPC40x_INPUT_CINT));/* SDRAM controller */ - dev =qdev_new (TYPE_PPC4xx_SDRAM_DDR); + dev =qdev_new_orphan (TYPE_PPC4xx_SDRAM_DDR);object_property_set_link (OBJECT (dev),"dram" ,OBJECT (machine->ram), &error_abort);ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (dev), cpu, &error_fatal);
hw/ppc/prep.c +2 -2
@@ -289,7 +289,7 @@ static void ibm_40p_init(MachineState *machine)g_free (filename);/* PCI host */ - dev =qdev_new ("raven-pcihost" ); + dev =qdev_new_orphan ("raven-pcihost" ); pcihost =SYS_BUS_DEVICE (dev);object_property_add_child (qdev_get_machine (),"raven" ,OBJECT (dev));sysbus_realize_and_unref (pcihost, &error_fatal);
@@ -363,7 +363,7 @@ static void ibm_40p_init(MachineState *machine) }/* Prepare firmware configuration for OpenBIOS */ - dev =qdev_new (TYPE_FW_CFG_MEM ); + dev =qdev_new_orphan (TYPE_FW_CFG_MEM ); fw_cfg =FW_CFG (dev);qdev_prop_set_uint32 (dev,"data_width" ,1 );qdev_prop_set_bit (dev,"dma_enabled" , false);
hw/ppc/sam460ex.c +8 -8
@@ -275,7 +275,7 @@ static void sam460ex_init(MachineState *machine)ppc_dcr_init (env,NULL ,NULL );/* PLB arbitrer */ - dev =qdev_new (TYPE_PPC4xx_PLB); + dev =qdev_new_orphan (TYPE_PPC4xx_PLB);ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (dev), cpu, &error_fatal);object_unref (OBJECT (dev));
@@ -291,7 +291,7 @@ static void sam460ex_init(MachineState *machine)*/ const int input_ints[] = {-1 ,30 ,10 ,16 }; - uic[i] =qdev_new (TYPE_PPC_UIC ); + uic[i] =qdev_new_orphan (TYPE_PPC_UIC );qdev_prop_set_uint32 (uic[i],"dcr-base" ,0xc0 + i *0x10 );ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (uic[i]), cpu, &error_fatal);object_unref (OBJECT (uic[i]));
@@ -321,7 +321,7 @@ static void sam460ex_init(MachineState *machine)error_report ("Memory below 64 MiB is not supported" );exit (1 ); } - dev =qdev_new (TYPE_PPC4xx_SDRAM_DDR2); + dev =qdev_new_orphan (TYPE_PPC4xx_SDRAM_DDR2);object_property_set_link (OBJECT (dev),"dram" ,OBJECT (machine->ram), &error_abort);/*
@@ -351,7 +351,7 @@ static void sam460ex_init(MachineState *machine) qdev_get_gpio_in(uic[0], 3));/* External bus controller */ - dev =qdev_new (TYPE_PPC4xx_EBC); + dev =qdev_new_orphan (TYPE_PPC4xx_EBC);ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (dev), cpu, &error_fatal);object_unref (OBJECT (dev));
@@ -365,7 +365,7 @@ static void sam460ex_init(MachineState *machine)ppc4xx_sdr_init (env);/* MAL */ - dev =qdev_new (TYPE_PPC4xx_MAL); + dev =qdev_new_orphan (TYPE_PPC4xx_MAL);qdev_prop_set_uint8 (dev,"txc-num" ,4 );qdev_prop_set_uint8 (dev,"rxc-num" ,16 );ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (dev), cpu, &error_fatal);
@@ -389,7 +389,7 @@ static void sam460ex_init(MachineState *machine)/* USB */ sysbus_create_simple (TYPE_PPC4xx_EHCI,0x4bffd0400 ,qdev_get_gpio_in (uic[2 ],29 )); - dev =qdev_new ("sysbus-ohci" ); + dev =qdev_new_orphan ("sysbus-ohci" );qdev_prop_set_string (dev,"masterbus" ,"usb-bus.0" );qdev_prop_set_uint32 (dev,"num-ports" ,6 ); sbdev =SYS_BUS_DEVICE (dev);
@@ -402,13 +402,13 @@ static void sam460ex_init(MachineState *machine)usb_create_simple (usb_bus,"usb-mouse" );/* PCIe buses */ - dev =qdev_new (TYPE_PPC460EX_PCIE_HOST ); + dev =qdev_new_orphan (TYPE_PPC460EX_PCIE_HOST );qdev_prop_set_int32 (dev,"busnum" ,0 );qdev_prop_set_int32 (dev,"dcrn-base" ,PCIE0_DCRN_BASE );object_property_set_link (OBJECT (dev),"cpu" ,OBJECT (cpu), &error_abort);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); - dev =qdev_new (TYPE_PPC460EX_PCIE_HOST ); + dev =qdev_new_orphan (TYPE_PPC460EX_PCIE_HOST );qdev_prop_set_int32 (dev,"busnum" ,1 );qdev_prop_set_int32 (dev,"dcrn-base" ,PCIE1_DCRN_BASE );object_property_set_link (OBJECT (dev),"cpu" ,OBJECT (cpu), &error_abort);
hw/ppc/spapr.c +2 -2
@@ -1885,7 +1885,7 @@ static void spapr_machine_reset(MachineState *machine, ResetType type)static void spapr_create_nvram (SpaprMachineState *spapr) { -DeviceState *dev =qdev_new ("spapr-nvram" ); +DeviceState *dev =qdev_new_orphan ("spapr-nvram" );DriveInfo *dinfo =drive_get (IF_PFLASH ,0 ,0 );if (dinfo) {
@@ -2799,7 +2799,7 @@ static PCIHostState *spapr_create_default_phb(void) {DeviceState *dev; - dev =qdev_new (TYPE_SPAPR_PCI_HOST_BRIDGE ); + dev =qdev_new_orphan (TYPE_SPAPR_PCI_HOST_BRIDGE );qdev_prop_set_uint32 (dev,"index" ,0 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/ppc/spapr_irq.c +1 -1
@@ -312,7 +312,7 @@ void spapr_irq_init(SpaprMachineState *spapr, Error **errp)DeviceState *dev;int i; - dev =qdev_new (TYPE_SPAPR_XIVE ); + dev =qdev_new_orphan (TYPE_SPAPR_XIVE );qdev_prop_set_uint32 (dev,"nr-irqs" ,SPAPR_NR_XIRQS +SPAPR_IRQ_NR_IPIS );/* * 8 XIVE END structures per CPU. One for each available
hw/ppc/spapr_vio.c +1 -1
@@ -564,7 +564,7 @@ SpaprVioBus *spapr_vio_bus_init(void)DeviceState *dev;/* Create bridge device */ - dev =qdev_new (TYPE_SPAPR_VIO_BRIDGE ); + dev =qdev_new_orphan (TYPE_SPAPR_VIO_BRIDGE );/* Create bus on bridge device */ qbus =qbus_new (TYPE_SPAPR_VIO_BUS , dev,"spapr-vio" );
hw/ppc/virtex_ml507.c +3 -3
@@ -84,7 +84,7 @@ static PowerPCCPU *ppc440_init_xilinx(const char *cpu_type, uint32_t sysclk)ppc_dcr_init (env,NULL ,NULL );/* interrupt controller */ - uicdev =qdev_new (TYPE_PPC_UIC ); + uicdev =qdev_new_orphan (TYPE_PPC_UIC );ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (uicdev), cpu, &error_fatal);object_unref (OBJECT (uicdev)); uicsbd =SYS_BUS_DEVICE (uicdev);
@@ -218,7 +218,7 @@ static void virtex_init(MachineState *machine) 64 * KiB, 1, 0x89, 0x18, 0x0000, 0x0, 1); cpu_irq =qdev_get_gpio_in (DEVICE (cpu), PPC40x_INPUT_INT); - dev =qdev_new ("xlnx.xps-intc" ); + dev =qdev_new_orphan ("xlnx.xps-intc" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_BIG );qdev_prop_set_uint32 (dev,"kind-of-intr" ,0 );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -232,7 +232,7 @@ static void virtex_init(MachineState *machine) 115200, serial_hd(0), DEVICE_LITTLE_ENDIAN);/* 2 timers at irq 2 @ 62 Mhz. */ - dev =qdev_new ("xlnx.xps-timer" ); + dev =qdev_new_orphan ("xlnx.xps-timer" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_BIG );qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,62 *1000000 );
hw/remote/machine.c +1 -1
@@ -39,7 +39,7 @@ static void remote_machine_init(MachineState *machine) pci_memory =g_new (MemoryRegion,1 );memory_region_init (pci_memory,NULL ,"pci" ,UINT64_MAX ); - rem_host =REMOTE_PCIHOST (qdev_new (TYPE_REMOTE_PCIHOST )); + rem_host =REMOTE_PCIHOST (qdev_new_orphan (TYPE_REMOTE_PCIHOST )); rem_host->mr_pci_mem = pci_memory; rem_host->mr_sys_mem = system_memory;
hw/riscv/boston-aia.c +2 -2
@@ -305,7 +305,7 @@ xilinx_pcie_init(MemoryRegion *sys_mem, uint32_t bus_nr,DeviceState *dev;MemoryRegion *cfg, *mmio; - dev =qdev_new (TYPE_XILINX_PCIE_HOST ); + dev =qdev_new_orphan (TYPE_XILINX_PCIE_HOST );qdev_prop_set_uint32 (dev,"bus_nr" , bus_nr);qdev_prop_set_uint64 (dev,"cfg_base" , cfg_base);
@@ -352,7 +352,7 @@ static void boston_mach_init(MachineState *machine)exit (1 ); } - dev =qdev_new (TYPE_MIPS_BOSTON_AIA ); + dev =qdev_new_orphan (TYPE_MIPS_BOSTON_AIA );sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); s =BOSTON (dev);
hw/riscv/microblaze-v-generic.c +7 -7
@@ -79,7 +79,7 @@ static void mb_v_generic_init(MachineState *machine) ram_size, &error_fatal);memory_region_add_subregion (sysmem, ddr_base, phys_ram); - dev =qdev_new ("xlnx.xps-intc" ); + dev =qdev_new_orphan ("xlnx.xps-intc" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint32 (dev,"kind-of-intr" ,1 <<UARTLITE_IRQ );
@@ -92,7 +92,7 @@ static void mb_v_generic_init(MachineState *machine) }/* Uartlite */ - dev =qdev_new (TYPE_XILINX_UARTLITE ); + dev =qdev_new_orphan (TYPE_XILINX_UARTLITE );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 ));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -105,7 +105,7 @@ static void mb_v_generic_init(MachineState *machine) DEVICE_LITTLE_ENDIAN);/* 2 timers at irq 0 @ 100 Mhz. */ - dev =qdev_new ("xlnx.xps-timer" ); + dev =qdev_new_orphan ("xlnx.xps-timer" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,100000000 );
@@ -114,7 +114,7 @@ static void mb_v_generic_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[TIMER_IRQ ]);/* 2 timers at irq 3 @ 100 Mhz. */ - dev =qdev_new ("xlnx.xps-timer" ); + dev =qdev_new_orphan ("xlnx.xps-timer" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qdev_prop_set_uint32 (dev,"one-timer-only" ,0 );qdev_prop_set_uint32 (dev,"clock-frequency" ,100000000 );
@@ -123,7 +123,7 @@ static void mb_v_generic_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[TIMER_IRQ2 ]);/* Emaclite */ - dev =qdev_new ("xlnx.xps-ethernetlite" ); + dev =qdev_new_orphan ("xlnx.xps-ethernetlite" );qdev_prop_set_enum (dev,"endianness" ,ENDIAN_MODE_LITTLE );qemu_configure_nic_device (dev, true,NULL );qdev_prop_set_uint32 (dev,"tx-ping-pong" ,0 );
@@ -133,8 +133,8 @@ static void mb_v_generic_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , irq[ETHLITE_IRQ ]);/* axi ethernet and dma initialization. */ - eth0 =qdev_new ("xlnx.axi-ethernet" ); - dma =qdev_new ("xlnx.axi-dma" ); + eth0 =qdev_new_orphan ("xlnx.axi-ethernet" ); + dma =qdev_new_orphan ("xlnx.axi-dma" );/* FIXME: attach to the sysbus instead */ object_property_add_child (qdev_get_machine (),"xilinx-eth" ,OBJECT (eth0));
hw/riscv/microchip_pfsoc.c +1 -1
@@ -580,7 +580,7 @@ static void microchip_icicle_kit_machine_init(MachineState *machine)/* Attach an SD card */ if (dinfo) {CadenceSDHCIState *sdhci = &(s->soc.sdhci); -DeviceState *card =qdev_new (TYPE_SD_CARD ); +DeviceState *card =qdev_new_orphan (TYPE_SD_CARD );qdev_prop_set_drive_err (card,"drive" ,blk_by_legacy_dinfo (dinfo), &error_fatal);
hw/riscv/sifive_u.c +2 -2
@@ -593,7 +593,7 @@ static void sifive_u_machine_init(MachineState *machine) sizeof(reset_vec), kernel_entry);/* Connect an SPI flash to SPI0 */ - flash_dev =qdev_new ("is25wp256" ); + flash_dev =qdev_new_orphan ("is25wp256" ); dinfo =drive_get (IF_MTD ,0 ,0 );if (dinfo) { qdev_prop_set_drive_err(flash_dev, "drive",
@@ -613,7 +613,7 @@ static void sifive_u_machine_init(MachineState *machine) dinfo =drive_get (IF_SD ,0 ,0 ); blk = dinfo ?blk_by_legacy_dinfo (dinfo) :NULL ; - card_dev =qdev_new (TYPE_SD_CARD_SPI ); + card_dev =qdev_new_orphan (TYPE_SD_CARD_SPI );qdev_prop_set_drive_err (card_dev,"drive" , blk, &error_fatal); qdev_realize_and_unref(card_dev, qdev_get_child_bus(sd_dev, "sd-bus"),
hw/riscv/virt.c +4 -4
@@ -125,7 +125,7 @@ static PFlashCFI01 *virt_flash_create1(RISCVVirtState *s,* Create a single flash device. We use the same parameters as * the flash devices on the ARM virt board. */ -DeviceState *dev =qdev_new (TYPE_PFLASH_CFI01 ); +DeviceState *dev =qdev_new_orphan (TYPE_PFLASH_CFI01 );qdev_prop_set_uint64 (dev,"sector-length" ,VIRT_FLASH_SECTOR_SIZE );qdev_prop_set_uint8 (dev,"width" ,4 );
@@ -1050,7 +1050,7 @@ static inline DeviceState *gpex_pcie_init(MemoryRegion *sys_mem,qemu_irq irq;int i; - dev =qdev_new (TYPE_GPEX_HOST ); + dev =qdev_new_orphan (TYPE_GPEX_HOST );/* Set GPEX object properties for the virt machine */ object_property_set_uint(OBJECT(dev), PCI_HOST_ECAM_BASE,
@@ -1142,7 +1142,7 @@ static void create_platform_bus(RISCVVirtState *s, DeviceState *irqchip)int i;MemoryRegion *sysmem =get_system_memory (); - dev =qdev_new (TYPE_PLATFORM_BUS_DEVICE ); + dev =qdev_new_orphan (TYPE_PLATFORM_BUS_DEVICE ); dev->id =g_strdup (TYPE_PLATFORM_BUS_DEVICE );qdev_prop_set_uint32 (dev,"num_irqs" ,VIRT_PLATFORM_BUS_NUM_IRQS );qdev_prop_set_uint32 (dev,"mmio_size" , s->memmap[VIRT_PLATFORM_BUS ].size);
@@ -1508,7 +1508,7 @@ static void virt_machine_init(MachineState *machine) }if (virt_is_iommu_sys_enabled (s)) { -DeviceState *iommu_sys =qdev_new (TYPE_RISCV_IOMMU_SYS ); +DeviceState *iommu_sys =qdev_new_orphan (TYPE_RISCV_IOMMU_SYS ); object_property_set_uint(OBJECT(iommu_sys), "addr", s->memmap[VIRT_IOMMU_SYS].base,
hw/rtc/sun4v-rtc.c +1 -1
@@ -57,7 +57,7 @@ void sun4v_rtc_init(hwaddr addr)DeviceState *dev;SysBusDevice *s; - dev =qdev_new (TYPE_SUN4V_RTC ); + dev =qdev_new_orphan (TYPE_SUN4V_RTC ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);
hw/s390x/ap-bridge.c +1 -1
@@ -49,7 +49,7 @@ void s390_init_ap(void) }/* Create bridge device */ - dev =qdev_new (TYPE_AP_BRIDGE ); + dev =qdev_new_orphan (TYPE_AP_BRIDGE );object_property_add_child (qdev_get_machine (),TYPE_AP_BRIDGE ,OBJECT (dev));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/s390x/css-bridge.c +1 -1
@@ -92,7 +92,7 @@ VirtualCssBus *virtual_css_bus_init(void)DeviceState *dev;/* Create bridge device */ - dev =qdev_new (TYPE_VIRTUAL_CSS_BRIDGE ); + dev =qdev_new_orphan (TYPE_VIRTUAL_CSS_BRIDGE );object_property_add_child (qdev_get_machine (),TYPE_VIRTUAL_CSS_BRIDGE ,OBJECT (dev));
hw/s390x/s390-pci-bus.c +1 -1
@@ -967,7 +967,7 @@ static S390PCIBusDevice *s390_pci_device_new(S390pciState *s,Error *local_err =NULL ;DeviceState *dev; - dev =qdev_try_new (TYPE_S390_PCI_DEVICE ); + dev =qdev_try_new_orphan (TYPE_S390_PCI_DEVICE );if (!dev) {error_setg (errp,"zPCI device could not be created" );return NULL ;
hw/s390x/s390-virtio-ccw.c +3 -3
@@ -253,7 +253,7 @@ static void s390_create_sclpconsole(SCLPDevice *sclp,BusState *ev_fac_bus =sclp_get_event_facility_bus (ef);DeviceState *dev; - dev =qdev_new (type); + dev =qdev_new_orphan (type);object_property_add_child (OBJECT (ef), type,OBJECT (dev));qdev_prop_set_chr (dev,"chardev" , chardev);qdev_realize_and_unref (dev, ev_fac_bus, &error_fatal);
@@ -265,7 +265,7 @@ static void s390_create_sclpcpi(SCLPDevice *sclp)BusState *ev_fac_bus =sclp_get_event_facility_bus (ef);DeviceState *dev; - dev =qdev_new (TYPE_SCLP_EVENT_CPI ); + dev =qdev_new_orphan (TYPE_SCLP_EVENT_CPI );object_property_add_child (OBJECT (ef),"sclpcpi" ,OBJECT (dev));qdev_realize_and_unref (dev, ev_fac_bus, &error_fatal); }
@@ -309,7 +309,7 @@ static void ccw_init(MachineState *machine) machine->firmware ?:"s390-ccw.img" , true); - dev =qdev_new (TYPE_S390_PCI_HOST_BRIDGE ); + dev =qdev_new_orphan (TYPE_S390_PCI_HOST_BRIDGE );object_property_add_child (qdev_get_machine (),TYPE_S390_PCI_HOST_BRIDGE ,OBJECT (dev));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/scsi/lasi_ncr710.c +1 -1
@@ -231,7 +231,7 @@ DeviceState *lasi_ncr710_init(MemoryRegion *addr_space, hwaddr hpa,LasiNCR710State *s;SysBusDevice *sbd; - dev =qdev_new (TYPE_LASI_NCR710 ); + dev =qdev_new_orphan (TYPE_LASI_NCR710 ); s =LASI_NCR710 (dev); sbd =SYS_BUS_DEVICE (dev); s->lasi_irq = irq;
hw/scsi/ncr53c710.c +2 -2
@@ -2376,7 +2376,7 @@ DeviceState *ncr710_device_create_sysbus(hwaddr addr, qemu_irq irq)DeviceState *dev;SysBusDevice *sysbus; - dev =qdev_new (TYPE_SYSBUS_NCR710_SCSI ); + dev =qdev_new_orphan (TYPE_SYSBUS_NCR710_SCSI ); sysbus =SYS_BUS_DEVICE (dev);qdev_realize_and_unref (dev,NULL , &error_abort);
@@ -2394,7 +2394,7 @@ DeviceState *ncr53c710_init(MemoryRegion *address_space, hwaddr addr,/* trace_ncr710_device_init(addr); */ - dev =qdev_new (TYPE_SYSBUS_NCR710_SCSI ); + dev =qdev_new_orphan (TYPE_SYSBUS_NCR710_SCSI ); sysbus =SYS_BUS_DEVICE (dev);qdev_realize_and_unref (dev,NULL , &error_abort);
hw/scsi/scsi-bus.c +1 -1
@@ -445,7 +445,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk, driver ="scsi-hd" ; } } - dev =qdev_new (driver); + dev =qdev_new_orphan (driver); name =g_strdup_printf ("legacy[%d]" , unit);object_property_add_child (OBJECT (bus), name,OBJECT (dev));g_free (name);
hw/scsi/spapr_vscsi.c +1 -1
@@ -1235,7 +1235,7 @@ void spapr_vscsi_create(SpaprVioBus *bus) {DeviceState *dev; - dev =qdev_new ("spapr-vscsi" ); + dev =qdev_new_orphan ("spapr-vscsi" );qdev_realize_and_unref (dev, &bus->bus, &error_fatal);scsi_bus_legacy_handle_cmdline (&VIO_SPAPR_VSCSI_DEVICE (dev)->bus);
hw/sh4/r2d.c +3 -3
@@ -266,7 +266,7 @@ static void r2d_init(MachineState *machine) s =sh7750_init (cpu, address_space_mem); fpga =r2d_fpga_init (address_space_mem,0x04000000 ,sh7750_irl (s)); - dev =qdev_new ("sh_pci" ); + dev =qdev_new_orphan ("sh_pci" ); busdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (busdev, &error_fatal); pci_bus =PCI_BUS (qdev_get_child_bus (dev,"pci" ));
@@ -277,7 +277,7 @@ static void r2d_init(MachineState *machine)sysbus_connect_irq (busdev,2 , &fpga->irq[PCI_INTC ]);sysbus_connect_irq (busdev,3 , &fpga->irq[PCI_INTD ]); - dev =qdev_new ("sysbus-sm501" ); + dev =qdev_new_orphan ("sysbus-sm501" ); busdev =SYS_BUS_DEVICE (dev);qdev_prop_set_uint32 (dev,"vram-size" ,SM501_VRAM_SIZE );qdev_prop_set_uint64 (dev,"dma-offset" ,0x10000000 );
@@ -289,7 +289,7 @@ static void r2d_init(MachineState *machine)/* onboard CF (True IDE mode, Master only). */ dinfo =drive_get (IF_IDE ,0 ,0 ); - dev =qdev_new ("mmio-ide" ); + dev =qdev_new_orphan ("mmio-ide" ); busdev =SYS_BUS_DEVICE (dev);sysbus_connect_irq (busdev,0 , &fpga->irq[CF_IDE ]);qdev_prop_set_uint32 (dev,"shift" ,1 );
hw/sh4/sh7750.c +2 -2
@@ -762,7 +762,7 @@ SH7750State *sh7750_init(SuperHCPU *cpu, MemoryRegion *sysmem) cpu->env.intc_handle = &s->intc;/* SCI */ - dev =qdev_new (TYPE_SH_SERIAL ); + dev =qdev_new_orphan (TYPE_SH_SERIAL ); dev->id =g_strdup ("sci" );qdev_prop_set_chr (dev,"chardev" ,serial_hd (0 )); sb =SYS_BUS_DEVICE (dev);
@@ -779,7 +779,7 @@ SH7750State *sh7750_init(SuperHCPU *cpu, MemoryRegion *sysmem)qdev_connect_gpio_out_named (dev,"tei" ,0 , s->intc.irqs[SCI1_TEI ]);/* SCIF */ - dev =qdev_new (TYPE_SH_SERIAL ); + dev =qdev_new_orphan (TYPE_SH_SERIAL ); dev->id =g_strdup ("scif" );qdev_prop_set_chr (dev,"chardev" ,serial_hd (1 ));qdev_prop_set_uint8 (dev,"features" ,SH_SERIAL_FEAT_SCIF );
hw/sparc/leon3.c +5 -5
@@ -292,14 +292,14 @@ static void leon3_generic_hw_init(MachineState *machine)qemu_register_reset (leon3_cpu_reset, &reset_info->info[i]); } - ahb_pnp =GRLIB_AHB_PNP (qdev_new (TYPE_GRLIB_AHB_PNP )); + ahb_pnp =GRLIB_AHB_PNP (qdev_new_orphan (TYPE_GRLIB_AHB_PNP ));sysbus_realize_and_unref (SYS_BUS_DEVICE (ahb_pnp), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (ahb_pnp),0 ,LEON3_AHB_PNP_OFFSET );grlib_ahb_pnp_add_entry (ahb_pnp,0 ,0 ,GRLIB_VENDOR_GAISLER ,GRLIB_LEON3_DEV ,GRLIB_AHB_MASTER ,GRLIB_CPU_AREA ); - apb_pnp =GRLIB_APB_PNP (qdev_new (TYPE_GRLIB_APB_PNP )); + apb_pnp =GRLIB_APB_PNP (qdev_new_orphan (TYPE_GRLIB_APB_PNP ));sysbus_realize_and_unref (SYS_BUS_DEVICE (apb_pnp), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (apb_pnp),0 ,LEON3_APB_PNP_OFFSET ); grlib_ahb_pnp_add_entry(ahb_pnp, LEON3_APB_PNP_OFFSET, 0xFFF,
@@ -307,7 +307,7 @@ static void leon3_generic_hw_init(MachineState *machine) GRLIB_AHB_SLAVE, GRLIB_AHBMEM_AREA);/* Allocate IRQ manager */ - irqmpdev =qdev_new (TYPE_GRLIB_IRQMP ); + irqmpdev =qdev_new_orphan (TYPE_GRLIB_IRQMP );object_property_set_int (OBJECT (irqmpdev),"ncpus" , machine->smp.cpus, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (irqmpdev), &error_fatal);
@@ -406,7 +406,7 @@ static void leon3_generic_hw_init(MachineState *machine) }/* Allocate timers */ - dev =qdev_new (TYPE_GRLIB_GPTIMER ); + dev =qdev_new_orphan (TYPE_GRLIB_GPTIMER );qdev_prop_set_uint32 (dev,"nr-timers" ,LEON3_TIMER_COUNT );qdev_prop_set_uint32 (dev,"frequency" ,CPU_CLK );qdev_prop_set_uint32 (dev,"irq-line" ,LEON3_TIMER_IRQ );
@@ -423,7 +423,7 @@ static void leon3_generic_hw_init(MachineState *machine) 0, LEON3_TIMER_IRQ, GRLIB_APBIO_AREA);/* Allocate uart */ - dev =qdev_new (TYPE_GRLIB_APB_UART ); + dev =qdev_new_orphan (TYPE_GRLIB_APB_UART );qdev_prop_set_chr (dev,"chrdev" ,serial_hd (0 ));sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,LEON3_UART_OFFSET );
hw/sparc/sun4m.c +19 -19
@@ -280,7 +280,7 @@ static void *iommu_init(hwaddr addr, uint32_t version, qemu_irq irq)DeviceState *dev;SysBusDevice *s; - dev =qdev_new (TYPE_SUN4M_IOMMU ); + dev =qdev_new_orphan (TYPE_SUN4M_IOMMU );qdev_prop_set_uint32 (dev,"version" , version); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);
@@ -302,7 +302,7 @@ static void *sparc32_dma_init(hwaddr dma_base,SysBusPCNetState *lance;NICInfo *nd =qemu_find_nic_info ("lance" , true,NULL ); - dma =qdev_new (TYPE_SPARC32_DMA ); + dma =qdev_new_orphan (TYPE_SPARC32_DMA ); espdma =SPARC32_ESPDMA_DEVICE (object_resolve_path_component (OBJECT (dma),"espdma" ));
@@ -347,7 +347,7 @@ static DeviceState *slavio_intctl_init(hwaddr addr,SysBusDevice *s;unsigned int i, j; - dev =qdev_new ("slavio_intctl" ); + dev =qdev_new_orphan ("slavio_intctl" ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);
@@ -376,7 +376,7 @@ static void slavio_timer_init_all(hwaddr addr, qemu_irq master_irq,SysBusDevice *s;unsigned int i; - dev =qdev_new ("slavio_timer" ); + dev =qdev_new_orphan ("slavio_timer" );qdev_prop_set_uint32 (dev,"num_cpus" , num_cpus); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);
@@ -414,7 +414,7 @@ static void slavio_misc_init(hwaddr base,DeviceState *dev;SysBusDevice *s; - dev =qdev_new ("slavio_misc" ); + dev =qdev_new_orphan ("slavio_misc" ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);if (base) {
@@ -451,7 +451,7 @@ static void ecc_init(hwaddr base, qemu_irq irq, uint32_t version)DeviceState *dev;SysBusDevice *s; - dev =qdev_new ("eccmemctl" ); + dev =qdev_new_orphan ("eccmemctl" );qdev_prop_set_uint32 (dev,"version" , version); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);
@@ -467,7 +467,7 @@ static void apc_init(hwaddr power_base, qemu_irq cpu_halt)DeviceState *dev;SysBusDevice *s; - dev =qdev_new ("apc" ); + dev =qdev_new_orphan ("apc" ); s =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (s, &error_fatal);/* Power management (APC) XXX: not a Slavio device */
@@ -481,7 +481,7 @@ static void tcx_init(hwaddr addr, qemu_irq irq, int vram_size, int width,DeviceState *dev;SysBusDevice *s; - dev =qdev_new ("sun-tcx" ); + dev =qdev_new_orphan ("sun-tcx" );
Lines of this file are not shown. View the raw message.
scripts/coccinelle/qom-parent/qdev-new-orphan.cocci new file +18 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.47.1
Part of the diff is not shown here. View the raw message.
RFC PATCH v2 3/137 qdev: Reintroduce qdev_new() with a mandatory QOM parent
In reply to Alexander GrafThe previous commit vacated the qdev_new()/qdev_try_new() names. Reintroduce them with the signature we actually want:
DeviceState *qdev_new(Object *parent, const char *id,
const char *type);
which is the qdev-layer, heap-allocated dual of object_initialize_child(): the returned device is created and immediately added to the QOM composition tree as a child of @parent under @id.
Refcount contract: the initial reference is transferred to the child<> property of @parent, so on return the caller does not hold a reference. Pair with qdev_realize() (not qdev_realize_and_unref()), matching object_initialize_child()'s convention.
qdev_new_orphan() remains for callers that set the parent themselves before realize (notably qdev_device_add(), which parents under /machine/peripheral via qdev_set_id()). Later patches convert the remaining orphan callers subsystem by subsystem.
AI-used-for: code (refactoring)
--- hw/core/qdev.c | 20 ++++++++++++++++++++ include/hw/core/qdev.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)
hw/core/qdev.c +20 -0
@@ -145,6 +145,26 @@ bool qdev_set_parent_bus(DeviceState *dev, BusState *bus, Error **errp)return true; } +DeviceState *qdev_new (Object *parent,const char *id,const char *type) +{ +return DEVICE (object_new_child (parent, id, type)); +} + +DeviceState *qdev_try_new (Object *parent,const char *id,const char *type) +{ +ObjectClass *oc =module_object_class_by_name (type); +Object *obj; + +if (!oc) { +return NULL ; + } + obj =object_new_with_class (oc); +g_assert (id[0 ] && !strchr (id,'/' )); +object_property_add_child (parent, id, obj); +object_unref (obj); +return DEVICE (obj); +} +DeviceState *qdev_new_orphan (const char *name) {return DEVICE (object_new (name));
include/hw/core/qdev.h +34 -0
@@ -406,6 +406,40 @@ struct BusState {/*** Board API. This should go away once we have a machine config file. ***/ +/** +* qdev_new: Create a device and parent it in the QOM composition tree +* @parent: the QOM parent (usually the machine or containing device) +* @id: child<> property name; the device's canonical QOM path becomes +* @parent's path plus "/" plus @id +* @type: device type to create (we assert() that this type exists) +* +* Heap-allocated counterpart to object_initialize_child(). This +* allocates and initializes the device state and immediately adds it +* as a child of @parent, ready for the caller to set properties and +* then realize. +* +* The reference count of the returned device is 1, held by @parent's +* child<> property. The caller therefore does not hold a reference +* and pairs this with qdev_realize() (NOT qdev_realize_and_unref()). +* +* Return: a derived DeviceState, owned by @parent. +*/ +DeviceState *qdev_new (Object *parent,const char *id,const char *type); + +/** +* qdev_try_new: Try to create a parented device on the heap +* @parent: the QOM parent +* @id: child<> property name +* @type: device type to create +* +* This is like qdev_new(), except it returns %NULL when @type does +* not exist, rather than asserting. +* +* Return: a derived DeviceState owned by @parent, or NULL if @type +* does not exist. +*/ +DeviceState *qdev_try_new (Object *parent,const char *id,const char *type); +/** * qdev_new_orphan: Create a device on the heap * @name: device type to create (we assert() that this type exists)
Signature · 1 line
2.47.1
RFC PATCH v2 4/137 sysbus: Make sysbus_create_simple()/_varargs() take a QOM parent
In reply to Alexander GrafSysbus is by far the largest producer of orphaned onboard devices:
of the ~1180 unparented device creation sites in the tree, well over half go through sysbus_create_simple(), sysbus_create_varargs(), or qdev_new_orphan()+sysbus_realize_and_unref() open-coded.
Apply the same rename-and-reintroduce treatment as qdev_new():
mechanically rename the existing helpers to *_orphan() and reintroduce the short names with a leading (parent, id, ...) pair that plumbs down to the new qdev_new(). The parented versions call sysbus_realize() (not _and_unref) since the child<> property already holds the sole reference.
The mechanical rename part is generated by
spatch --sp-file \
scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci \
--in-place --include-headers --dir .or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \
grep -v '^subprojects/' | \
xargs sed -i \
's/\bsysbus_create_simple\b/sysbus_create_simple_orphan/g;
s/\bsysbus_create_varargs\b/sysbus_create_varargs_orphan/g'AI-used-for: code (refactoring)
--- hw/arm/allwinner-h3.c | 16 ++++----- hw/arm/collie.c | 2 +- hw/arm/exynos4210.c | 14 ++++---- hw/arm/fsl-imx6.c | 2 +- hw/arm/integratorcp.c | 18 +++++----- hw/arm/mps2.c | 6 ++-- hw/arm/musicpal.c | 18 +++++----- hw/arm/npcm7xx.c | 2 +- hw/arm/realview.c | 24 ++++++------- hw/arm/sbsa-ref.c | 6 ++-- hw/arm/stellaris.c | 8 ++--- hw/arm/strongarm.c | 10 +++--- hw/arm/versatilepb.c | 28 +++++++-------- hw/arm/vexpress.c | 20 +++++------ hw/arm/virt.c | 8 ++--- hw/arm/xilinx_zynq.c | 10 +++--- hw/core/sysbus.c | 35 +++++++++++++++++- hw/i386/kvm/clock.c | 2 +- hw/i386/kvm/xen_evtchn.c | 2 +- hw/i386/kvm/xen_gnttab.c | 2 +- hw/i386/kvm/xen_overlay.c | 2 +- hw/i386/kvm/xen_primary_console.c | 2 +- hw/i386/kvm/xen_xenstore.c | 2 +- hw/i386/microvm.c | 2 +- hw/intc/apic_common.c | 2 +- hw/loongarch/virt.c | 2 +- hw/m68k/next-cube.c | 4 +-- hw/m68k/virt.c | 2 +- hw/mips/jazz.c | 2 +- hw/mips/loongson3_virt.c | 2 +- hw/or1k/virt.c | 2 +- hw/ppc/amigaone.c | 2 +- hw/ppc/e500.c | 2 +- hw/ppc/pegasos.c | 4 +-- hw/ppc/ppc440_bamboo.c | 2 +- hw/ppc/sam460ex.c | 8 ++--- hw/riscv/virt.c | 4 +-- hw/sparc/sun4m.c | 2 +- hw/vmapple/vmapple.c | 4 +-- hw/xen/xen-pvh-common.c | 2 +- include/hw/core/sysbus.h | 36 ++++++++++++++++--- .../qom-parent/sysbus-create-orphan.cocci | 18 ++++++++++ 42 files changed, 210 insertions(+), 131 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci
hw/arm/allwinner-h3.c +8 -8
@@ -379,29 +379,29 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_EMAC));/* Universal Serial Bus */ -sysbus_create_simple (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI0 ], +sysbus_create_simple_orphan (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI0 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_EHCI0 )); -sysbus_create_simple (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI1 ], +sysbus_create_simple_orphan (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI1 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_EHCI1 )); -sysbus_create_simple (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI2 ], +sysbus_create_simple_orphan (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI2 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_EHCI2 )); -sysbus_create_simple (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI3 ], +sysbus_create_simple_orphan (TYPE_AW_H3_EHCI , s->memmap[AW_H3_DEV_EHCI3 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_EHCI3 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI0 ], +sysbus_create_simple_orphan ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI0 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI0 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI1 ], +sysbus_create_simple_orphan ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI1 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI1 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI2 ], +sysbus_create_simple_orphan ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI2 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI2 )); -sysbus_create_simple ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI3 ], +sysbus_create_simple_orphan ("sysbus-ohci" , s->memmap[AW_H3_DEV_OHCI3 ],qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_OHCI3 ));
hw/arm/collie.c +1 -1
@@ -64,7 +64,7 @@ static void collie_init(MachineState *machine) FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0); } -sysbus_create_simple ("scoop" ,0x40800000 ,NULL ); +sysbus_create_simple_orphan ("scoop" ,0x40800000 ,NULL ); collie_binfo.board_id =0x208 ;arm_load_kernel (cms->sa1110->cpu, machine, &collie_binfo);
hw/arm/exynos4210.c +7 -7
@@ -600,7 +600,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) }/* Cache controller */ -sysbus_create_simple ("l2x0" ,EXYNOS4210_L2X0_BASE_ADDR ,NULL ); +sysbus_create_simple_orphan ("l2x0" ,EXYNOS4210_L2X0_BASE_ADDR ,NULL );/* External GIC */ qdev_prop_set_uint32 (DEVICE (&s->ext_gic),"num-cpu" ,EXYNOS4210_NCPUS );
@@ -667,13 +667,13 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)* The only reason of existence at the moment is that secondary CPU boot * loader uses PMU INFORM5 register as a holding pen. */ -sysbus_create_simple ("exynos4210.pmu" ,EXYNOS4210_PMU_BASE_ADDR ,NULL ); +sysbus_create_simple_orphan ("exynos4210.pmu" ,EXYNOS4210_PMU_BASE_ADDR ,NULL ); -sysbus_create_simple ("exynos4210.clk" ,EXYNOS4210_CLK_BASE_ADDR ,NULL ); -sysbus_create_simple ("exynos4210.rng" ,EXYNOS4210_RNG_BASE_ADDR ,NULL ); +sysbus_create_simple_orphan ("exynos4210.clk" ,EXYNOS4210_CLK_BASE_ADDR ,NULL ); +sysbus_create_simple_orphan ("exynos4210.rng" ,EXYNOS4210_RNG_BASE_ADDR ,NULL );/* PWM */ - sysbus_create_varargs("exynos4210.pwm", EXYNOS4210_PWM_BASE_ADDR, + sysbus_create_varargs_orphan("exynos4210.pwm", EXYNOS4210_PWM_BASE_ADDR, s->irq_table[exynos4210_get_irq(22, 0)], s->irq_table[exynos4210_get_irq(22, 1)], s->irq_table[exynos4210_get_irq(22, 2)],
@@ -681,7 +681,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) s->irq_table[exynos4210_get_irq (22 ,4 )], NULL);/* RTC */ -sysbus_create_varargs ("exynos4210.rtc" ,EXYNOS4210_RTC_BASE_ADDR , +sysbus_create_varargs_orphan ("exynos4210.rtc" ,EXYNOS4210_RTC_BASE_ADDR , s->irq_table[exynos4210_get_irq (23 ,0 )], s->irq_table[exynos4210_get_irq (23 ,1 )],NULL );
@@ -784,7 +784,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)sysbus_connect_irq (busdev, n, s->irq_table[exynos4210_get_irq (11 , n)]); } -sysbus_create_simple (TYPE_EXYNOS4210_EHCI ,EXYNOS4210_EHCI_BASE_ADDR , +sysbus_create_simple_orphan (TYPE_EXYNOS4210_EHCI ,EXYNOS4210_EHCI_BASE_ADDR , s->irq_table[exynos4210_get_irq (28 ,3 )]);/*** DMA controllers ***/
hw/arm/fsl-imx6.c +1 -1
@@ -168,7 +168,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) }/* L2 cache controller */ -sysbus_create_simple ("l2x0" ,FSL_IMX6_PL310_ADDR ,NULL ); +sysbus_create_simple_orphan ("l2x0" ,FSL_IMX6_PL310_ADDR ,NULL );if (!sysbus_realize (SYS_BUS_DEVICE (&s->ccm), errp)) {return ;
hw/arm/integratorcp.c +9 -9
@@ -626,26 +626,26 @@ static void integratorcp_init(MachineState *machine)sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);sysbus_mmio_map ((SysBusDevice *)dev,0 ,0x10000000 ); - dev =sysbus_create_varargs (TYPE_INTEGRATOR_PIC ,0x14000000 , + dev =sysbus_create_varargs_orphan (TYPE_INTEGRATOR_PIC ,0x14000000 ,qdev_get_gpio_in (DEVICE (cpu),ARM_CPU_IRQ ),qdev_get_gpio_in (DEVICE (cpu),ARM_CPU_FIQ ),NULL );for (i =0 ; i <32 ; i++) { pic[i] =qdev_get_gpio_in (dev, i); } - sic =sysbus_create_simple (TYPE_INTEGRATOR_PIC ,0xca000000 , pic[26 ]); -sysbus_create_varargs ("integrator_pit" ,0x13000000 , + sic =sysbus_create_simple_orphan (TYPE_INTEGRATOR_PIC ,0xca000000 , pic[26 ]); +sysbus_create_varargs_orphan ("integrator_pit" ,0x13000000 , pic[5 ], pic[6 ], pic[7 ],NULL ); -sysbus_create_simple ("pl031" ,0x15000000 , pic[8 ]); +sysbus_create_simple_orphan ("pl031" ,0x15000000 , pic[8 ]);pl011_create (0x16000000 , pic[1 ],serial_hd (0 ));pl011_create (0x17000000 , pic[2 ],serial_hd (1 )); - icp =sysbus_create_simple (TYPE_ICP_CONTROL_REGS ,0xcb000000 , + icp =sysbus_create_simple_orphan (TYPE_ICP_CONTROL_REGS ,0xcb000000 ,qdev_get_gpio_in (sic,3 )); -sysbus_create_simple ("pl050_keyboard" ,0x18000000 , pic[3 ]); -sysbus_create_simple ("pl050_mouse" ,0x19000000 , pic[4 ]); -sysbus_create_simple (TYPE_INTEGRATOR_DEBUG ,0x1a000000 ,0 ); +sysbus_create_simple_orphan ("pl050_keyboard" ,0x18000000 , pic[3 ]); +sysbus_create_simple_orphan ("pl050_mouse" ,0x19000000 , pic[4 ]); +sysbus_create_simple_orphan (TYPE_INTEGRATOR_DEBUG ,0x1a000000 ,0 ); - dev =sysbus_create_varargs ("pl181" ,0x1c000000 , pic[23 ], pic[24 ],NULL ); + dev =sysbus_create_varargs_orphan ("pl181" ,0x1c000000 , pic[23 ], pic[24 ],NULL );qdev_connect_gpio_out_named (dev,"card-read-only" ,0 ,qdev_get_gpio_in_named (icp,ICP_GPIO_MMC_WPROT ,0 )); qdev_connect_gpio_out_named(dev, "card-inserted", 0,
hw/arm/mps2.c +3 -3
@@ -416,7 +416,7 @@ static void mps2_common_init(MachineState *machine)qdev_prop_set_uint32 (DEVICE (&mms->fpgaio),"prescale-clk" ,25000000 );sysbus_realize (SYS_BUS_DEVICE (&mms->fpgaio), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (&mms->fpgaio),0 ,0x40028000 ); -sysbus_create_simple (TYPE_PL022 ,0x40025000 ,/* External ADC */ +sysbus_create_simple_orphan (TYPE_PL022 ,0x40025000 ,/* External ADC */ qdev_get_gpio_in (armv7m,22 ));for (i =0 ; i <2 ; i++) {static const int spi_irqno[] = {11 ,24 };
@@ -435,7 +435,7 @@ static void mps2_common_init(MachineState *machine)qdev_connect_gpio_out (orgate_dev,0 ,qdev_get_gpio_in (armv7m, spi_irqno[i]));for (j =0 ; j <2 ; j++) { -sysbus_create_simple (TYPE_PL022 , spibase[2 * i + j], +sysbus_create_simple_orphan (TYPE_PL022 , spibase[2 * i + j],qdev_get_gpio_in (orgate_dev, j)); } }
@@ -446,7 +446,7 @@ static void mps2_common_init(MachineState *machine) 0x4002a000}; /* Shield1 */DeviceState *dev; - dev =sysbus_create_simple (TYPE_ARM_SBCON_I2C , i2cbase[i],NULL ); + dev =sysbus_create_simple_orphan (TYPE_ARM_SBCON_I2C , i2cbase[i],NULL );if (i <2 ) {/* * internal-only bus: mark it full to avoid user-created
hw/arm/musicpal.c +9 -9
@@ -1240,9 +1240,9 @@ static void musicpal_init(MachineState *machine) &error_fatal);memory_region_add_subregion (address_space_mem,MP_SRAM_BASE , sram); - pic =sysbus_create_simple (TYPE_MV88W8618_PIC ,MP_PIC_BASE , + pic =sysbus_create_simple_orphan (TYPE_MV88W8618_PIC ,MP_PIC_BASE ,qdev_get_gpio_in (DEVICE (cpu),ARM_CPU_IRQ )); - sysbus_create_varargs(TYPE_MV88W8618_PIT, MP_PIT_BASE, + sysbus_create_varargs_orphan(TYPE_MV88W8618_PIT, MP_PIT_BASE, qdev_get_gpio_in(pic, MP_TIMER1_IRQ), qdev_get_gpio_in(pic, MP_TIMER2_IRQ), qdev_get_gpio_in(pic, MP_TIMER3_IRQ),
@@ -1286,7 +1286,7 @@ static void musicpal_init(MachineState *machine)2 ,0x00BF ,0x236D ,0x0000 ,0x0000 , 0x5555, 0x2AAA, 0); } -sysbus_create_simple (TYPE_MV88W8618_FLASHCFG ,MP_FLASHCFG_BASE ,NULL ); +sysbus_create_simple_orphan (TYPE_MV88W8618_FLASHCFG ,MP_FLASHCFG_BASE ,NULL ); dev =qdev_new_orphan (TYPE_MV88W8618_ETH );qemu_configure_nic_device (dev, true,"mv88w8618" );
@@ -1297,17 +1297,17 @@ static void musicpal_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 ,qdev_get_gpio_in (pic,MP_ETH_IRQ )); -sysbus_create_simple ("mv88w8618_wlan" ,MP_WLAN_BASE ,NULL ); +sysbus_create_simple_orphan ("mv88w8618_wlan" ,MP_WLAN_BASE ,NULL ); -sysbus_create_simple (TYPE_MUSICPAL_MISC ,MP_MISC_BASE ,NULL ); +sysbus_create_simple_orphan (TYPE_MUSICPAL_MISC ,MP_MISC_BASE ,NULL ); - dev =sysbus_create_simple (TYPE_MUSICPAL_GPIO ,MP_GPIO_BASE , + dev =sysbus_create_simple_orphan (TYPE_MUSICPAL_GPIO ,MP_GPIO_BASE ,qdev_get_gpio_in (pic,MP_GPIO_IRQ )); - i2c_dev =sysbus_create_simple (TYPE_GPIO_I2C ,-1 ,NULL ); + i2c_dev =sysbus_create_simple_orphan (TYPE_GPIO_I2C ,-1 ,NULL ); i2c = (I2CBus *)qdev_get_child_bus (i2c_dev,"i2c" ); - lcd_dev =sysbus_create_simple (TYPE_MUSICPAL_LCD ,MP_LCD_BASE ,NULL ); - key_dev =sysbus_create_simple (TYPE_MUSICPAL_KEY ,-1 ,NULL ); + lcd_dev =sysbus_create_simple_orphan (TYPE_MUSICPAL_LCD ,MP_LCD_BASE ,NULL ); + key_dev =sysbus_create_simple_orphan (TYPE_MUSICPAL_KEY ,-1 ,NULL );/* I2C read data */ qdev_connect_gpio_out(i2c_dev, 0,
hw/arm/npcm7xx.c +1 -1
@@ -521,7 +521,7 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) }/* L2 cache controller */ -sysbus_create_simple ("l2x0" ,NPCM7XX_L2C_BA ,NULL ); +sysbus_create_simple_orphan ("l2x0" ,NPCM7XX_L2C_BA ,NULL );/* System Global Control Registers (GCR). Can fail due to user input. */ object_property_set_int(OBJECT(&s->gcr), "disabled-modules",
hw/arm/realview.c +12 -12
@@ -200,13 +200,13 @@ static void realview_init(MachineState *machine,for (n =0 ; n < smp_cpus; n++) {sysbus_connect_irq (busdev, n, cpu_irq[n]); } -sysbus_create_varargs ("l2x0" , periphbase +0x2000 ,NULL ); +sysbus_create_varargs_orphan ("l2x0" , periphbase +0x2000 ,NULL );/* Both A9 and 11MPCore put the GIC CPU i/f at base + 0x100 */ realview_binfo.gic_cpu_if_addr = periphbase +0x100 ; }else {uint32_t gic_addr = is_pb ?0x1e000000 :0x10040000 ;/* For now just create the nIRQ GIC, and ignore the others. */ - dev =sysbus_create_simple (TYPE_REALVIEW_GIC , gic_addr, cpu_irq[0 ]); + dev =sysbus_create_simple_orphan (TYPE_REALVIEW_GIC , gic_addr, cpu_irq[0 ]); }for (n =0 ; n <GIC_EXT_IRQS ; n++) { pic[n] =qdev_get_gpio_in (dev, n);
@@ -221,8 +221,8 @@ static void realview_init(MachineState *machine,sysbus_mmio_map (SYS_BUS_DEVICE (pl041),0 ,0x10004000 );sysbus_connect_irq (SYS_BUS_DEVICE (pl041),0 , pic[19 ]); -sysbus_create_simple ("pl050_keyboard" ,0x10006000 , pic[20 ]); -sysbus_create_simple ("pl050_mouse" ,0x10007000 , pic[21 ]); +sysbus_create_simple_orphan ("pl050_keyboard" ,0x10006000 , pic[20 ]); +sysbus_create_simple_orphan ("pl050_mouse" ,0x10007000 , pic[21 ]);pl011_create (0x10009000 , pic[12 ],serial_hd (0 ));pl011_create (0x1000a000 , pic[13 ],serial_hd (1 ));
@@ -238,12 +238,12 @@ static void realview_init(MachineState *machine,sysbus_mmio_map (busdev,0 ,0x10030000 );sysbus_connect_irq (busdev,0 , pic[24 ]); -sysbus_create_simple ("sp804" ,0x10011000 , pic[4 ]); -sysbus_create_simple ("sp804" ,0x10012000 , pic[5 ]); +sysbus_create_simple_orphan ("sp804" ,0x10011000 , pic[4 ]); +sysbus_create_simple_orphan ("sp804" ,0x10012000 , pic[5 ]); -sysbus_create_simple ("pl061" ,0x10013000 , pic[6 ]); -sysbus_create_simple ("pl061" ,0x10014000 , pic[7 ]); - gpio2 =sysbus_create_simple ("pl061" ,0x10015000 , pic[8 ]); +sysbus_create_simple_orphan ("pl061" ,0x10013000 , pic[6 ]); +sysbus_create_simple_orphan ("pl061" ,0x10014000 , pic[7 ]); + gpio2 =sysbus_create_simple_orphan ("pl061" ,0x10015000 , pic[8 ]); dev =qdev_new_orphan ("pl111" ); object_property_set_link(OBJECT(dev), "framebuffer-memory",
@@ -252,7 +252,7 @@ static void realview_init(MachineState *machine,sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,0x10020000 );sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , pic[23 ]); - dev =sysbus_create_varargs ("pl181" ,0x10005000 , pic[17 ], pic[18 ],NULL ); + dev =sysbus_create_varargs_orphan ("pl181" ,0x10005000 , pic[17 ], pic[18 ],NULL );/* Wire up MMC card detect and read-only signals. These have * to go to both the PL061 GPIO and the sysctl register. * Note that the PL181 orders these lines (readonly,inserted)
@@ -278,7 +278,7 @@ static void realview_init(MachineState *machine, &error_fatal); } -sysbus_create_simple ("pl031" ,0x10017000 , pic[10 ]); +sysbus_create_simple_orphan ("pl031" ,0x10017000 , pic[10 ]);if (!is_pb) { dev =qdev_new_orphan ("realview_pci" );
@@ -319,7 +319,7 @@ static void realview_init(MachineState *machine,pci_init_nic_devices (pci_bus,"rtl8139" ); } - dev =sysbus_create_simple (TYPE_ARM_SBCON_I2C ,0x10002000 ,NULL ); + dev =sysbus_create_simple_orphan (TYPE_ARM_SBCON_I2C ,0x10002000 ,NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" );i2c_slave_create_simple (i2c,"ds1338" ,0x68 );
hw/arm/sbsa-ref.c +3 -3
@@ -537,7 +537,7 @@ static void create_rtc(const SBSAMachineState *sms)hwaddr base = sbsa_ref_memmap[SBSA_RTC ].base;int irq = sbsa_ref_irqmap[SBSA_RTC ]; -sysbus_create_simple ("pl031" , base,qdev_get_gpio_in (sms->gic, irq)); +sysbus_create_simple_orphan ("pl031" , base,qdev_get_gpio_in (sms->gic, irq)); }static void create_wdt (const SBSAMachineState *sms)
@@ -572,10 +572,10 @@ static void create_gpio(const SBSAMachineState *sms)hwaddr base = sbsa_ref_memmap[SBSA_GPIO ].base;int irq = sbsa_ref_irqmap[SBSA_GPIO ]; - pl061_dev =sysbus_create_simple ("pl061" , base, + pl061_dev =sysbus_create_simple_orphan ("pl061" , base,qdev_get_gpio_in (sms->gic, irq)); - gpio_key_dev =sysbus_create_simple ("gpio-key" ,-1 , + gpio_key_dev =sysbus_create_simple_orphan ("gpio-key" ,-1 ,qdev_get_gpio_in (pl061_dev,3 ));/* connect powerdown request */
hw/arm/stellaris.c +4 -4
@@ -1143,7 +1143,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)sysbus_connect_irq (SYS_BUS_DEVICE (ssys_dev),0 ,qdev_get_gpio_in (nvic,28 ));if (DEV_CAP (1 ,ADC )) { - dev = sysbus_create_varargs(TYPE_STELLARIS_ADC, 0x40038000, + dev = sysbus_create_varargs_orphan(TYPE_STELLARIS_ADC, 0x40038000, qdev_get_gpio_in(nvic, 14), qdev_get_gpio_in(nvic, 15), qdev_get_gpio_in(nvic, 16),
@@ -1189,7 +1189,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)for (i =0 ; i <NUM_GPIO ; i++) {if (DEV_CAP (4 ,GPIO (i))) { - gpio_dev[i] =sysbus_create_simple ("pl061_luminary" , gpio_addr[i], + gpio_dev[i] =sysbus_create_simple_orphan ("pl061_luminary" , gpio_addr[i],qdev_get_gpio_in (nvic, gpio_irq[i]));for (j =0 ; j <8 ; j++) {
@@ -1201,7 +1201,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)for (i =0 ; i <NUM_I2C ; i++) {if (DEV_CAP (2 ,I2C (i))) { - i2c_dev[i] =sysbus_create_simple (TYPE_STELLARIS_I2C , i2c_addr[i], + i2c_dev[i] =sysbus_create_simple_orphan (TYPE_STELLARIS_I2C , i2c_addr[i],qdev_get_gpio_in (nvic, i2c_irq[i])); }
@@ -1226,7 +1226,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) } }if (DEV_CAP (2 ,SSI )) { - dev =sysbus_create_simple ("pl022" ,0x40008000 , + dev =sysbus_create_simple_orphan ("pl022" ,0x40008000 ,qdev_get_gpio_in (nvic,7 ));if (board->peripherals &BP_OLED_SSI ) {void *bus;
hw/arm/strongarm.c +5 -5
@@ -1622,24 +1622,24 @@ StrongARMState *sa1110_init(const char *cpu_type) s->cpu =ARM_CPU (cpu_create (cpu_type)); - s->pic =sysbus_create_varargs ("strongarm_pic" ,0x90050000 , + s->pic =sysbus_create_varargs_orphan ("strongarm_pic" ,0x90050000 ,qdev_get_gpio_in (DEVICE (s->cpu),ARM_CPU_IRQ ),qdev_get_gpio_in (DEVICE (s->cpu),ARM_CPU_FIQ ),NULL ); -sysbus_create_varargs ("pxa25x-timer" ,0x90000000 , +sysbus_create_varargs_orphan ("pxa25x-timer" ,0x90000000 ,qdev_get_gpio_in (s->pic,SA_PIC_OSTC0 ),qdev_get_gpio_in (s->pic,SA_PIC_OSTC1 ),qdev_get_gpio_in (s->pic,SA_PIC_OSTC2 ),qdev_get_gpio_in (s->pic,SA_PIC_OSTC3 ),NULL ); -sysbus_create_simple (TYPE_STRONGARM_RTC ,0x90010000 , +sysbus_create_simple_orphan (TYPE_STRONGARM_RTC ,0x90010000 ,qdev_get_gpio_in (s->pic,SA_PIC_RTC_ALARM )); s->gpio =strongarm_gpio_init (0x90040000 , s->pic); - s->ppc =sysbus_create_varargs (TYPE_STRONGARM_PPC ,0x90060000 ,NULL ); + s->ppc =sysbus_create_varargs_orphan (TYPE_STRONGARM_PPC ,0x90060000 ,NULL );for (i =0 ; sa_serial[i].io_base; i++) {DeviceState *dev =qdev_new_orphan (TYPE_STRONGARM_UART );
@@ -1651,7 +1651,7 @@ StrongARMState *sa1110_init(const char *cpu_type) qdev_get_gpio_in(s->pic, sa_serial[i].irq)); } - s->ssp =sysbus_create_varargs (TYPE_STRONGARM_SSP ,0x80070000 , + s->ssp =sysbus_create_varargs_orphan (TYPE_STRONGARM_SSP ,0x80070000 ,qdev_get_gpio_in (s->pic,SA_PIC_SSP ),NULL ); s->ssp_bus = (SSIBus *)qdev_get_child_bus (s->ssp,"ssi" );
hw/arm/versatilepb.c +14 -14
@@ -232,21 +232,21 @@ static void versatile_init(MachineState *machine, int board_id)sysbus_realize_and_unref (SYS_BUS_DEVICE (sysctl), &error_fatal);sysbus_mmio_map (SYS_BUS_DEVICE (sysctl),0 ,0x10000000 ); - dev =sysbus_create_varargs ("pl190" ,0x10140000 , + dev =sysbus_create_varargs_orphan ("pl190" ,0x10140000 ,qdev_get_gpio_in (DEVICE (cpu),ARM_CPU_IRQ ),qdev_get_gpio_in (DEVICE (cpu),ARM_CPU_FIQ ),NULL );for (n =0 ; n <32 ; n++) { pic[n] =qdev_get_gpio_in (dev, n); } - dev =sysbus_create_simple (TYPE_VERSATILE_PB_SIC ,0x10003000 ,NULL ); + dev =sysbus_create_simple_orphan (TYPE_VERSATILE_PB_SIC ,0x10003000 ,NULL );for (n =0 ; n <32 ; n++) {sysbus_connect_irq (SYS_BUS_DEVICE (dev), n, pic[n]); sic[n] =qdev_get_gpio_in (dev, n); } -sysbus_create_simple ("pl050_keyboard" ,0x10006000 , sic[3 ]); -sysbus_create_simple ("pl050_mouse" ,0x10007000 , sic[4 ]); +sysbus_create_simple_orphan ("pl050_keyboard" ,0x10006000 , sic[3 ]); +sysbus_create_simple_orphan ("pl050_mouse" ,0x10007000 , sic[4 ]); dev =qdev_new_orphan ("versatile_pci" ); busdev =SYS_BUS_DEVICE (dev);
@@ -292,13 +292,13 @@ static void versatile_init(MachineState *machine, int board_id)sysbus_mmio_map (busdev,0 ,0x10130000 );sysbus_connect_irq (busdev,0 , pic[17 ]); -sysbus_create_simple ("sp804" ,0x101e2000 , pic[4 ]); -sysbus_create_simple ("sp804" ,0x101e3000 , pic[5 ]); +sysbus_create_simple_orphan ("sp804" ,0x101e2000 , pic[4 ]); +sysbus_create_simple_orphan ("sp804" ,0x101e3000 , pic[5 ]); -sysbus_create_simple ("pl061" ,0x101e4000 , pic[6 ]); -sysbus_create_simple ("pl061" ,0x101e5000 , pic[7 ]); -sysbus_create_simple ("pl061" ,0x101e6000 , pic[8 ]); -sysbus_create_simple ("pl061" ,0x101e7000 , pic[9 ]); +sysbus_create_simple_orphan ("pl061" ,0x101e4000 , pic[6 ]); +sysbus_create_simple_orphan ("pl061" ,0x101e5000 , pic[7 ]); +sysbus_create_simple_orphan ("pl061" ,0x101e6000 , pic[8 ]); +sysbus_create_simple_orphan ("pl061" ,0x101e7000 , pic[9 ]);/* The versatile/PB actually has a modified Color LCD controller that includes hardware cursor support from the PL111. */
@@ -312,7 +312,7 @@ static void versatile_init(MachineState *machine, int board_id)/* Wire up the mux control signals from the SYS_CLCD register */ qdev_connect_gpio_out (sysctl,0 ,qdev_get_gpio_in (dev,0 )); - dev =sysbus_create_varargs ("pl181" ,0x10005000 , sic[22 ], sic[1 ],NULL ); + dev =sysbus_create_varargs_orphan ("pl181" ,0x10005000 , sic[22 ], sic[1 ],NULL ); dinfo =drive_get (IF_SD ,0 ,0 );if (dinfo) {DeviceState *card;
@@ -324,7 +324,7 @@ static void versatile_init(MachineState *machine, int board_id) &error_fatal); } - dev =sysbus_create_varargs ("pl181" ,0x1000b000 , sic[23 ], sic[2 ],NULL ); + dev =sysbus_create_varargs_orphan ("pl181" ,0x1000b000 , sic[23 ], sic[2 ],NULL ); dinfo =drive_get (IF_SD ,0 ,1 );if (dinfo) {DeviceState *card;
@@ -337,9 +337,9 @@ static void versatile_init(MachineState *machine, int board_id) }/* Add PL031 Real Time Clock. */ -sysbus_create_simple ("pl031" ,0x101e8000 , pic[10 ]); +sysbus_create_simple_orphan ("pl031" ,0x101e8000 , pic[10 ]); - dev =sysbus_create_simple (TYPE_ARM_SBCON_I2C ,0x10002000 ,NULL ); + dev =sysbus_create_simple_orphan (TYPE_ARM_SBCON_I2C ,0x10002000 ,NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" );i2c_slave_create_simple (i2c,"ds1338" ,0x68 );
hw/arm/vexpress.c +10 -10
@@ -313,7 +313,7 @@ static void a9_daughterboard_init(VexpressMachineState *vms,/* 0x100e1000 PL354 Static Memory Controller */ /* 0x100e2000 System Configuration Controller */ -sysbus_create_simple ("sp804" ,0x100e4000 , pic[48 ]); +sysbus_create_simple_orphan ("sp804" ,0x100e4000 , pic[48 ]);/* 0x100e5000 SP805 Watchdog module */ /* 0x100e6000 BP147 TrustZone Protection Controller */ /* 0x100e9000 PL301 'Fast' AXI matrix */
@@ -321,7 +321,7 @@ static void a9_daughterboard_init(VexpressMachineState *vms,/* 0x100ec000 TrustZone Address Space Controller */ /* 0x10200000 CoreSight debug APB */ /* 0x1e00a000 PL310 L2 Cache Controller */ -sysbus_create_varargs ("l2x0" ,0x1e00a000 ,NULL ); +sysbus_create_varargs_orphan ("l2x0" ,0x1e00a000 ,NULL ); }/* Voltage values for SYS_CFG_VOLT daughterboard registers;
@@ -623,7 +623,7 @@ static void vexpress_common_init(MachineState *machine)sysbus_mmio_map (SYS_BUS_DEVICE (pl041),0 , map[VE_PL041 ]);sysbus_connect_irq (SYS_BUS_DEVICE (pl041),0 , pic[11 ]); - dev =sysbus_create_varargs ("pl181" , map[VE_MMCI ], pic[9 ], pic[10 ],NULL ); + dev =sysbus_create_varargs_orphan ("pl181" , map[VE_MMCI ], pic[9 ], pic[10 ],NULL );/* Wire up MMC card detect and read-only signals */ qdev_connect_gpio_out_named (dev,"card-read-only" ,0 ,qdev_get_gpio_in (sysctl,ARM_SYSCTL_GPIO_MMC_WPROT ));
@@ -640,22 +640,22 @@ static void vexpress_common_init(MachineState *machine) &error_fatal); } -sysbus_create_simple ("pl050_keyboard" , map[VE_KMI0 ], pic[12 ]); -sysbus_create_simple ("pl050_mouse" , map[VE_KMI1 ], pic[13 ]); +sysbus_create_simple_orphan ("pl050_keyboard" , map[VE_KMI0 ], pic[12 ]); +sysbus_create_simple_orphan ("pl050_mouse" , map[VE_KMI1 ], pic[13 ]);pl011_create (map[VE_UART0 ], pic[5 ],serial_hd (0 ));pl011_create (map[VE_UART1 ], pic[6 ],serial_hd (1 ));pl011_create (map[VE_UART2 ], pic[7 ],serial_hd (2 ));pl011_create (map[VE_UART3 ], pic[8 ],serial_hd (3 )); -sysbus_create_simple ("sp804" , map[VE_TIMER01 ], pic[2 ]); -sysbus_create_simple ("sp804" , map[VE_TIMER23 ], pic[3 ]); +sysbus_create_simple_orphan ("sp804" , map[VE_TIMER01 ], pic[2 ]); +sysbus_create_simple_orphan ("sp804" , map[VE_TIMER23 ], pic[3 ]); - dev =sysbus_create_simple (TYPE_ARM_SBCON_I2C , map[VE_SERIALDVI ],NULL ); + dev =sysbus_create_simple_orphan (TYPE_ARM_SBCON_I2C , map[VE_SERIALDVI ],NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" );i2c_slave_create_simple (i2c,"sii9022" ,0x39 ); -sysbus_create_simple ("pl031" , map[VE_RTC ], pic[4 ]);/* RTC */ +sysbus_create_simple_orphan ("pl031" , map[VE_RTC ], pic[4 ]);/* RTC */ /* VE_COMPACTFLASH: not modelled */
@@ -706,7 +706,7 @@ static void vexpress_common_init(MachineState *machine)* no backend is created the transport will just sit harmlessly idle. */ for (i =0 ; i <NUM_VIRTIO_TRANSPORTS ; i++) { -sysbus_create_simple ("virtio-mmio" , map[VE_VIRTIO ] +0x200 * i, +sysbus_create_simple_orphan ("virtio-mmio" , map[VE_VIRTIO ] +0x200 * i, pic[40 + i]); }
hw/arm/virt.c +4 -4
@@ -1561,7 +1561,7 @@ static void create_rtc(const VirtMachineState *vms)const char compat[] ="arm,pl031\0arm,primecell" ;MachineState *ms =MACHINE (vms); -sysbus_create_simple ("pl031" , base,qdev_get_gpio_in (vms->gic, irq)); +sysbus_create_simple_orphan ("pl031" , base,qdev_get_gpio_in (vms->gic, irq)); nodename =g_strdup_printf ("/pl031@%" PRIx64, base);qemu_fdt_add_subnode (ms->fdt, nodename);
@@ -1606,7 +1606,7 @@ static void virt_generic_error_req(Notifier *n, void *opaque)static void create_gpio_keys (char *fdt,DeviceState *pl061_dev,uint32_t phandle) { - gpio_key_dev =sysbus_create_simple ("gpio-key" ,-1 , + gpio_key_dev =sysbus_create_simple_orphan ("gpio-key" ,-1 ,qdev_get_gpio_in (pl061_dev,GPIO_PIN_POWER_BUTTON ));
@@ -1631,7 +1631,7 @@ static void create_secure_gpio_pwr(char *fdt, DeviceState *pl061_dev,DeviceState *gpio_pwr_dev;/* gpio-pwr */ - gpio_pwr_dev =sysbus_create_simple ("gpio-pwr" ,-1 ,NULL ); + gpio_pwr_dev =sysbus_create_simple_orphan ("gpio-pwr" ,-1 ,NULL );/* connect secure pl061 to gpio-pwr */ qdev_connect_gpio_out(pl061_dev, SECURE_GPIO_RESET,
@@ -1746,7 +1746,7 @@ static void create_virtio_devices(const VirtMachineState *vms)int irq = vms->irqmap[VIRT_MMIO ] + i;hwaddr base = vms->memmap[VIRT_MMIO ].base + i * size; -sysbus_create_simple ("virtio-mmio" , base, +sysbus_create_simple_orphan ("virtio-mmio" , base,qdev_get_gpio_in (vms->gic, irq)); }
hw/arm/xilinx_zynq.c +5 -5
@@ -269,7 +269,7 @@ static void zynq_init(MachineState *machine)sysbus_realize_and_unref (busdev, &error_fatal);sysbus_mmio_map (busdev,0 ,MPCORE_PERIPHBASE ); zynq_binfo.gic_cpu_if_addr =MPCORE_PERIPHBASE +0x100 ; -sysbus_create_varargs ("l2x0" ,MPCORE_PERIPHBASE +0x2000 ,NULL ); +sysbus_create_varargs_orphan ("l2x0" ,MPCORE_PERIPHBASE +0x2000 ,NULL );for (n =0 ; n < smp_cpus; n++) {/* See "hw/intc/arm_gic.h" for the IRQ line association */ DeviceState *cpudev =DEVICE (zynq_machine->cpu[n]);
@@ -287,8 +287,8 @@ static void zynq_init(MachineState *machine) n =zynq_init_spi_flashes (0xE0007000 , pic[81 -GIC_INTERNAL ], false, n); n =zynq_init_spi_flashes (0xE000D000 , pic[51 -GIC_INTERNAL ], true, n); -sysbus_create_simple (TYPE_CHIPIDEA ,0xE0002000 , pic[53 -GIC_INTERNAL ]); -sysbus_create_simple (TYPE_CHIPIDEA ,0xE0003000 , pic[76 -GIC_INTERNAL ]); +sysbus_create_simple_orphan (TYPE_CHIPIDEA ,0xE0002000 , pic[53 -GIC_INTERNAL ]); +sysbus_create_simple_orphan (TYPE_CHIPIDEA ,0xE0003000 , pic[76 -GIC_INTERNAL ]); dev =qdev_new_orphan (TYPE_CADENCE_UART ); busdev =SYS_BUS_DEVICE (dev);
@@ -307,9 +307,9 @@ static void zynq_init(MachineState *machine)sysbus_mmio_map (busdev,0 ,0xE0001000 );sysbus_connect_irq (busdev,0 , pic[82 -GIC_INTERNAL ]); -sysbus_create_varargs ("cadence_ttc" ,0xF8001000 , +sysbus_create_varargs_orphan ("cadence_ttc" ,0xF8001000 , pic[42 -GIC_INTERNAL ], pic[43 -GIC_INTERNAL ], pic[44 -GIC_INTERNAL ],NULL ); -sysbus_create_varargs ("cadence_ttc" ,0xF8002000 , +sysbus_create_varargs_orphan ("cadence_ttc" ,0xF8002000 , pic[69 -GIC_INTERNAL ], pic[70 -GIC_INTERNAL ], pic[71 -GIC_INTERNAL ],NULL );ddr_ctrl_init (0xF8006000 );
hw/core/sysbus.c +34 -1
@@ -209,7 +209,40 @@ static void sysbus_device_realize(DeviceState *dev, Error **errp) { } -DeviceState *sysbus_create_varargs (const char *name, +static void sysbus_create_tail (SysBusDevice *s,hwaddr addr,va_list va) +{ +qemu_irq irq; +int n; + +if (addr != (hwaddr)-1 ) { +sysbus_mmio_map (s,0 , addr); + } + n =0 ; +while (1 ) { + irq =va_arg (va, qemu_irq); +if (!irq) { +break ; + } +sysbus_connect_irq (s, n, irq); + n++; + } +} + +DeviceState *sysbus_create_varargs (Object *parent,const char *id, +const char *type,hwaddr addr, ...) +{ +DeviceState *dev; +va_list va; + + dev =qdev_new (parent, id, type); +sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal); +va_start (va, addr); +sysbus_create_tail (SYS_BUS_DEVICE (dev), addr, va); +va_end (va); +return dev; +} + +DeviceState *sysbus_create_varargs_orphan (const char *name,hwaddr addr, ...) {DeviceState *dev;
hw/i386/kvm/clock.c +1 -1
@@ -377,7 +377,7 @@ void kvmclock_create(bool create_always)if (create_always || cpu->env.features[FEAT_KVM ] & (CPUID_KVM_CLOCK |CPUID_KVM_CLOCK2 )) { -sysbus_create_simple (TYPE_KVM_CLOCK ,-1 ,NULL ); +sysbus_create_simple_orphan (TYPE_KVM_CLOCK ,-1 ,NULL ); } }
hw/i386/kvm/xen_evtchn.c +1 -1
@@ -306,7 +306,7 @@ static void gsi_assert_bh(void *opaque)void xen_evtchn_create (unsigned int nr_gsis,qemu_irq *system_gsis) { -XenEvtchnState *s =XEN_EVTCHN (sysbus_create_simple (TYPE_XEN_EVTCHN , +XenEvtchnState *s =XEN_EVTCHN (sysbus_create_simple_orphan (TYPE_XEN_EVTCHN ,-1 ,NULL ));int i;
hw/i386/kvm/xen_gnttab.c +1 -1
@@ -152,7 +152,7 @@ static const TypeInfo xen_gnttab_info = {void xen_gnttab_create (void ) { - xen_gnttab_singleton =XEN_GNTTAB (sysbus_create_simple (TYPE_XEN_GNTTAB , + xen_gnttab_singleton =XEN_GNTTAB (sysbus_create_simple_orphan (TYPE_XEN_GNTTAB ,-1 ,NULL )); }
hw/i386/kvm/xen_overlay.c +1 -1
@@ -169,7 +169,7 @@ static const TypeInfo xen_overlay_info = {void xen_overlay_create (void ) { - xen_overlay_singleton =XEN_OVERLAY (sysbus_create_simple (TYPE_XEN_OVERLAY , + xen_overlay_singleton =XEN_OVERLAY (sysbus_create_simple_orphan (TYPE_XEN_OVERLAY ,-1 ,NULL ));/* If xen_domid wasn't explicitly set, at least make sure it isn't zero. */
hw/i386/kvm/xen_primary_console.c +1 -1
@@ -84,7 +84,7 @@ static const TypeInfo xen_primary_console_info = {void xen_primary_console_create (void ) { -DeviceState *dev =sysbus_create_simple (TYPE_XEN_PRIMARY_CONSOLE ,-1 ,NULL ); +DeviceState *dev =sysbus_create_simple_orphan (TYPE_XEN_PRIMARY_CONSOLE ,-1 ,NULL );trace_xen_primary_console_create ();
hw/i386/kvm/xen_xenstore.c +1 -1
@@ -276,7 +276,7 @@ static const TypeInfo xen_xenstore_info = {void xen_xenstore_create (void ) { -DeviceState *dev =sysbus_create_simple (TYPE_XEN_XENSTORE ,-1 ,NULL ); +DeviceState *dev =sysbus_create_simple_orphan (TYPE_XEN_XENSTORE ,-1 ,NULL ); xen_xenstore_singleton =XEN_XENSTORE (dev);
hw/i386/microvm.c +1 -1
@@ -197,7 +197,7 @@ static void microvm_devices_init(MicrovmMachineState *mms) }for (i =0 ; i < mms->virtio_num_transports; i++) { -sysbus_create_simple ("virtio-mmio" , +sysbus_create_simple_orphan ("virtio-mmio" ,VIRTIO_MMIO_BASE + i *512 , x86ms->gsi[mms->virtio_irq_base + i]); }
hw/intc/apic_common.c +1 -1
@@ -282,7 +282,7 @@ static void apic_common_realize(DeviceState *dev, Error **errp)/* Note: We need at least 1M to map the VAPIC option ROM */ if (!vapic && s->vapic_control &VAPIC_ENABLE_MASK && current_machine->ram_size >=1024 *1024 ) { - vapic =sysbus_create_simple ("kvmvapic" ,-1 ,NULL ); + vapic =sysbus_create_simple_orphan ("kvmvapic" ,-1 ,NULL ); } s->vapic = vapic;if (apic_report_tpr_access && info->enable_tpr_reporting) {
hw/loongarch/virt.c +1 -1
@@ -485,7 +485,7 @@ static void virt_devices_init(DeviceState *pch_pic,* Create some unimplemented devices to emulate this. */ create_unimplemented_device ("pci-dma-cfg" ,0x1001041c ,0x4 ); -sysbus_create_simple ("ls7a_rtc" ,VIRT_RTC_REG_BASE , +sysbus_create_simple_orphan ("ls7a_rtc" ,VIRT_RTC_REG_BASE ,qdev_get_gpio_in (pch_pic,VIRT_RTC_IRQ -VIRT_GSI_BASE ));
hw/m68k/next-cube.c +2 -2
@@ -1280,7 +1280,7 @@ static void next_cube_init(MachineState *machine)memory_region_add_subregion (sysmem,0x04000000 , machine->ram);/* Framebuffer */ -sysbus_create_simple (TYPE_NEXTFB ,0x0B000000 ,NULL ); +sysbus_create_simple_orphan (TYPE_NEXTFB ,0x0B000000 ,NULL );/* MMIO */ sysbus_mmio_map (SYS_BUS_DEVICE (pcdev),0 ,0x02005000 );
@@ -1319,7 +1319,7 @@ static void next_cube_init(MachineState *machine)memory_region_add_subregion (sysmem,0x820c0000 , &m->bmapm2);/* KBD */ -sysbus_create_simple (TYPE_NEXTKBD ,0x0200e000 ,NULL ); +sysbus_create_simple_orphan (TYPE_NEXTKBD ,0x0200e000 ,NULL );/* Load ROM here */ memory_region_init_rom (&m->rom,NULL ,"next.rom" ,0x20000 , &error_fatal);
hw/m68k/virt.c +1 -1
@@ -202,7 +202,7 @@ static void virt_init(MachineState *machine)sysbus_connect_irq (sysbus,0 ,PIC_GPIO (VIRT_GF_TTY_IRQ_BASE ));/* virt controller */ - dev =sysbus_create_simple (TYPE_VIRT_CTRL ,VIRT_CTRL_MMIO_BASE , + dev =sysbus_create_simple_orphan (TYPE_VIRT_CTRL ,VIRT_CTRL_MMIO_BASE ,PIC_GPIO (VIRT_CTRL_IRQ_BASE ));/* virtio-mmio */
hw/mips/jazz.c +1 -1
@@ -395,7 +395,7 @@ static void mips_jazz_init(MachineState *machine,sysbus_mmio_map (sysbus,0 ,0x80009000 );/* LED indicator */ -sysbus_create_simple ("jazz-led" ,0x8000f000 ,NULL ); +sysbus_create_simple_orphan ("jazz-led" ,0x8000f000 ,NULL );g_free (dmas); }
hw/mips/loongson3_virt.c +1 -1
@@ -536,7 +536,7 @@ static void mips_loongson3_virt_init(MachineState *machine)qdev_get_gpio_in (liointc,UART_IRQ ),115200 ,serial_hd (0 ), DEVICE_LITTLE_ENDIAN); -sysbus_create_simple ("goldfish_rtc" , virt_memmap[VIRT_RTC ].base, +sysbus_create_simple_orphan ("goldfish_rtc" , virt_memmap[VIRT_RTC ].base,qdev_get_gpio_in (liointc,RTC_IRQ )); cpuclk =clock_new (OBJECT (machine),"cpu-refclk" );
hw/or1k/virt.c +1 -1
@@ -300,7 +300,7 @@ static void openrisc_virt_rtc_init(OR1KVirtState *state, hwaddr base,qemu_irq rtc_irq =get_per_cpu_irq (cpus, num_cpus, irq_pin);/* Goldfish RTC */ -sysbus_create_simple (TYPE_GOLDFISH_RTC , base, rtc_irq); +sysbus_create_simple_orphan (TYPE_GOLDFISH_RTC , base, rtc_irq);/* Goldfish RTC FDT */ nodename =g_strdup_printf ("/soc/rtc@%" HWADDR_PRIx, base);
hw/ppc/amigaone.c +1 -1
@@ -329,7 +329,7 @@ static void amigaone_init(MachineState *machine) }/* Articia S */ - dev =sysbus_create_simple (TYPE_ARTICIA ,ARTICIA_ADDR ,NULL ); + dev =sysbus_create_simple_orphan (TYPE_ARTICIA ,ARTICIA_ADDR ,NULL ); i2c_bus =I2C_BUS (qdev_get_child_bus (dev,"smbus" ));if (machine->ram_size >512 * MiB) {
hw/ppc/e500.c +1 -1
@@ -1076,7 +1076,7 @@ void ppce500_init(MachineState *machine) }/* Register spinning region */ -sysbus_create_simple ("e500-spin" , pmc->spin_base,NULL ); +sysbus_create_simple_orphan ("e500-spin" , pmc->spin_base,NULL );if (pmc->has_mpc8xxx_gpio) {qemu_irq poweroff_irq;
hw/ppc/pegasos.c +2 -2
@@ -218,7 +218,7 @@ static void pegasos_init(MachineState *machine)MemoryRegion *pci_mem, *mr;/* Articia S */ - pm->nb =DEVICE (sysbus_create_simple (TYPE_ARTICIA ,0xfe000000 ,NULL )); + pm->nb =DEVICE (sysbus_create_simple_orphan (TYPE_ARTICIA ,0xfe000000 ,NULL )); pci_mem =sysbus_mmio_get_region (SYS_BUS_DEVICE (pm->nb),1 ); mr =g_new (MemoryRegion,1 ); memory_region_init_alias(mr, OBJECT(pm->nb), "pci-mem-low", pci_mem,
@@ -233,7 +233,7 @@ static void pegasos_init(MachineState *machine) }case PEGASOS2 :/* Marvell Discovery II system controller */ - pm->nb =DEVICE (sysbus_create_simple (TYPE_MV64361 ,-1 , + pm->nb =DEVICE (sysbus_create_simple_orphan (TYPE_MV64361 ,-1 ,qdev_get_gpio_in (DEVICE (pm->cpu), PPC6xx_INPUT_INT))); pci_bus =mv64361_get_pci_bus (pm->nb,1 );break ;
hw/ppc/ppc440_bamboo.c +1 -1
@@ -183,7 +183,7 @@ static void bamboo_init(MachineState *machine)ppc4xx_sdram_ddr_enable (PPC4xx_SDRAM_DDR (dev));/* PCI */ - dev = sysbus_create_varargs(TYPE_PPC4xx_PCI_HOST, PPC440EP_PCI_CONFIG, + dev = sysbus_create_varargs_orphan(TYPE_PPC4xx_PCI_HOST, PPC440EP_PCI_CONFIG, qdev_get_gpio_in(uicdev, pci_irq_nrs[0]), qdev_get_gpio_in(uicdev, pci_irq_nrs[1]), qdev_get_gpio_in(uicdev, pci_irq_nrs[2]),
hw/ppc/sam460ex.c +4 -4
@@ -336,7 +336,7 @@ static void sam460ex_init(MachineState *machine)ppc4xx_sdram_ddr2_enable (PPC4xx_SDRAM_DDR2 (dev));/* IIC controllers and devices */ - dev =sysbus_create_simple (TYPE_PPC4xx_I2C,0x4ef600700 , + dev =sysbus_create_simple_orphan (TYPE_PPC4xx_I2C,0x4ef600700 ,qdev_get_gpio_in (uic[0 ],2 )); i2c =PPC4xx_I2C (dev)->bus;/* SPD EEPROM on RAM module */
@@ -347,7 +347,7 @@ static void sam460ex_init(MachineState *machine)/* RTC */ i2c_slave_create_simple (i2c,"m41t80" ,0x68 ); - dev =sysbus_create_simple (TYPE_PPC4xx_I2C,0x4ef600800 , + dev =sysbus_create_simple_orphan (TYPE_PPC4xx_I2C,0x4ef600800 ,qdev_get_gpio_in (uic[0 ],3 ));/* External bus controller */
@@ -387,7 +387,7 @@ static void sam460ex_init(MachineState *machine) l2cache_ram);/* USB */ -sysbus_create_simple (TYPE_PPC4xx_EHCI,0x4bffd0400 , +sysbus_create_simple_orphan (TYPE_PPC4xx_EHCI,0x4bffd0400 ,qdev_get_gpio_in (uic[2 ],29 )); dev =qdev_new_orphan ("sysbus-ohci" );qdev_prop_set_string (dev,"masterbus" ,"usb-bus.0" );
@@ -416,7 +416,7 @@ static void sam460ex_init(MachineState *machine)/* PCI bus */ /* All PCI irqs are connected to the same UIC pin (cf. UBoot source) */ - dev =sysbus_create_simple (TYPE_PPC440_PCIX_HOST ,0xc0ec00000 , + dev =sysbus_create_simple_orphan (TYPE_PPC440_PCIX_HOST ,0xc0ec00000 ,qdev_get_gpio_in (uic[1 ],0 ));sysbus_mmio_map (SYS_BUS_DEVICE (dev),1 ,0xc08000000 ); pci_bus =PCI_BUS (qdev_get_child_bus (dev,"pci.0" ));
hw/riscv/virt.c +2 -2
@@ -1473,7 +1473,7 @@ static void virt_machine_init(MachineState *machine)/* VirtIO MMIO devices */ for (i =0 ; i <VIRTIO_COUNT ; i++) { -sysbus_create_simple ("virtio-mmio" , +sysbus_create_simple_orphan ("virtio-mmio" , s->memmap[VIRT_VIRTIO ].base + i * s->memmap[VIRT_VIRTIO ].size,qdev_get_gpio_in (virtio_irqchip,VIRTIO_IRQ + i)); }
@@ -1486,7 +1486,7 @@ static void virt_machine_init(MachineState *machine)0 ,qdev_get_gpio_in (mmio_irqchip,UART0_IRQ ),399193 , serial_hd(0), DEVICE_LITTLE_ENDIAN); -sysbus_create_simple ("goldfish_rtc" , s->memmap[VIRT_RTC ].base, +sysbus_create_simple_orphan ("goldfish_rtc" , s->memmap[VIRT_RTC ].base,qdev_get_gpio_in (mmio_irqchip,RTC_IRQ ));for (i =0 ; i <ARRAY_SIZE (s->flash); i++) {
hw/sparc/sun4m.c +1 -1
@@ -1018,7 +1018,7 @@ static void sun4m_hw_init(MachineState *machine) slavio_irq[30], fdc_tc);if (hwdef->cs_base) { -sysbus_create_simple ("sun-CS4231" , hwdef->cs_base, +sysbus_create_simple_orphan ("sun-CS4231" , hwdef->cs_base, slavio_irq[5 ]); }
hw/vmapple/vmapple.c +2 -2
@@ -305,7 +305,7 @@ static void create_rtc(const VMAppleMachineState *vms)hwaddr base = vms->memmap[VMAPPLE_RTC ].base;int irq = vms->irqmap[VMAPPLE_RTC ]; -sysbus_create_simple ("pl031" , base,qdev_get_gpio_in (vms->gic, irq)); +sysbus_create_simple_orphan ("pl031" , base,qdev_get_gpio_in (vms->gic, irq)); }static DeviceState *gpio_key_dev;
@@ -331,7 +331,7 @@ static void create_gpio_devices(const VMAppleMachineState *vms, int gpio,sysbus_realize_and_unref (s, &error_fatal);memory_region_add_subregion (mem, base,sysbus_mmio_get_region (s,0 ));sysbus_connect_irq (s,0 ,qdev_get_gpio_in (vms->gic, irq)); - gpio_key_dev =sysbus_create_simple ("gpio-key" ,-1 , + gpio_key_dev =sysbus_create_simple_orphan ("gpio-key" ,-1 ,qdev_get_gpio_in (pl061_dev,3 )); }
hw/xen/xen-pvh-common.c +1 -1
@@ -173,7 +173,7 @@ static void xen_create_virtio_mmio_devices(XenPVHMachineState *s)qemu_irq irq =qemu_allocate_irq (xen_set_irq,NULL , s->cfg.virtio_mmio_irq_base + i); -sysbus_create_simple ("virtio-mmio" , base, irq); +sysbus_create_simple_orphan ("virtio-mmio" , base, irq); trace_xen_create_virtio_mmio_devices(i, s->cfg.virtio_mmio_irq_base + i,
include/hw/core/sysbus.h +32 -4
@@ -91,15 +91,43 @@ bool sysbus_realize_and_unref(SysBusDevice *dev, Error **errp);/* Call func for every dynamically created sysbus device in the system */ void foreach_dynamic_sysbus_device (FindSysbusDeviceFunc *func,void *opaque); -/* Legacy helper function for creating devices. */ -DeviceState *sysbus_create_varargs (const char *name, +/** +* sysbus_create_varargs: Create, parent and realize a sysbus device +* @parent: the QOM parent (usually the machine or containing device) +* @id: child<> property name +* @type: sysbus device type to create +* @addr: MMIO region 0 address, or -1 for none +* @...: NULL-terminated list of qemu_irq to connect +* +* Create a sysbus device via qdev_new(@parent, @id, @type), realize +* it, optionally map MMIO region 0 at @addr, and connect the given +* IRQs. The returned device is owned by @parent. +* +* This is a convenience helper for simple sysbus devices; new code +* should generally prefer qdev_new() + sysbus_realize() and set +* properties explicitly before realize. +*/ +DeviceState *sysbus_create_varargs (Object *parent,const char *id, +const char *type,hwaddr addr, ...); + +static inline DeviceState *sysbus_create_simple (Object *parent, +const char *id, +const char *type, +hwaddr addr, +qemu_irq irq) +{ +return sysbus_create_varargs (parent, id, type, addr, irq,NULL ); +} + +/* Legacy helper function for creating unparented devices. */ +DeviceState *sysbus_create_varargs_orphan (const char *name,hwaddr addr, ...); -static inline DeviceState *sysbus_create_simple (const char *name, +static inline DeviceState *sysbus_create_simple_orphan (const char *name,hwaddr addr,qemu_irq irq) { -return sysbus_create_varargs (name, addr, irq,NULL ); +return sysbus_create_varargs_orphan (name, addr, irq,NULL ); }#endif /* HW_SYSBUS_H */
scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci new file +18 -0
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// +// Rename sysbus_create_simple()/sysbus_create_varargs() to *_orphan() +// so that the short names can be reintroduced with a mandatory +// (parent, id, ...) signature. +// +// spatch --sp-file scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci \ +// --in-place --include-headers --dir . + +@@ +@@ +- sysbus_create_simple ++ sysbus_create_simple_orphan + +@@ +@@ +- sysbus_create_varargs ++ sysbus_create_varargs_orphan
Signature · 1 line
2.47.1
RFC PATCH v2 5/137 pci: Make pci_new*()/pci_create_simple*() take a QOM parent
In reply to Alexander GrafSame rename-and-reintroduce treatment as qdev_new() and sysbus_create_*(): mechanically rename the four PCI creation helpers to *_orphan() and reintroduce the short names with a leading (parent, id, ...) pair.
The parented pci_create_simple*() variants call qdev_realize() (not pci_realize_and_unref()) since the child<> property already holds the sole reference.
The mechanical rename part is generated by
spatch --sp-file scripts/coccinelle/qom-parent/pci-new-orphan.cocci \
--in-place --include-headers --dir .
or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \
grep -v '^subprojects/' | \
xargs sed -i \
's/\bpci_create_simple_multifunction\b/&_orphan/g;
s/\bpci_create_simple\b/&_orphan/g;
s/\bpci_new_multifunction\b/&_orphan/g;
s/\bpci_new\b/&_orphan/g'AI-used-for: code (refactoring)
--- hw/alpha/dp264.c | 4 +- hw/arm/realview.c | 4 +- hw/arm/sbsa-ref.c | 2 +- hw/arm/versatilepb.c | 4 +- hw/hppa/machine.c | 8 +-- hw/i386/pc.c | 2 +- hw/i386/pc_piix.c | 4 +- hw/i386/pc_q35.c | 10 +-- hw/mips/boston.c | 2 +- hw/mips/fuloong2e.c | 4 +- hw/mips/loongson3_virt.c | 2 +- hw/mips/malta.c | 2 +- hw/pci-host/articia.c | 4 +- hw/pci-host/bonito.c | 2 +- hw/pci-host/grackle.c | 2 +- hw/pci-host/gt64120.c | 2 +- hw/pci-host/i440fx.c | 2 +- hw/pci-host/mv64361.c | 2 +- hw/pci-host/pnv_phb.c | 2 +- hw/pci-host/ppc4xx_pci.c | 2 +- hw/pci-host/ppce500.c | 2 +- hw/pci-host/raven.c | 2 +- hw/pci-host/sabre.c | 6 +- hw/pci-host/sh_pci.c | 2 +- hw/pci-host/uninorth.c | 8 +-- hw/pci/pci.c | 65 +++++++++++++++---- hw/pci/pcie_sriov.c | 2 +- hw/ppc/amigaone.c | 2 +- hw/ppc/mac_newworld.c | 4 +- hw/ppc/mac_oldworld.c | 4 +- hw/ppc/pegasos.c | 2 +- hw/ppc/prep.c | 4 +- hw/ppc/sam460ex.c | 4 +- hw/ppc/spapr.c | 2 +- hw/riscv/boston-aia.c | 2 +- hw/sparc64/sun4u.c | 8 +-- hw/vfio/igd.c | 2 +- hw/xen/xen_pt_graphics.c | 2 +- include/hw/pci/pci.h | 18 +++-- .../qom-parent/pci-new-orphan.cocci | 28 ++++++++ 40 files changed, 157 insertions(+), 78 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/pci-new-orphan.cocci
hw/alpha/dp264.c +2 -2
@@ -110,7 +110,7 @@ static void clipper_init(MachineState *machine)* Importantly, we need to provide a PCI device node for it, otherwise * some operating systems won't notice there's an ISA bus to configure. */ - i82378_dev =DEVICE (pci_create_simple (pci_bus,PCI_DEVFN (7 ,0 ),"i82378" )); + i82378_dev =DEVICE (pci_create_simple_orphan (pci_bus,PCI_DEVFN (7 ,0 ),"i82378" )); isa_bus =ISA_BUS (qdev_get_child_bus (i82378_dev,"isa.0" ));/* Connect the ISA PIC to the Typhoon IRQ used for ISA interrupts. */
@@ -129,7 +129,7 @@ static void clipper_init(MachineState *machine)isa_create_simple (isa_bus,TYPE_SMC37C669_SUPERIO );/* IDE disk setup. */ - pci_dev =pci_create_simple (pci_bus,-1 ,"cmd646-ide" ); + pci_dev =pci_create_simple_orphan (pci_bus,-1 ,"cmd646-ide" );pci_ide_create_devs (pci_dev);/* Load PALcode. Given that this is not "real" cpu palcode,
hw/arm/realview.c +2 -2
@@ -297,11 +297,11 @@ static void realview_init(MachineState *machine,sysbus_connect_irq (busdev,3 , pic[51 ]); pci_bus = (PCIBus *)qdev_get_child_bus (dev,"pci" );if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); } n =drive_get_max_bus (IF_SCSI );while (n >=0 ) { - dev =DEVICE (pci_create_simple (pci_bus,-1 ,"lsi53c895a" )); + dev =DEVICE (pci_create_simple_orphan (pci_bus,-1 ,"lsi53c895a" ));lsi53c8xx_handle_legacy_cmdline (dev); n--; }
hw/arm/sbsa-ref.c +1 -1
@@ -695,7 +695,7 @@ static void create_pcie(SBSAMachineState *sms,pci_init_nic_devices (pci->bus, mc->default_nic); -pci_create_simple (pci->bus,-1 ,"bochs-display" ); +pci_create_simple_orphan (pci->bus,-1 ,"bochs-display" );create_smmu (sms, pci->bus, sysmem, secure_sysmem); }
hw/arm/versatilepb.c +2 -2
@@ -270,11 +270,11 @@ static void versatile_init(MachineState *machine, int board_id)pci_init_nic_devices (pci_bus,"rtl8139" );if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); } n =drive_get_max_bus (IF_SCSI );while (n >=0 ) { - dev =DEVICE (pci_create_simple (pci_bus,-1 ,"lsi53c895a" )); + dev =DEVICE (pci_create_simple_orphan (pci_bus,-1 ,"lsi53c895a" ));lsi53c8xx_handle_legacy_cmdline (dev); n--; }
hw/hppa/machine.c +4 -4
@@ -428,7 +428,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,if (pci_bus &&hppa_is_pa20 (&cpu[0 ]->env)) {/* BMC board: HP Diva GSP PCI card */ - pci_dev =pci_new_multifunction (PCI_DEVFN (2 ,0 ),"diva-gsp" ); + pci_dev =pci_new_multifunction_orphan (PCI_DEVFN (2 ,0 ),"diva-gsp" );if (!lasi_dev) {/* bind default keyboard/serial to Diva card */ qdev_prop_set_chr (DEVICE (pci_dev),"chardev1" ,serial_hd (0 ));
@@ -443,7 +443,7 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,if (!lasi_dev && machine->enable_graphics &&defaults_enabled ()) {USBBus *usb_bus; -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort));usb_create_simple (usb_bus,"usb-kbd" );
@@ -721,7 +721,7 @@ static void machine_HP_B160L_init(MachineState *machine)/* SCSI disk setup. */ if (drive_get_max_bus (IF_SCSI ) >=0 ) { - dev =DEVICE (pci_create_simple (pci_bus,-1 ,"lsi53c895a" )); + dev =DEVICE (pci_create_simple_orphan (pci_bus,-1 ,"lsi53c895a" ));lsi53c8xx_handle_legacy_cmdline (dev); }
@@ -773,7 +773,7 @@ static void machine_HP_C3700_init(MachineState *machine)/* SCSI disk setup. */ if (drive_get_max_bus (IF_SCSI ) >=0 ) { -DeviceState *dev =DEVICE (pci_create_simple (pci_bus,-1 ,"lsi53c895a" )); +DeviceState *dev =DEVICE (pci_create_simple_orphan (pci_bus,-1 ,"lsi53c895a" ));lsi53c8xx_handle_legacy_cmdline (dev); }
hw/i386/pc.c +1 -1
@@ -1104,7 +1104,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,xen_gnttab_create ();xen_xenstore_create ();if (pcms->pcibus) { -pci_create_simple (pcms->pcibus,-1 ,"xen-platform" ); +pci_create_simple_orphan (pcms->pcibus,-1 ,"xen-platform" ); }xen_bus_init (); }
hw/i386/pc_piix.c +2 -2
@@ -236,7 +236,7 @@ static void pc_init1(MachineState *machine, const char *pci_type) gsi_state =pc_gsi_create (&x86ms->gsi, true); - pci_dev =pci_new_multifunction (-1 , pcms->south_bridge); + pci_dev =pci_new_multifunction_orphan (-1 , pcms->south_bridge);object_property_set_bool (OBJECT (pci_dev),"has-usb" ,machine_usb (machine), &error_abort); object_property_set_bool(OBJECT(pci_dev), "has-acpi",
@@ -384,7 +384,7 @@ static void pc_xen_hvm_init(MachineState *machine) : TYPE_I440FX_PCI_DEVICE);xen_igd_reserve_slot (pcms->pcibus); - pci_create_simple(pcms->pcibus, -1, "xen-platform"); + pci_create_simple_orphan(pcms->pcibus, -1, "xen-platform"); }#endif
hw/i386/pc_q35.c +5 -5
@@ -114,12 +114,12 @@ static int ehci_create_ich9_with_companions(PCIBus *bus, int slot)return -1 ; } - ehci =pci_new_multifunction (PCI_DEVFN (slot,7 ), name); + ehci =pci_new_multifunction_orphan (PCI_DEVFN (slot,7 ), name);pci_realize_and_unref (ehci, bus, &error_fatal); usbbus =QLIST_FIRST (&ehci->qdev.child_bus);for (i =0 ; i <3 ; i++) { - uhci =pci_new_multifunction (PCI_DEVFN (slot, comp[i].func), + uhci =pci_new_multifunction_orphan (PCI_DEVFN (slot, comp[i].func), comp[i].name);qdev_prop_set_string (&uhci->qdev,"masterbus" , usbbus->name);qdev_prop_set_uint32 (&uhci->qdev,"firstport" , comp[i].port);
@@ -235,7 +235,7 @@ static void pc_q35_init(MachineState *machine) gsi_state =pc_gsi_create (&x86ms->gsi, true);/* create ISA bus */ - lpc =pci_new_multifunction (PCI_DEVFN (ICH9_LPC_DEV ,ICH9_LPC_FUNC ), + lpc =pci_new_multifunction_orphan (PCI_DEVFN (ICH9_LPC_DEV ,ICH9_LPC_FUNC ),TYPE_ICH9_LPC_DEVICE ); lpc_dev =DEVICE (lpc); qdev_prop_set_bit(lpc_dev, "smm-enabled",
@@ -290,7 +290,7 @@ static void pc_q35_init(MachineState *machine)AHCIPCIState *ich9;/* ahci and SATA device, for q35 1 ahci controller is built-in */ - pdev =pci_create_simple_multifunction (pcms->pcibus, + pdev =pci_create_simple_multifunction_orphan (pcms->pcibus,PCI_DEVFN (ICH9_SATA1_DEV ,ICH9_SATA1_FUNC ),"ich9-ahci" );
@@ -311,7 +311,7 @@ static void pc_q35_init(MachineState *machine)PCIDevice *smb;/* TODO: Populate SPD eeprom data. */ - smb =pci_create_simple_multifunction (pcms->pcibus, + smb =pci_create_simple_multifunction_orphan (pcms->pcibus,PCI_DEVFN (ICH9_SMB_DEV ,ICH9_SMB_FUNC ),TYPE_ICH9_SMB_DEVICE );
hw/mips/boston.c +1 -1
@@ -769,7 +769,7 @@ static void boston_mach_init(MachineState *machine)qemu_chr_fe_set_handlers (&s->lcd_display,NULL ,NULL , boston_lcd_event,NULL , s,NULL , true); - pdev =pci_create_simple_multifunction (&PCI_BRIDGE (&pcie2->root)->sec_bus, + pdev =pci_create_simple_multifunction_orphan (&PCI_BRIDGE (&pcie2->root)->sec_bus,PCI_DEVFN (0 ,0 ),TYPE_ICH9_AHCI ); ich9 =ICH9_AHCI (pdev);g_assert (ARRAY_SIZE (hd) == ich9->ahci.ports);
hw/mips/fuloong2e.c +2 -2
@@ -286,7 +286,7 @@ static void mips_fuloong2e_init(MachineState *machine) pci_bus =bonito_init ((qemu_irq *)&(env->irq[2 ]));/* South bridge -> IP5 */ - pci_dev =pci_new_multifunction (PCI_DEVFN (FULOONG2E_VIA_SLOT ,0 ), + pci_dev =pci_new_multifunction_orphan (PCI_DEVFN (FULOONG2E_VIA_SLOT ,0 ),TYPE_VT82C686B_ISA );/* Set properties on individual devices before realizing the south bridge */
@@ -312,7 +312,7 @@ static void mips_fuloong2e_init(MachineState *machine)/* GPU */ if (vga_interface_type !=VGA_NONE ) { vga_interface_created = true; - pci_dev =pci_new (-1 ,"ati-vga" ); + pci_dev =pci_new_orphan (-1 ,"ati-vga" ); dev =DEVICE (pci_dev);qdev_prop_set_uint32 (dev,"vgamem_mb" ,16 );qdev_prop_set_uint16 (dev,"x-device-id" ,0x5159 );
hw/mips/loongson3_virt.c +1 -1
@@ -465,7 +465,7 @@ static inline void loongson3_virt_devices_init(MachineState *machine,if (defaults_enabled () &&object_class_by_name ("pci-ohci" )) {USBBus *usb_bus; -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort));usb_create_simple (usb_bus,"usb-kbd" );
hw/mips/malta.c +1 -1
@@ -1233,7 +1233,7 @@ void mips_malta_init(MachineState *machine)pci_bus_map_irqs (pci_bus, malta_pci_slot_get_pirq);/* Southbridge */ - piix4 =pci_new_multifunction (PIIX4_PCI_DEVFN ,TYPE_PIIX4_PCI_DEVICE ); + piix4 =pci_new_multifunction_orphan (PIIX4_PCI_DEVFN ,TYPE_PIIX4_PCI_DEVICE );qdev_prop_set_uint32 (DEVICE (piix4),"smb_io_base" ,0x1100 );pci_realize_and_unref (piix4, pci_bus, &error_fatal); isa_bus =ISA_BUS (qdev_get_child_bus (DEVICE (piix4),"isa.0" ));
hw/pci-host/articia.c +2 -2
@@ -185,10 +185,10 @@ static void articia_realize(DeviceState *dev, Error **errp) h->bus =pci_register_root_bus (dev,NULL , articia_pcihost_set_irq, amigaone_pcihost_bus0_map_irq, dev, &s->mem, &s->io,PCI_DEVFN (8 ,0 ),4 ,TYPE_PCI_BUS ); - pdev =pci_create_simple_multifunction (h->bus,PCI_DEVFN (0 ,0 ), + pdev =pci_create_simple_multifunction_orphan (h->bus,PCI_DEVFN (0 ,0 ),TYPE_ARTICIA_PCI_HOST );ARTICIA_PCI_HOST (pdev)->as = s; -pci_create_simple (h->bus,PCI_DEVFN (0 ,1 ),TYPE_ARTICIA_PCI_BRIDGE ); +pci_create_simple_orphan (h->bus,PCI_DEVFN (0 ,1 ),TYPE_ARTICIA_PCI_BRIDGE );sysbus_init_mmio (SYS_BUS_DEVICE (dev), &s->reg);sysbus_init_mmio (SYS_BUS_DEVICE (dev), &s->mem);
hw/pci-host/bonito.c +1 -1
@@ -747,7 +747,7 @@ PCIBus *bonito_init(qemu_irq *pic) pcihost->pic = pic;sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); - d =pci_new (PCI_DEVFN (0 ,0 ),TYPE_PCI_BONITO ); + d =pci_new_orphan (PCI_DEVFN (0 ,0 ),TYPE_PCI_BONITO ); s =PCI_BONITO (d); s->pcihost = pcihost; pcihost->pci_dev = s;
hw/pci-host/grackle.c +1 -1
@@ -60,7 +60,7 @@ static void grackle_realize(DeviceState *dev, Error **errp) &s->pci_io, 0, 4, TYPE_PCI_BUS); -pci_create_simple (phb->bus,0 ,"grackle" ); +pci_create_simple_orphan (phb->bus,0 ,"grackle" ); }static void grackle_init (Object *obj)
hw/pci-host/gt64120.c +1 -1
@@ -1204,7 +1204,7 @@ static void gt64120_realize(DeviceState *dev, Error **errp)get_system_io (), PCI_DEVFN(18, 0), TYPE_PCI_BUS); -pci_create_simple (phb->bus,PCI_DEVFN (0 ,0 ),"gt64120_pci" ); +pci_create_simple_orphan (phb->bus,PCI_DEVFN (0 ,0 ),"gt64120_pci" );memory_region_init_io (&phb->conf_mem,OBJECT (phb), &pci_host_conf_le_ops, s,"pci-conf-idx" ,4 );
hw/pci-host/i440fx.c +1 -1
@@ -282,7 +282,7 @@ static void i440fx_pcihost_realize(DeviceState *dev, Error **errp) s->io_memory, 0, TYPE_PCI_BUS); phb->bus = b; - d =pci_create_simple (b,0 , s->pci_type); + d =pci_create_simple_orphan (b,0 , s->pci_type); f =I440FX_PCI_DEVICE (d); range_set_bounds(&s->pci_hole, s->below_4g_mem_size,
hw/pci-host/mv64361.c +1 -1
@@ -94,7 +94,7 @@ static void mv64361_pcihost_realize(DeviceState *dev, Error **errp) pci_swizzle_map_irq_fn, dev, &s->mem, &s->io, 0, 4, TYPE_PCI_BUS);g_free (name); -pci_create_simple (h->bus,0 ,TYPE_MV64361_PCI_BRIDGE ); +pci_create_simple_orphan (h->bus,0 ,TYPE_MV64361_PCI_BRIDGE );qdev_init_gpio_out (dev, s->irq,ARRAY_SIZE (s->irq)); }
hw/pci-host/pnv_phb.c +1 -1
@@ -167,7 +167,7 @@ static void pnv_phb_realize(DeviceState *dev, Error **errp) }if (defaults_enabled ()) { -PCIDevice *root =pci_new (PCI_DEVFN (0 ,0 ),TYPE_PNV_PHB_ROOT_PORT ); +PCIDevice *root =pci_new_orphan (PCI_DEVFN (0 ,0 ),TYPE_PNV_PHB_ROOT_PORT );pci_realize_and_unref (root, pci->bus, errp); }
hw/pci-host/ppc4xx_pci.c +1 -1
@@ -332,7 +332,7 @@ static void ppc4xx_pcihost_realize(DeviceState *dev, Error **errp) TYPE_PCI_BUS); h->bus = b; -pci_create_simple (b,0 , TYPE_PPC4xx_HOST_BRIDGE); +pci_create_simple_orphan (b,0 , TYPE_PPC4xx_HOST_BRIDGE);/* XXX split into 2 memory regions, one for config space, one for regs */ memory_region_init (&s->container,OBJECT (s),"pci-container" ,PCI_ALL_SIZE );
hw/pci-host/ppce500.c +1 -1
@@ -473,7 +473,7 @@ static void e500_pcihost_realize(DeviceState *dev, Error **errp)address_space_init (&s->bm_as, &s->bm,"pci-bm" );pci_setup_iommu (b, &ppce500_iommu_ops, s); -pci_create_simple (b,0 ,TYPE_PPC_E500_PCI_BRIDGE ); +pci_create_simple_orphan (b,0 ,TYPE_PPC_E500_PCI_BRIDGE );memory_region_init (&s->container,OBJECT (h),"pci-container" ,PCIE500_ALL_SIZE ); memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_be_ops, h,
hw/pci-host/raven.c +1 -1
@@ -281,7 +281,7 @@ static void raven_pcihost_realizefn(DeviceState *d, Error **errp) "pci-intack", 1);memory_region_add_subregion (address_space_mem,0xbffffff0 , &s->pci_intack); -pci_create_simple (h->bus,PCI_DEVFN (0 ,0 ),TYPE_RAVEN_PCI_DEVICE ); +pci_create_simple_orphan (h->bus,PCI_DEVFN (0 ,0 ),TYPE_RAVEN_PCI_DEVICE );address_space_init (&s->bm_as, &s->bm,"raven-bm" );pci_setup_iommu (h->bus, &raven_iommu_ops, s);
hw/pci-host/sabre.c +3 -3
@@ -383,7 +383,7 @@ static void sabre_realize(DeviceState *dev, Error **errp) &s->pci_ioport, 0, 0x40, TYPE_PCI_BUS); -pci_create_simple (phb->bus,0 ,TYPE_SABRE_PCI_DEVICE ); +pci_create_simple_orphan (phb->bus,0 ,TYPE_SABRE_PCI_DEVICE );/* IOMMU */ memory_region_add_subregion_overlap(&s->sabre_config, 0x200,
@@ -391,12 +391,12 @@ static void sabre_realize(DeviceState *dev, Error **errp)pci_setup_iommu (phb->bus, &sabre_iommu_ops, s->iommu);/* APB secondary busses */ - pci_dev =pci_new_multifunction (PCI_DEVFN (1 ,0 ),TYPE_SIMBA_PCI_BRIDGE ); + pci_dev =pci_new_multifunction_orphan (PCI_DEVFN (1 ,0 ),TYPE_SIMBA_PCI_BRIDGE ); s->bridgeB =PCI_BRIDGE (pci_dev);pci_bridge_map_irq (s->bridgeB,"pciB" , pci_simbaB_map_irq);pci_realize_and_unref (pci_dev, phb->bus, &error_fatal); - pci_dev =pci_new_multifunction (PCI_DEVFN (1 ,1 ),TYPE_SIMBA_PCI_BRIDGE ); + pci_dev =pci_new_multifunction_orphan (PCI_DEVFN (1 ,1 ),TYPE_SIMBA_PCI_BRIDGE ); s->bridgeA =PCI_BRIDGE (pci_dev);pci_bridge_map_irq (s->bridgeA,"pciA" , pci_simbaA_map_irq);pci_realize_and_unref (pci_dev, phb->bus, &error_fatal);
hw/pci-host/sh_pci.c +1 -1
@@ -142,7 +142,7 @@ static void sh_pcic_host_realize(DeviceState *dev, Error **errp)sysbus_init_mmio (sbd, &s->memconfig_a7);memory_region_add_subregion (get_system_memory (),0xfe240000 , &s->isa); - s->dev =pci_create_simple (phb->bus,PCI_DEVFN (0 ,0 ),"sh_pci_host" ); + s->dev =pci_create_simple_orphan (phb->bus,PCI_DEVFN (0 ,0 ),"sh_pci_host" ); }static void sh_pcic_pci_realize (PCIDevice *d,Error **errp)
hw/pci-host/uninorth.c +4 -4
@@ -126,7 +126,7 @@ static void pci_unin_main_realize(DeviceState *dev, Error **errp) &s->pci_io, PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); -pci_create_simple (h->bus,PCI_DEVFN (11 ,0 ),"uni-north-pci" ); +pci_create_simple_orphan (h->bus,PCI_DEVFN (11 ,0 ),"uni-north-pci" );/* * DEC 21154 bridge was unused for many years, this comment is
@@ -176,7 +176,7 @@ static void pci_u3_agp_realize(DeviceState *dev, Error **errp) &s->pci_io, PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); -pci_create_simple (h->bus,PCI_DEVFN (11 ,0 ),"u3-agp" ); +pci_create_simple_orphan (h->bus,PCI_DEVFN (11 ,0 ),"u3-agp" ); }static void pci_u3_agp_init (Object *obj)
@@ -220,7 +220,7 @@ static void pci_unin_agp_realize(DeviceState *dev, Error **errp) &s->pci_io, PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); -pci_create_simple (h->bus,PCI_DEVFN (11 ,0 ),"uni-north-agp" ); +pci_create_simple_orphan (h->bus,PCI_DEVFN (11 ,0 ),"uni-north-agp" ); }static void pci_unin_agp_init (Object *obj)
@@ -253,7 +253,7 @@ static void pci_unin_internal_realize(DeviceState *dev, Error **errp) &s->pci_io, PCI_DEVFN(14, 0), 4, TYPE_PCI_BUS); -pci_create_simple (h->bus,PCI_DEVFN (14 ,0 ),"uni-north-internal-pci" ); +pci_create_simple_orphan (h->bus,PCI_DEVFN (14 ,0 ),"uni-north-internal-pci" ); }static void pci_unin_internal_init (Object *obj)
hw/pci/pci.c +53 -12
104 lines not on this page · raw message
hw/pci/pcie_sriov.c +1 -1
@@ -171,7 +171,7 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, dev->exp.sriov_pf.vf = g_new(PCIDevice *, total_vfs);for (uint16_t i =0 ; i < total_vfs; i++) { -PCIDevice *vf =pci_new (devfn, vfname); +PCIDevice *vf =pci_new_orphan (devfn, vfname); vf->exp.sriov_vf.pf = dev; vf->exp.sriov_vf.vf_number = i;
hw/ppc/amigaone.c +1 -1
@@ -355,7 +355,7 @@ static void amigaone_init(MachineState *machine) pci_bus =PCI_BUS (qdev_get_child_bus (dev,"pci.0" ));/* VIA VT82c686B South Bridge (multifunction PCI device) */ - via =OBJECT (pci_create_simple_multifunction (pci_bus,PCI_DEVFN (7 ,0 ), + via =OBJECT (pci_create_simple_multifunction_orphan (pci_bus,PCI_DEVFN (7 ,0 ),TYPE_VT82C686B_ISA )); object_property_add_alias(OBJECT(machine), "rtc-time", object_resolve_path_component(via, "rtc"),
hw/ppc/mac_newworld.c +2 -2
@@ -348,7 +348,7 @@ static void ppc_core99_init(MachineState *machine) pci_bus =PCI_HOST_BRIDGE (uninorth_pci_dev)->bus;/* MacIO */ - macio =OBJECT (pci_new (-1 ,TYPE_NEWWORLD_MACIO )); + macio =OBJECT (pci_new_orphan (-1 ,TYPE_NEWWORLD_MACIO )); dev =DEVICE (macio);qdev_prop_set_uint64 (dev,"frequency" , tbfreq);qdev_prop_set_bit (dev,"has-pmu" , has_pmu);
@@ -416,7 +416,7 @@ static void ppc_core99_init(MachineState *machine) }if (machine->usb) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" );/* U3 needs to use USB for input because Linux doesn't support via-cuda on PPC64 */
hw/ppc/mac_oldworld.c +2 -2
@@ -229,7 +229,7 @@ static void ppc_heathrow_init(MachineState *machine) pci_bus =PCI_HOST_BRIDGE (grackle_dev)->bus;/* MacIO */ - macio =OBJECT (pci_new (PCI_DEVFN (16 ,0 ),TYPE_OLDWORLD_MACIO )); + macio =OBJECT (pci_new_orphan (PCI_DEVFN (16 ,0 ),TYPE_OLDWORLD_MACIO ));qdev_prop_set_uint64 (DEVICE (macio),"frequency" , tbfreq); dev =DEVICE (object_resolve_path_component (macio,"escc" ));
@@ -285,7 +285,7 @@ static void ppc_heathrow_init(MachineState *machine)qdev_realize_and_unref (dev, adb_bus, &error_fatal);if (machine_usb (machine)) { -pci_create_simple (pci_bus,-1 ,"pci-ohci" ); +pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); }if (!graphic_width) {
hw/ppc/pegasos.c +1 -1
@@ -241,7 +241,7 @@ static void pegasos_init(MachineState *machine)/* VIA VT8231 South Bridge (multifunction PCI device) */ devfn =PCI_DEVFN (pm->type ==PEGASOS1 ?7 :12 ,0 ); - pm->sb =DEVICE (pci_new_multifunction (devfn,TYPE_VT8231_ISA )); + pm->sb =DEVICE (pci_new_multifunction_orphan (devfn,TYPE_VT8231_ISA )); via =OBJECT (pm->sb);/* Set properties on individual devices before realizing the south bridge */
hw/ppc/prep.c +2 -2
@@ -300,7 +300,7 @@ static void ibm_40p_init(MachineState *machine) }/* PCI -> ISA bridge */ - i82378_dev =DEVICE (pci_new (PCI_DEVFN (11 ,0 ),"i82378" )); + i82378_dev =DEVICE (pci_new_orphan (PCI_DEVFN (11 ,0 ),"i82378" ));qdev_realize_and_unref (i82378_dev,BUS (pci_bus), &error_fatal);qdev_connect_gpio_out (i82378_dev,0 ,qdev_get_gpio_in (DEVICE (cpu), PPC6xx_INPUT_INT));
@@ -350,7 +350,7 @@ static void ibm_40p_init(MachineState *machine)qdev_prop_set_uint32 (dev,"config" ,12 );isa_realize_and_unref (isa_dev, isa_bus, &error_fatal); - dev =DEVICE (pci_create_simple (pci_bus,PCI_DEVFN (1 ,0 ),"lsi53c810" )); + dev =DEVICE (pci_create_simple_orphan (pci_bus,PCI_DEVFN (1 ,0 ),"lsi53c810" ));lsi53c8xx_handle_legacy_cmdline (dev);qdev_connect_gpio_out (dev,0 ,qdev_get_gpio_in (i82378_dev,13 ));
hw/ppc/sam460ex.c +2 -2
@@ -422,14 +422,14 @@ static void sam460ex_init(MachineState *machine) pci_bus =PCI_BUS (qdev_get_child_bus (dev,"pci.0" ));/* PCI devices */ -pci_create_simple (pci_bus,PCI_DEVFN (6 ,0 ),"sm501" ); +pci_create_simple_orphan (pci_bus,PCI_DEVFN (6 ,0 ),"sm501" );/* * SoC has a single SATA port but we don't emulate that * However, firmware and usual clients have driver for SiI311x * PCI SATA card so add one for convenience by default */ if (defaults_enabled ()) { -PCIIDEState *s =PCI_IDE (pci_create_simple (pci_bus,-1 ,"sii3112" )); +PCIIDEState *s =PCI_IDE (pci_create_simple_orphan (pci_bus,-1 ,"sii3112" ));DriveInfo *di; di =drive_get_by_index (IF_IDE ,0 );
hw/ppc/spapr.c +1 -1
@@ -3075,7 +3075,7 @@ static void spapr_machine_init(MachineState *machine) }if (machine->usb) { -pci_create_simple (phb->bus,-1 ,"nec-usb-xhci" ); +pci_create_simple_orphan (phb->bus,-1 ,"nec-usb-xhci" );if (has_vga) {USBBus *usb_bus;
hw/riscv/boston-aia.c +1 -1
@@ -418,7 +418,7 @@ static void boston_mach_init(MachineState *machine)qemu_chr_fe_set_handlers (&s->lcd_display,NULL ,NULL , boston_lcd_event,NULL , s,NULL , true); - pdev =pci_create_simple_multifunction (&PCI_BRIDGE (&pcie2->root)->sec_bus, + pdev =pci_create_simple_multifunction_orphan (&PCI_BRIDGE (&pcie2->root)->sec_bus,PCI_DEVFN (0 ,0 ),TYPE_ICH9_AHCI ); ich9 =ICH9_AHCI (pdev);g_assert (ARRAY_SIZE (hd) == ich9->ahci.ports);
hw/sparc64/sun4u.c +4 -4
@@ -599,7 +599,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,pci_bus_set_slot_reserved_mask (pci_busA,0xfffffff1 );pci_bus_set_slot_reserved_mask (pci_busB,0xfffffff0 ); - ebus =pci_new_multifunction (PCI_DEVFN (1 ,0 ),TYPE_EBUS ); + ebus =pci_new_multifunction_orphan (PCI_DEVFN (1 ,0 ),TYPE_EBUS );qdev_prop_set_uint64 (DEVICE (ebus),"console-serial-base" , hwdef->console_serial_base);pci_realize_and_unref (ebus, pci_busA, &error_fatal);
@@ -618,7 +618,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,switch (vga_interface_type) {case VGA_STD : -pci_create_simple (pci_busA,PCI_DEVFN (2 ,0 ),"VGA" ); +pci_create_simple_orphan (pci_busA,PCI_DEVFN (2 ,0 ),"VGA" ); vga_interface_created = true;break ;case VGA_NONE :
@@ -632,7 +632,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, nd =qemu_find_nic_info (mc->default_nic, true,NULL );if (nd) { - pci_dev =pci_new_multifunction (PCI_DEVFN (1 ,1 ), mc->default_nic); + pci_dev =pci_new_multifunction_orphan (PCI_DEVFN (1 ,1 ), mc->default_nic); dev = &pci_dev->qdev;qdev_set_nic_properties (dev, nd);pci_realize_and_unref (pci_dev, pci_busA, &error_fatal);
@@ -648,7 +648,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,qemu_macaddr_default_if_unset (&macaddr); } - pci_dev =pci_new (PCI_DEVFN (3 ,0 ),"cmd646-ide" ); + pci_dev =pci_new_orphan (PCI_DEVFN (3 ,0 ),"cmd646-ide" );qdev_prop_set_uint32 (&pci_dev->qdev,"secondary" ,1 );pci_realize_and_unref (pci_dev, pci_busA, &error_fatal);pci_ide_create_devs (pci_dev);
hw/vfio/igd.c +1 -1
@@ -334,7 +334,7 @@ static int vfio_pci_igd_lpc_init(VFIOPCIDevice *vdev, lpc_bridge =pci_find_device (pci_device_root_bus (pdev),0 ,PCI_DEVFN (0x1f ,0 ));if (!lpc_bridge) { - lpc_bridge =pci_create_simple (pci_device_root_bus (pdev), + lpc_bridge =pci_create_simple_orphan (pci_device_root_bus (pdev),PCI_DEVFN (0x1f ,0 ),"vfio-pci-igd-lpc-bridge" ); }
hw/xen/xen_pt_graphics.c +1 -1
@@ -399,7 +399,7 @@ void xen_igd_passthrough_isa_bridge_create(XenPCIPassthroughState *s, }/* Currently IGD drivers always need to access PCH by 1f.0. */ - bridge_dev =pci_create_simple (bus,PCI_DEVFN (0x1f ,0 ), + bridge_dev =pci_create_simple_orphan (bus,PCI_DEVFN (0x1f ,0 ),"igd-passthrough-isa-bridge" );/*
include/hw/pci/pci.h +14 -4
@@ -1088,13 +1088,23 @@ pci_set_quad_by_mask(uint8_t *config, uint64_t mask, uint64_t reg)pci_set_quad (config, (~mask & val) | (mask & rval)); } -PCIDevice *pci_new_multifunction (int devfn,const char *name); -PCIDevice *pci_new (int devfn,const char *name); +PCIDevice *pci_new_multifunction (Object *parent,const char *id, +int devfn,const char *type); +PCIDevice *pci_new (Object *parent,const char *id, +int devfn,const char *type); +PCIDevice *pci_create_simple_multifunction (Object *parent,const char *id, +PCIBus *bus,int devfn, +const char *type); +PCIDevice *pci_create_simple (Object *parent,const char *id, +PCIBus *bus,int devfn,const char *type); + +PCIDevice *pci_new_multifunction_orphan (int devfn,const char *name); +PCIDevice *pci_new_orphan (int devfn,const char *name);bool pci_realize_and_unref (PCIDevice *dev,PCIBus *bus,Error **errp); -PCIDevice *pci_create_simple_multifunction (PCIBus *bus,int devfn, +PCIDevice *pci_create_simple_multifunction_orphan (PCIBus *bus,int devfn,const char *name); -PCIDevice *pci_create_simple (PCIBus *bus,int devfn,const char *name); +PCIDevice *pci_create_simple_orphan (PCIBus *bus,int devfn,const char *name);void lsi53c8xx_handle_legacy_cmdline (DeviceState *lsi_dev);
scripts/coccinelle/qom-parent/pci-new-orphan.cocci new file +28 -0
@@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// +// Rename pci_new*/pci_create_simple*() to *_orphan() so that the +// short names can be reintroduced with a mandatory (parent, id, ...) +// signature. +// +// spatch --sp-file scripts/coccinelle/qom-parent/pci-new-orphan.cocci \ +// --in-place --include-headers --dir . + +@@ +@@ +- pci_new_multifunction ++ pci_new_multifunction_orphan + +@@ +@@ +- pci_new ++ pci_new_orphan + +@@ +@@ +- pci_create_simple_multifunction ++ pci_create_simple_multifunction_orphan + +@@ +@@ +- pci_create_simple ++ pci_create_simple_orphan
Signature · 1 line
2.47.1
RFC PATCH v2 6/137 isa: Make isa_new()/isa_try_new()/isa_create_simple() take a QOM parent
In reply to Alexander GrafSame rename-and-reintroduce treatment as the qdev, sysbus and PCI
layers: mechanically rename the three ISA creation helpers to *_orphan() and reintroduce the short names with a leading (parent, id, ...) pair.
The parented isa_create_simple() calls qdev_realize() (not isa_realize_and_unref()) since the child<> property already holds the sole reference.
The mechanical rename part is generated by
spatch --sp-file scripts/coccinelle/qom-parent/isa-new-orphan.cocci \
--in-place --include-headers --dir .
or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \
grep -v '^subprojects/' | \
xargs sed -i \
's/\bisa_create_simple\b/&_orphan/g;
s/\bisa_try_new\b/&_orphan/g;
s/\bisa_new\b/&_orphan/g'AI-used-for: code (refactoring)
--- hw/alpha/dp264.c | 2 +- hw/char/parallel-isa.c | 2 +- hw/char/serial-isa.c | 2 +- hw/dma/i8257.c | 4 +-- hw/i386/isapc.c | 2 +- hw/i386/pc.c | 12 ++++---- hw/ide/isa.c | 2 +- hw/intc/i8259_common.c | 2 +- hw/isa/i82378.c | 4 +-- hw/isa/isa-bus.c | 30 +++++++++++++++---- hw/isa/isa-superio.c | 10 +++---- hw/mips/jazz.c | 2 +- hw/mips/malta.c | 2 +- hw/ppc/pnv.c | 2 +- hw/ppc/prep.c | 12 ++++---- hw/rtc/mc146818rtc.c | 2 +- hw/sparc64/sun4u.c | 4 +-- include/hw/i386/vmport.h | 2 +- include/hw/isa/isa.h | 10 +++++-- include/hw/net/ne2000-isa.h | 2 +- include/hw/timer/i8254.h | 4 +-- .../qom-parent/isa-new-orphan.cocci | 23 ++++++++++++++ 22 files changed, 91 insertions(+), 46 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/isa-new-orphan.cocci
hw/alpha/dp264.c +1 -1
@@ -126,7 +126,7 @@ static void clipper_init(MachineState *machine)pci_init_nic_devices (pci_bus, mc->default_nic);/* Super I/O */ -isa_create_simple (isa_bus,TYPE_SMC37C669_SUPERIO ); +isa_create_simple_orphan (isa_bus,TYPE_SMC37C669_SUPERIO );/* IDE disk setup. */ pci_dev =pci_create_simple_orphan (pci_bus,-1 ,"cmd646-ide" );
hw/char/parallel-isa.c +1 -1
@@ -22,7 +22,7 @@ static void parallel_init(ISABus *bus, int index, Chardev *chr)DeviceState *dev;ISADevice *isadev; - isadev =isa_new (TYPE_ISA_PARALLEL ); + isadev =isa_new_orphan (TYPE_ISA_PARALLEL ); dev =DEVICE (isadev);qdev_prop_set_uint32 (dev,"index" , index);qdev_prop_set_chr (dev,"chardev" , chr);
hw/char/serial-isa.c +1 -1
@@ -165,7 +165,7 @@ static void serial_isa_init(ISABus *bus, int index, Chardev *chr)DeviceState *dev;ISADevice *isadev; - isadev =isa_new (TYPE_ISA_SERIAL ); + isadev =isa_new_orphan (TYPE_ISA_SERIAL ); dev =DEVICE (isadev);qdev_prop_set_uint32 (dev,"index" , index);qdev_prop_set_chr (dev,"chardev" , chr);
hw/dma/i8257.c +2 -2
@@ -651,7 +651,7 @@ void i8257_dma_init(Object *parent, ISABus *bus, bool high_page_enable)ISADevice *isa1, *isa2;DeviceState *d; - isa1 =isa_new (TYPE_I8257 ); + isa1 =isa_new_orphan (TYPE_I8257 );object_property_add_child (parent,"dma[*]" ,OBJECT (isa1)); d =DEVICE (isa1);qdev_prop_set_int32 (d,"base" ,0x00 );
@@ -660,7 +660,7 @@ void i8257_dma_init(Object *parent, ISABus *bus, bool high_page_enable)qdev_prop_set_int32 (d,"dshift" ,0 );isa_realize_and_unref (isa1, bus, &error_fatal); - isa2 =isa_new (TYPE_I8257 ); + isa2 =isa_new_orphan (TYPE_I8257 );object_property_add_child (parent,"dma[*]" ,OBJECT (isa2)); d =DEVICE (isa2);qdev_prop_set_int32 (d,"base" ,0xc0 );
hw/i386/isapc.c +1 -1
@@ -112,7 +112,7 @@ static void pc_init_isa(MachineState *machine) &error_abort);isa_bus_register_input_irqs (isa_bus, x86ms->gsi); - x86ms->rtc =isa_new (TYPE_MC146818_RTC ); + x86ms->rtc =isa_new_orphan (TYPE_MC146818_RTC );qdev_prop_set_int32 (DEVICE (x86ms->rtc),"base_year" ,2000 );isa_realize_and_unref (x86ms->rtc, isa_bus, &error_fatal); irq = object_property_get_uint(OBJECT(x86ms->rtc), "irq",
hw/i386/pc.c +6 -6
@@ -998,7 +998,7 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, }if (create_fdctrl) {#ifdef CONFIG_FDC_ISA -ISADevice *fdc =isa_new (TYPE_ISA_FDC ); +ISADevice *fdc =isa_new_orphan (TYPE_ISA_FDC );if (fdc) {isa_realize_and_unref (fdc, isa_bus, &error_fatal);isa_fdc_init_drives (fdc, fd);
@@ -1014,10 +1014,10 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl,return ; } - i8042 =isa_create_simple (isa_bus,TYPE_I8042 ); + i8042 =isa_create_simple_orphan (isa_bus,TYPE_I8042 );if (!no_vmport) { -isa_create_simple (isa_bus,TYPE_VMPORT ); - vmmouse =isa_try_new ("vmmouse" ); +isa_create_simple_orphan (isa_bus,TYPE_VMPORT ); + vmmouse =isa_try_new_orphan ("vmmouse" ); }else { vmmouse =NULL ; }
@@ -1026,7 +1026,7 @@ static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, &error_abort);isa_realize_and_unref (vmmouse, isa_bus, &error_fatal); } - port92 =isa_create_simple (isa_bus,TYPE_PORT92 ); + port92 =isa_create_simple_orphan (isa_bus,TYPE_PORT92 ); a20_line =qemu_allocate_irqs (handle_a20_line_change, first_cpu,2 ); qdev_connect_gpio_out_named(DEVICE(i8042),
@@ -1639,7 +1639,7 @@ static void pc_machine_initfn(Object *obj) pcms->default_bus_bypass_iommu = false;pc_system_flash_create (pcms); - pcms->pcspk =isa_new (TYPE_PC_SPEAKER ); + pcms->pcspk =isa_new_orphan (TYPE_PC_SPEAKER );object_property_add_alias (OBJECT (pcms),"pcspk-audiodev" ,OBJECT (pcms->pcspk),"audiodev" );if (pcmc->pci_enabled) {
hw/ide/isa.c +1 -1
@@ -84,7 +84,7 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int iobase2, int irqnum,ISADevice *isadev;ISAIDEState *s; - isadev =isa_new (TYPE_ISA_IDE ); + isadev =isa_new_orphan (TYPE_ISA_IDE ); dev =DEVICE (isadev);qdev_prop_set_uint32 (dev,"iobase" , iobase);qdev_prop_set_uint32 (dev,"iobase2" , iobase2);
hw/intc/i8259_common.c +1 -1
@@ -94,7 +94,7 @@ ISADevice *i8259_init_chip(const char *name, ISABus *bus, bool master)DeviceState *dev;ISADevice *isadev; - isadev =isa_new (name); + isadev =isa_new_orphan (name); dev =DEVICE (isadev);qdev_prop_set_uint32 (dev,"iobase" , master ?0x20 :0xa0 );qdev_prop_set_uint32 (dev,"elcr_addr" , master ?0x4d0 :0x4d1 );
hw/isa/i82378.c +2 -2
@@ -103,14 +103,14 @@ static void i82378_realize(PCIDevice *pci, Error **errp) pit =i8254_pit_init (isabus,0x40 ,0 ,NULL );/* speaker */ - pcspk =isa_new (TYPE_PC_SPEAKER ); + pcspk =isa_new_orphan (TYPE_PC_SPEAKER );object_property_set_link (OBJECT (pcspk),"pit" ,OBJECT (pit), &error_fatal);if (!isa_realize_and_unref (pcspk, isabus, errp)) {return ; }/* 2 82C37 (dma) */ -isa_create_simple (isabus,"i82374" ); +isa_create_simple_orphan (isabus,"i82374" ); }static void i82378_init (Object *obj)
hw/isa/isa-bus.c +24 -6
@@ -153,21 +153,39 @@ int isa_register_portio_list(ISADevice *dev,return 0 ; } -ISADevice *isa_new (const char *name) +ISADevice *isa_new (Object *parent,const char *id,const char *type) +{ +return ISA_DEVICE (qdev_new (parent, id, type)); +} + +ISADevice *isa_try_new (Object *parent,const char *id,const char *type) +{ +return ISA_DEVICE (qdev_try_new (parent, id, type)); +} + +ISADevice *isa_create_simple (Object *parent,const char *id, +ISABus *bus,const char *type) +{ +ISADevice *dev =isa_new (parent, id, type); +qdev_realize (DEVICE (dev),BUS (bus), &error_fatal); +return dev; +} + +ISADevice *isa_new_orphan (const char *name) {return ISA_DEVICE (qdev_new_orphan (name)); } -ISADevice *isa_try_new (const char *name) +ISADevice *isa_try_new_orphan (const char *name) {return ISA_DEVICE (qdev_try_new_orphan (name)); } -ISADevice *isa_create_simple (ISABus *bus,const char *name) +ISADevice *isa_create_simple_orphan (ISABus *bus,const char *name) {ISADevice *dev; - dev =isa_new (name); + dev =isa_new_orphan (name);isa_realize_and_unref (dev, bus, &error_fatal);return dev; }
@@ -187,12 +205,12 @@ ISADevice *isa_vga_init(ISABus *bus) vga_interface_created = true;switch (vga_interface_type) {case VGA_CIRRUS : -return isa_create_simple (bus,"isa-cirrus-vga" ); +return isa_create_simple_orphan (bus,"isa-cirrus-vga" );case VGA_QXL :error_report ("%s: qxl: no PCI bus" , __func__);return NULL ;case VGA_STD : -return isa_create_simple (bus,"isa-vga" ); +return isa_create_simple_orphan (bus,"isa-vga" );case VGA_VMWARE :error_report ("%s: vmware_vga: no PCI bus" , __func__);return NULL ;
hw/isa/isa-superio.c +5 -5
@@ -54,7 +54,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) }else { name =g_strdup_printf ("parallel%d" , i); } - isa =isa_new (TYPE_ISA_PARALLEL ); + isa =isa_new_orphan (TYPE_ISA_PARALLEL ); d =DEVICE (isa);qdev_prop_set_uint32 (d,"index" , i);if (k->parallel.get_iobase) {
@@ -93,7 +93,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) }else { name =g_strdup_printf ("serial%d" , i); } - isa =isa_new (TYPE_ISA_SERIAL ); + isa =isa_new_orphan (TYPE_ISA_SERIAL ); d =DEVICE (isa);qdev_prop_set_uint32 (d,"index" , i);if (k->serial.get_iobase) {
@@ -120,7 +120,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 (TYPE_ISA_FDC ); + isa =isa_new_orphan (TYPE_ISA_FDC ); d =DEVICE (isa);if (k->floppy.get_iobase) {qdev_prop_set_uint32 (d,"iobase" , k->floppy.get_iobase (sio,0 ));
@@ -144,14 +144,14 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) }/* Keyboard, mouse */ - isa =isa_new (TYPE_I8042 ); + isa =isa_new_orphan (TYPE_I8042 );object_property_add_child (OBJECT (sio),TYPE_I8042 ,OBJECT (isa));isa_realize_and_unref (isa, bus, &error_fatal); sio->kbc = isa;/* IDE */ if (k->ide.count && (!k->ide.is_enabled || k->ide.is_enabled (sio,0 ))) { - isa =isa_new ("isa-ide" ); + isa =isa_new_orphan ("isa-ide" ); d =DEVICE (isa);if (k->ide.get_iobase) {qdev_prop_set_uint32 (d,"iobase" , k->ide.get_iobase (sio,0 ));
hw/mips/jazz.c +1 -1
@@ -289,7 +289,7 @@ static void mips_jazz_init(MachineState *machine,isa_bus_register_input_irqs (isa_bus, i8259);i8257_dma_init (OBJECT (rc4030), isa_bus,0 ); pit =i8254_pit_init (isa_bus,0x40 ,0 ,NULL ); - pcspk =isa_new (TYPE_PC_SPEAKER ); + pcspk =isa_new_orphan (TYPE_PC_SPEAKER );object_property_set_link (OBJECT (pcspk),"pit" ,OBJECT (pit), &error_fatal);isa_realize_and_unref (pcspk, isa_bus, &error_fatal);
hw/mips/malta.c +1 -1
@@ -1253,7 +1253,7 @@ void mips_malta_init(MachineState *machine)g_free (smbus_eeprom_buf);/* Super I/O: SMS FDC37M817 */ -isa_create_simple (isa_bus,TYPE_FDC37M81X_SUPERIO ); +isa_create_simple_orphan (isa_bus,TYPE_FDC37M81X_SUPERIO );/* Network card */ network_init (pci_bus);
hw/ppc/pnv.c +1 -1
@@ -1010,7 +1010,7 @@ static bool pnv_match_cpu(const char *default_type, const char *cpu_type)static void pnv_ipmi_bt_init (ISABus *bus,IPMIBmc *bmc,uint32_t irq) { -ISADevice *dev =isa_new ("isa-ipmi-bt" ); +ISADevice *dev =isa_new_orphan ("isa-ipmi-bt" );object_property_set_link (OBJECT (dev),"bmc" ,OBJECT (bmc), &error_fatal);object_property_set_int (OBJECT (dev),"irq" , irq, &error_fatal);
hw/ppc/prep.c +6 -6
@@ -309,20 +309,20 @@ static void ibm_40p_init(MachineState *machine) isa_bus =ISA_BUS (qdev_get_child_bus (i82378_dev,"isa.0" ));/* system control ports */ - isa_dev =isa_new ("prep-systemio" ); + isa_dev =isa_new_orphan ("prep-systemio" ); dev =DEVICE (isa_dev);qdev_prop_set_uint32 (dev,"ibm-planar-id" ,0xfc );qdev_prop_set_uint32 (dev,"equipment" ,0xc0 );isa_realize_and_unref (isa_dev, isa_bus, &error_fatal);/* Memory controller */ - isa_dev =isa_new ("rs6000-mc" ); + isa_dev =isa_new_orphan ("rs6000-mc" ); dev =DEVICE (isa_dev);qdev_prop_set_uint32 (dev,"ram-size" , machine->ram_size);isa_realize_and_unref (isa_dev, isa_bus, &error_fatal);/* RTC */ - isa_dev =isa_new (TYPE_MC146818_RTC ); + isa_dev =isa_new_orphan (TYPE_MC146818_RTC ); dev =DEVICE (isa_dev);qdev_prop_set_int32 (dev,"base_year" ,1900 );isa_realize_and_unref (isa_dev, isa_bus, &error_fatal);
@@ -334,9 +334,9 @@ static void ibm_40p_init(MachineState *machine)/* add some more devices */ if (defaults_enabled ()) { - m48t59 =NVRAM (isa_create_simple (isa_bus,"isa-m48t59" )); + m48t59 =NVRAM (isa_create_simple_orphan (isa_bus,"isa-m48t59" )); - isa_dev =isa_new ("cs4231a" ); + isa_dev =isa_new_orphan ("cs4231a" ); dev =DEVICE (isa_dev);qdev_prop_set_uint32 (dev,"iobase" ,0x830 );qdev_prop_set_uint32 (dev,"irq" ,10 );
@@ -345,7 +345,7 @@ static void ibm_40p_init(MachineState *machine) }isa_realize_and_unref (isa_dev, isa_bus, &error_fatal); - isa_dev =isa_new ("pc87312" ); + isa_dev =isa_new_orphan ("pc87312" ); dev =DEVICE (isa_dev);qdev_prop_set_uint32 (dev,"config" ,12 );isa_realize_and_unref (isa_dev, isa_bus, &error_fatal);
hw/rtc/mc146818rtc.c +1 -1
@@ -930,7 +930,7 @@ MC146818RtcState *mc146818_rtc_init(ISABus *bus, int base_year,ISADevice *isadev;MC146818RtcState *s; - isadev =isa_new (TYPE_MC146818_RTC ); + isadev =isa_new_orphan (TYPE_MC146818_RTC ); dev =DEVICE (isadev); s =MC146818_RTC (isadev);qdev_prop_set_int32 (dev,"base_year" , base_year);
hw/sparc64/sun4u.c +2 -2
@@ -329,13 +329,13 @@ static void ebus_realize(PCIDevice *pci_dev, Error **errp)parallel_hds_isa_init (s->isa_bus,MAX_PARALLEL_PORTS );/* Keyboard */ -isa_create_simple (s->isa_bus,TYPE_I8042 ); +isa_create_simple_orphan (s->isa_bus,TYPE_I8042 );/* Floppy */ for (i =0 ; i <MAX_FD ; i++) { fd[i] =drive_get (IF_FLOPPY ,0 , i); } - isa_dev =isa_new (TYPE_ISA_FDC ); + isa_dev =isa_new_orphan (TYPE_ISA_FDC ); dev =DEVICE (isa_dev);qdev_prop_set_uint32 (dev,"dma" ,-1 );isa_realize_and_unref (isa_dev, s->isa_bus, &error_fatal);
include/hw/i386/vmport.h +1 -1
@@ -20,7 +20,7 @@ typedef enum {static inline void vmport_init (ISABus *bus) { -isa_create_simple (bus,TYPE_VMPORT ); +isa_create_simple_orphan (bus,TYPE_VMPORT ); }void vmport_register (VMPortCommand command,VMPortReadFunc *func,void *opaque);
include/hw/isa/isa.h +7 -3
@@ -80,10 +80,14 @@ IsaDma *isa_bus_get_dma(ISABus *bus, int nchan);* Return IRQ @irqnum from the PIC associated on ISA @bus. */ qemu_irq isa_bus_get_irq (ISABus *bus,unsigned irqnum); -ISADevice *isa_new (const char *name); -ISADevice *isa_try_new (const char *name); +ISADevice *isa_new (Object *parent,const char *id,const char *type); +ISADevice *isa_try_new (Object *parent,const char *id,const char *type); +ISADevice *isa_create_simple (Object *parent,const char *id, +ISABus *bus,const char *type); +ISADevice *isa_new_orphan (const char *name); +ISADevice *isa_try_new_orphan (const char *name);bool isa_realize_and_unref (ISADevice *dev,ISABus *bus,Error **errp); -ISADevice *isa_create_simple (ISABus *bus,const char *name); +ISADevice *isa_create_simple_orphan (ISABus *bus,const char *name);ISADevice *isa_vga_init (ISABus *bus);
include/hw/net/ne2000-isa.h +1 -1
@@ -22,7 +22,7 @@ static inline ISADevice *isa_ne2000_init(ISABus *bus, int base, int irq, {ISADevice *d; - d =isa_try_new (TYPE_ISA_NE2000 ); + d =isa_try_new_orphan (TYPE_ISA_NE2000 );if (d) {DeviceState *dev =DEVICE (d);
include/hw/timer/i8254.h +2 -2
@@ -51,7 +51,7 @@ static inline ISADevice *i8254_pit_init(ISABus *bus, int base, int isa_irq,DeviceState *dev;ISADevice *d; - d =isa_new (TYPE_I8254 ); + d =isa_new_orphan (TYPE_I8254 ); dev =DEVICE (d);qdev_prop_set_uint32 (dev,"iobase" , base);isa_realize_and_unref (d, bus, &error_fatal);
@@ -67,7 +67,7 @@ static inline ISADevice *kvm_pit_init(ISABus *bus, int base)DeviceState *dev;ISADevice *d; - d =isa_new (TYPE_KVM_I8254 ); + d =isa_new_orphan (TYPE_KVM_I8254 ); dev =DEVICE (d);qdev_prop_set_uint32 (dev,"iobase" , base);isa_realize_and_unref (d, bus, &error_fatal);
scripts/coccinelle/qom-parent/isa-new-orphan.cocci new file +23 -0
@@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// +// Rename isa_new()/isa_try_new()/isa_create_simple() to *_orphan() +// so that the short names can be reintroduced with a mandatory +// (parent, id, ...) signature. +// +// spatch --sp-file scripts/coccinelle/qom-parent/isa-new-orphan.cocci \ +// --in-place --include-headers --dir . + +@@ +@@ +- isa_new ++ isa_new_orphan + +@@ +@@ +- isa_try_new ++ isa_try_new_orphan + +@@ +@@ +- isa_create_simple ++ isa_create_simple_orphan
Signature · 1 line
2.47.1
RFC PATCH v2 7/137 i2c: Make i2c_slave_new()/i2c_slave_create_simple() take a QOM parent
In reply to Alexander GrafSame rename-and-reintroduce treatment as the qdev, sysbus, PCI and ISA layers: mechanically rename the two I2C-slave creation helpers to *_orphan() and reintroduce the short names with a leading (parent, id, ...) pair.
The parented i2c_slave_create_simple() calls qdev_realize() (not i2c_slave_realize_and_unref()) since the child<> property already holds the sole reference.
The mechanical rename part is generated by
spatch --sp-file \
scripts/coccinelle/qom-parent/i2c-slave-new-orphan.cocci \
--in-place --include-headers --dir .or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \
grep -v '^subprojects/' | \
xargs sed -i \
's/\bi2c_slave_create_simple\b/&_orphan/g;
s/\bi2c_slave_new\b/&_orphan/g'AI-used-for: code (refactoring)
--- hw/arm/aspeed.c | 4 +- hw/arm/aspeed_ast1040_evb.c | 2 +- hw/arm/aspeed_ast10x0_evb.c | 2 +- hw/arm/aspeed_ast2400_palmetto.c | 4 +- hw/arm/aspeed_ast2400_quanta-q71l.c | 12 ++-- hw/arm/aspeed_ast2400_supermicrox11.c | 4 +- hw/arm/aspeed_ast2500_evb.c | 2 +- hw/arm/aspeed_ast2500_g220a.c | 6 +- hw/arm/aspeed_ast2500_romulus.c | 2 +- hw/arm/aspeed_ast2500_supermicro-x11spi.c | 4 +- hw/arm/aspeed_ast2500_tiogapass.c | 6 +- hw/arm/aspeed_ast2500_witherspoon.c | 16 ++--- hw/arm/aspeed_ast2500_yosemitev2.c | 6 +- hw/arm/aspeed_ast2600_anacapa.c | 26 ++++----- hw/arm/aspeed_ast2600_bletchley.c | 20 +++---- hw/arm/aspeed_ast2600_catalina.c | 58 +++++++++---------- hw/arm/aspeed_ast2600_evb.c | 2 +- hw/arm/aspeed_ast2600_fby35.c | 10 ++-- hw/arm/aspeed_ast2600_fuji.c | 40 ++++++------- hw/arm/aspeed_ast2600_gb200nvl.c | 12 ++-- hw/arm/aspeed_ast2600_rainier.c | 46 +++++++-------- hw/arm/aspeed_ast27x0-fc.c | 2 +- hw/arm/aspeed_ast27x0_evb.c | 2 +- hw/arm/bananapi_m2u.c | 2 +- hw/arm/cubieboard.c | 2 +- hw/arm/musicpal.c | 2 +- hw/arm/npcm7xx_boards.c | 42 +++++++------- hw/arm/npcm8xx_boards.c | 2 +- hw/arm/realview.c | 2 +- hw/arm/stellaris.c | 2 +- hw/arm/versatilepb.c | 2 +- hw/arm/vexpress.c | 2 +- hw/display/sii9022.c | 2 +- hw/i2c/aspeed_i2c.c | 2 +- hw/i2c/core.c | 26 ++++++++- hw/i3c/core.c | 2 +- hw/nvram/eeprom_at24c.c | 2 +- hw/ppc/e500.c | 2 +- hw/ppc/pnv.c | 4 +- hw/ppc/sam460ex.c | 2 +- hw/riscv/tt_atlantis.c | 4 +- include/hw/arm/aspeed.h | 4 +- include/hw/i2c/i2c.h | 38 ++++++++++-- .../qom-parent/i2c-slave-new-orphan.cocci | 18 ++++++ 44 files changed, 260 insertions(+), 192 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/i2c-slave-new-orphan.cocci
hw/arm/aspeed.c +2 -2
@@ -253,13 +253,13 @@ static void aspeed_machine_init(MachineState *machine)void aspeed_create_pca9552 (AspeedSoCState *soc,int bus_id,int addr) { -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c, bus_id), +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c, bus_id),TYPE_PCA9552 , addr); }I2CSlave *aspeed_create_pca9554 (AspeedSoCState *soc,int bus_id,int addr) { -return i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c, bus_id), +return i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c, bus_id),TYPE_PCA9554 , addr); }
hw/arm/aspeed_ast1040_evb.c +1 -1
@@ -55,7 +55,7 @@ static void ast1040_evb_i2c_init(AspeedMachineState *bmc)uint8_t *eeprom_buf =g_malloc0 (256 );smbus_eeprom_init_one (aspeed_i2c_get_bus (&soc->i2c,0 ),0x50 , eeprom_buf); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4d ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4d ); } static void aspeed_machine_ast1040_evb_class_init(ObjectClass *oc,
hw/arm/aspeed_ast10x0_evb.c +1 -1
@@ -73,7 +73,7 @@ static void ast1030_evb_i2c_init(AspeedMachineState *bmc)smbus_eeprom_init_one (aspeed_i2c_get_bus (&soc->i2c,0 ),0x50 , eeprom_buf);/* U11 LM75 connects to SDA/SCL Group 2 by default */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4d ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4d ); } static void aspeed_minibmc_machine_ast1030_evb_class_init(ObjectClass *oc,
hw/arm/aspeed_ast2400_palmetto.c +2 -2
@@ -37,13 +37,13 @@ static void palmetto_bmc_i2c_init(AspeedMachineState *bmc)* The palmetto platform expects a ds3231 RTC but a ds1338 is * enough to provide basic RTC features. Alarms will be missing */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,0 ),"ds1338" ,0x68 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,0 ),"ds1338" ,0x68 );smbus_eeprom_init_one (aspeed_i2c_get_bus (&soc->i2c,0 ),0x50 , eeprom_buf);/* add a TMP423 temperature sensor */ - dev =DEVICE (i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,2 ), + dev =DEVICE (i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,2 ),"tmp423" ,0x4c ));object_property_set_int (OBJECT (dev),"temperature0" ,31000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature1" ,28000 , &error_abort);
hw/arm/aspeed_ast2400_quanta-q71l.c +6 -6
@@ -33,21 +33,21 @@ static void quanta_q71l_bmc_i2c_init(AspeedMachineState *bmc)* The quanta-q71l platform expects tmp75s which are compatible with * tmp105s. */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4c ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4e ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4f ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4c ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4e ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,1 ),"tmp105" ,0x4f );/* TODO: i2c-1: Add baseboard FRU eeprom@54 24c64 */ /* TODO: i2c-1: Add Frontpanel FRU eeprom@57 24c64 */ /* TODO: Add Memory Riser i2c mux and eeproms. */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,2 ),"pca9546" ,0x74 ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,2 ),"pca9548" ,0x77 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,2 ),"pca9546" ,0x74 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,2 ),"pca9548" ,0x77 );/* TODO: i2c-3: Add BIOS FRU eeprom@56 24c64 */ /* i2c-7 */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,7 ),"pca9546" ,0x70 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,7 ),"pca9546" ,0x70 );/* - i2c@0: pmbus@59 */ /* - i2c@1: pmbus@58 */ /* - i2c@2: pmbus@58 */
hw/arm/aspeed_ast2400_supermicrox11.c +2 -2
@@ -37,13 +37,13 @@ static void supermicrox11_bmc_i2c_init(AspeedMachineState *bmc)* The palmetto platform expects a ds3231 RTC but a ds1338 is * enough to provide basic RTC features. Alarms will be missing */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,0 ),"ds1338" ,0x68 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,0 ),"ds1338" ,0x68 );smbus_eeprom_init_one (aspeed_i2c_get_bus (&soc->i2c,0 ),0x50 , eeprom_buf);/* add a TMP423 temperature sensor */ - dev =DEVICE (i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,2 ), + dev =DEVICE (i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,2 ),"tmp423" ,0x4c ));object_property_set_int (OBJECT (dev),"temperature0" ,31000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature1" ,28000 , &error_abort);
hw/arm/aspeed_ast2500_evb.c +1 -1
@@ -34,7 +34,7 @@ static void ast2500_evb_i2c_init(AspeedMachineState *bmc) eeprom_buf);/* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,7 ), +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,7 ),TYPE_TMP105 ,0x4d ); }
hw/arm/aspeed_ast2500_g220a.c +3 -3
@@ -32,19 +32,19 @@ static void g220a_bmc_i2c_init(AspeedMachineState *bmc)AspeedSoCState *soc = bmc->soc;DeviceState *dev; - dev =DEVICE (i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,3 ), + dev =DEVICE (i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,3 ),"emc1413" ,0x4c ));object_property_set_int (OBJECT (dev),"temperature0" ,31000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature1" ,28000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature2" ,20000 , &error_abort); - dev =DEVICE (i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,12 ), + dev =DEVICE (i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,12 ),"emc1413" ,0x4c ));object_property_set_int (OBJECT (dev),"temperature0" ,31000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature1" ,28000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature2" ,20000 , &error_abort); - dev =DEVICE (i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,13 ), + dev =DEVICE (i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,13 ),"emc1413" ,0x4c ));object_property_set_int (OBJECT (dev),"temperature0" ,31000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature1" ,28000 , &error_abort);
hw/arm/aspeed_ast2500_romulus.c +1 -1
@@ -30,7 +30,7 @@ static void romulus_bmc_i2c_init(AspeedMachineState *bmc)* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is * good enough */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,11 ),"ds1338" ,0x32 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,11 ),"ds1338" ,0x32 ); } static void aspeed_machine_romulus_class_init(ObjectClass *oc,
hw/arm/aspeed_ast2500_supermicro-x11spi.c +2 -2
@@ -33,13 +33,13 @@ static void supermicro_x11spi_bmc_i2c_init(AspeedMachineState *bmc)* The palmetto platform expects a ds3231 RTC but a ds1338 is * enough to provide basic RTC features. Alarms will be missing */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,0 ),"ds1338" ,0x68 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,0 ),"ds1338" ,0x68 );smbus_eeprom_init_one (aspeed_i2c_get_bus (&soc->i2c,0 ),0x50 , eeprom_buf);/* add a TMP423 temperature sensor */ - dev =DEVICE (i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,2 ), + dev =DEVICE (i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,2 ),"tmp423" ,0x4c ));object_property_set_int (OBJECT (dev),"temperature0" ,31000 , &error_abort);object_property_set_int (OBJECT (dev),"temperature1" ,28000 , &error_abort);
hw/arm/aspeed_ast2500_tiogapass.c +3 -3
@@ -55,9 +55,9 @@ static void tiogapass_bmc_i2c_init(AspeedMachineState *bmc)at24c_eeprom_init_rom (aspeed_i2c_get_bus (&soc->i2c,6 ),0x54 ,128 * KiB, tiogapass_bmc_fruid, tiogapass_bmc_fruid_len);/* TMP421 */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,8 ),"tmp421" ,0x1f ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,6 ),"tmp421" ,0x4f ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,6 ),"tmp421" ,0x4e ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,8 ),"tmp421" ,0x1f ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,6 ),"tmp421" ,0x4f ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,6 ),"tmp421" ,0x4e ); } static void aspeed_machine_tiogapass_class_init(ObjectClass *oc,
hw/arm/aspeed_ast2500_witherspoon.c +8 -8
@@ -44,7 +44,7 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc)LEDState *led;/* Bus 3: TODO bmp280@77 */ - dev =DEVICE (i2c_slave_new (TYPE_PCA9552 ,0x60 )); + dev =DEVICE (i2c_slave_new_orphan (TYPE_PCA9552 ,0x60 ));qdev_prop_set_string (dev,"description" ,"pca1" ); i2c_slave_realize_and_unref(I2C_SLAVE(dev), aspeed_i2c_get_bus(&soc->i2c, 3),
@@ -58,24 +58,24 @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc)qdev_connect_gpio_out (dev, pca1_leds[i].gpio_id,qdev_get_gpio_in (DEVICE (led),0 )); } -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,3 ),"dps310" ,0x76 ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,3 ),"max31785" ,0x52 ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,4 ),"tmp423" ,0x4c ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,5 ),"tmp423" ,0x4c ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,3 ),"dps310" ,0x76 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,3 ),"max31785" ,0x52 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,4 ),"tmp423" ,0x4c ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,5 ),"tmp423" ,0x4c );/* The Witherspoon expects a TMP275 but a TMP105 is compatible */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,9 ),TYPE_TMP105 , +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,9 ),TYPE_TMP105 ,0x4a );/* * The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is * good enough */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,11 ),"ds1338" ,0x32 ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,11 ),"ds1338" ,0x32 );smbus_eeprom_init_one (aspeed_i2c_get_bus (&soc->i2c,11 ),0x51 , eeprom_buf); - dev =DEVICE (i2c_slave_new (TYPE_PCA9552 ,0x60 )); + dev =DEVICE (i2c_slave_new_orphan (TYPE_PCA9552 ,0x60 ));qdev_prop_set_string (dev,"description" ,"pca0" ); i2c_slave_realize_and_unref(I2C_SLAVE(dev), aspeed_i2c_get_bus(&soc->i2c, 11),
hw/arm/aspeed_ast2500_yosemitev2.c +3 -3
@@ -55,9 +55,9 @@ static void yosemitev2_bmc_i2c_init(AspeedMachineState *bmc)at24c_eeprom_init_rom (aspeed_i2c_get_bus (&soc->i2c,8 ),0x51 ,128 * KiB, yosemitev2_bmc_fruid, yosemitev2_bmc_fruid_len);/* TMP421 */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,11 ),"tmp421" ,0x1f ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,9 ),"tmp421" ,0x4e ); -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,9 ),"tmp421" ,0x4f ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,11 ),"tmp421" ,0x1f ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,9 ),"tmp421" ,0x4e ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,9 ),"tmp421" ,0x4f ); }
hw/arm/aspeed_ast2600_anacapa.c +13 -13
@@ -237,17 +237,17 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)/* eeprom@50 */ at24c_eeprom_init (i2c[0 ],0x50 ,256 * KiB);/* i2c-mux@70 */ -i2c_slave_create_simple (i2c[0 ],TYPE_PCA9546 ,0x70 ); +i2c_slave_create_simple_orphan (i2c[0 ],TYPE_PCA9546 ,0x70 );/* &i2c1 */ /* eeprom@50 */ at24c_eeprom_init (i2c[1 ],0x50 ,256 * KiB);/* i2c-mux@70 (PCA9546) — 4 channels, empty */ -i2c_slave_create_simple (i2c[1 ],TYPE_PCA9546 ,0x70 ); +i2c_slave_create_simple_orphan (i2c[1 ],TYPE_PCA9546 ,0x70 );/* &i2c4 */ /* i2c-mux@70 (PCA9548) */ -i2c_slave_create_simple (i2c[4 ],TYPE_PCA9548 ,0x70 ); +i2c_slave_create_simple_orphan (i2c[4 ],TYPE_PCA9548 ,0x70 );/* &i2c6 */ /* eeprom@50 */
@@ -256,15 +256,15 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)/* &i2c8 */ /* i2c-mux@72 (PCA9546) */ - i2c_mux =i2c_slave_create_simple (i2c[8 ],TYPE_PCA9546 ,0x72 ); + i2c_mux =i2c_slave_create_simple_orphan (i2c[8 ],TYPE_PCA9546 ,0x72 );/* i2c8mux ch0 */ /* adc128d818@1f — no model */ /* pca9555@22 */ -i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,0 ), +i2c_slave_create_simple_orphan (pca954x_i2c_get_bus (i2c_mux,0 ),TYPE_PCA9552 ,0x22 );/* pca9555@24 */ -i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,0 ), +i2c_slave_create_simple_orphan (pca954x_i2c_get_bus (i2c_mux,0 ),TYPE_PCA9552 ,0x24 );/* eeprom@50 */ at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 16 * KiB,
@@ -272,10 +272,10 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)/* i2c8mux ch1 */ /* pca9555@22 */ -i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,1 ), +i2c_slave_create_simple_orphan (pca954x_i2c_get_bus (i2c_mux,1 ),TYPE_PCA9552 ,0x22 );/* pca9555@24 */ -i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,1 ), +i2c_slave_create_simple_orphan (pca954x_i2c_get_bus (i2c_mux,1 ),TYPE_PCA9552 ,0x24 );/* eeprom@50 */ at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 1), 0x50, 16 * KiB,
@@ -291,11 +291,11 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)/* &i2c10 */ /* i2c-mux@71 (PCA9548) */ - i2c_mux =i2c_slave_create_simple (i2c[10 ],TYPE_PCA9548 ,0x71 ); + i2c_mux =i2c_slave_create_simple_orphan (i2c[10 ],TYPE_PCA9548 ,0x71 );/* i2c10mux ch5 */ /* pca9555@22*/ -i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,5 ), +i2c_slave_create_simple_orphan (pca954x_i2c_get_bus (i2c_mux,5 ),TYPE_PCA9552 ,0x22 );/* eeprom@52 */ at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 5), 0x52, 32 * KiB,
@@ -303,13 +303,13 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)/* &i2c11 */ /* i2c-mux@71 (PCA9548) */ - i2c_mux =i2c_slave_create_simple (i2c[11 ],TYPE_PCA9548 ,0x71 ); + i2c_mux =i2c_slave_create_simple_orphan (i2c[11 ],TYPE_PCA9548 ,0x71 );/* i2c11mux ch0-ch4 — empty */ /* i2c11mux ch5 */ /* pca9555@22 */ -i2c_slave_create_simple (pca954x_i2c_get_bus (i2c_mux,5 ), +i2c_slave_create_simple_orphan (pca954x_i2c_get_bus (i2c_mux,5 ),TYPE_PCA9552 ,0x22 );/* eeprom@52 */ at24c_eeprom_init_rom(pca954x_i2c_get_bus(i2c_mux, 5), 0x52, 32 * KiB,
@@ -317,7 +317,7 @@ static void anacapa_bmc_i2c_init(AspeedMachineState *bmc)/* &i2c13 */ /* i2c-mux@70 (PCA9548) */ - i2c_mux =i2c_slave_create_simple (i2c[13 ],TYPE_PCA9548 ,0x70 ); + i2c_mux =i2c_slave_create_simple_orphan (i2c[13 ],TYPE_PCA9548 ,0x70 );/* i2c13mux ch3 */ /* adc128d818@1f - no model */
hw/arm/aspeed_ast2600_bletchley.c +10 -10
@@ -35,35 +35,35 @@ static void bletchley_bmc_i2c_init(AspeedMachineState *bmc)for (int i =0 ; i <6 ; i++) {/* Missing model: ti,ina230 @ 0x45 */ /* Missing model: mps,mp5023 @ 0x40 */ -i2c_slave_create_simple (i2c[i],TYPE_TMP421 ,0x4f ); +i2c_slave_create_simple_orphan (i2c[i],TYPE_TMP421 ,0x4f );/* Missing model: nxp,pca9539 @ 0x76, but PCA9552 works enough */ -i2c_slave_create_simple (i2c[i],TYPE_PCA9552 ,0x76 ); -i2c_slave_create_simple (i2c[i],TYPE_PCA9552 ,0x67 ); +i2c_slave_create_simple_orphan (i2c[i],TYPE_PCA9552 ,0x76 ); +i2c_slave_create_simple_orphan (i2c[i],TYPE_PCA9552 ,0x67 );/* Missing model: fsc,fusb302 @ 0x22 */ }/* Bus 6 */ at24c_eeprom_init (i2c[6 ],0x56 ,65536 );/* Missing model: nxp,pcf85263 @ 0x51 , but ds1338 works enough */ -i2c_slave_create_simple (i2c[6 ],"ds1338" ,0x51 ); +i2c_slave_create_simple_orphan (i2c[6 ],"ds1338" ,0x51 );/* Bus 7 */ at24c_eeprom_init (i2c[7 ],0x54 ,65536 );/* Bus 9 */ -i2c_slave_create_simple (i2c[9 ],TYPE_TMP421 ,0x4f ); +i2c_slave_create_simple_orphan (i2c[9 ],TYPE_TMP421 ,0x4f );/* Bus 10 */ -i2c_slave_create_simple (i2c[10 ],TYPE_TMP421 ,0x4f ); +i2c_slave_create_simple_orphan (i2c[10 ],TYPE_TMP421 ,0x4f );/* Missing model: ti,hdc1080 @ 0x40 */ -i2c_slave_create_simple (i2c[10 ],TYPE_PCA9552 ,0x67 ); +i2c_slave_create_simple_orphan (i2c[10 ],TYPE_PCA9552 ,0x67 );/* Bus 12 */ /* Missing model: adi,adm1278 @ 0x11 */ -i2c_slave_create_simple (i2c[12 ],TYPE_TMP421 ,0x4c ); -i2c_slave_create_simple (i2c[12 ],TYPE_TMP421 ,0x4d ); -i2c_slave_create_simple (i2c[12 ],TYPE_PCA9552 ,0x67 ); +i2c_slave_create_simple_orphan (i2c[12 ],TYPE_TMP421 ,0x4c ); +i2c_slave_create_simple_orphan (i2c[12 ],TYPE_TMP421 ,0x4d ); +i2c_slave_create_simple_orphan (i2c[12 ],TYPE_PCA9552 ,0x67 ); } static void aspeed_machine_bletchley_class_init(ObjectClass *oc,
hw/arm/aspeed_ast2600_catalina.c +29 -29
151 lines not on this page · raw message
hw/arm/aspeed_ast2600_evb.c +1 -1
@@ -27,7 +27,7 @@ static void ast2600_evb_i2c_init(AspeedMachineState *bmc) eeprom_buf);/* LM75 is compatible with TMP105 driver */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,8 ), +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,8 ),TYPE_TMP105 ,0x4d ); }
hw/arm/aspeed_ast2600_fby35.c +5 -5
@@ -102,12 +102,12 @@ static void fby35_i2c_init(AspeedMachineState *bmc) i2c[i] =aspeed_i2c_get_bus (&soc->i2c, i); } -i2c_slave_create_simple (i2c[2 ],TYPE_LM75 ,0x4f ); -i2c_slave_create_simple (i2c[8 ],TYPE_TMP421 ,0x1f ); +i2c_slave_create_simple_orphan (i2c[2 ],TYPE_LM75 ,0x4f ); +i2c_slave_create_simple_orphan (i2c[8 ],TYPE_TMP421 ,0x1f );/* Hotswap controller is actually supposed to be mp5920 or ltc4282. */ -i2c_slave_create_simple (i2c[11 ],"adm1272" ,0x44 ); -i2c_slave_create_simple (i2c[12 ],TYPE_LM75 ,0x4e ); -i2c_slave_create_simple (i2c[12 ],TYPE_LM75 ,0x4f ); +i2c_slave_create_simple_orphan (i2c[11 ],"adm1272" ,0x44 ); +i2c_slave_create_simple_orphan (i2c[12 ],TYPE_LM75 ,0x4e ); +i2c_slave_create_simple_orphan (i2c[12 ],TYPE_LM75 ,0x4f );at24c_eeprom_init (i2c[4 ],0x51 ,128 * KiB);at24c_eeprom_init (i2c[6 ],0x51 ,128 * KiB);
hw/arm/aspeed_ast2600_fuji.c +20 -20
@@ -27,7 +27,7 @@static void get_pca9548_channels (I2CBus *bus,uint8_t mux_addr,I2CBus **channels) { -I2CSlave *mux =i2c_slave_create_simple (bus,"pca9548" , mux_addr); +I2CSlave *mux =i2c_slave_create_simple_orphan (bus,"pca9548" , mux_addr);for (int i =0 ; i <8 ; i++) { channels[i] =pca954x_i2c_get_bus (mux, i); }
@@ -57,8 +57,8 @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc)get_pca9548_channels (i2c[40 + i],0x76 , &i2c[80 + i *8 ]); } -i2c_slave_create_simple (i2c[17 ],TYPE_LM75 ,0x4c ); -i2c_slave_create_simple (i2c[17 ],TYPE_LM75 ,0x4d ); +i2c_slave_create_simple_orphan (i2c[17 ],TYPE_LM75 ,0x4c ); +i2c_slave_create_simple_orphan (i2c[17 ],TYPE_LM75 ,0x4d );/* * EEPROM 24c64 size is 64Kbits or 8 Kbytes
@@ -68,33 +68,33 @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc)at24c_eeprom_init (i2c[20 ],0x50 ,256 );at24c_eeprom_init (i2c[22 ],0x52 ,256 ); -i2c_slave_create_simple (i2c[3 ],TYPE_LM75 ,0x48 ); -i2c_slave_create_simple (i2c[3 ],TYPE_LM75 ,0x49 ); -i2c_slave_create_simple (i2c[3 ],TYPE_LM75 ,0x4a ); -i2c_slave_create_simple (i2c[3 ],TYPE_TMP422 ,0x4c ); +i2c_slave_create_simple_orphan (i2c[3 ],TYPE_LM75 ,0x48 ); +i2c_slave_create_simple_orphan (i2c[3 ],TYPE_LM75 ,0x49 ); +i2c_slave_create_simple_orphan (i2c[3 ],TYPE_LM75 ,0x4a ); +i2c_slave_create_simple_orphan (i2c[3 ],TYPE_TMP422 ,0x4c );at24c_eeprom_init (i2c[8 ],0x51 ,8 * KiB); -i2c_slave_create_simple (i2c[8 ],TYPE_LM75 ,0x4a ); +i2c_slave_create_simple_orphan (i2c[8 ],TYPE_LM75 ,0x4a ); -i2c_slave_create_simple (i2c[50 ],TYPE_LM75 ,0x4c ); +i2c_slave_create_simple_orphan (i2c[50 ],TYPE_LM75 ,0x4c );at24c_eeprom_init (i2c[50 ],0x52 ,8 * KiB); -i2c_slave_create_simple (i2c[51 ],TYPE_TMP75 ,0x48 ); -i2c_slave_create_simple (i2c[52 ],TYPE_TMP75 ,0x49 ); +i2c_slave_create_simple_orphan (i2c[51 ],TYPE_TMP75 ,0x48 ); +i2c_slave_create_simple_orphan (i2c[52 ],TYPE_TMP75 ,0x49 ); -i2c_slave_create_simple (i2c[59 ],TYPE_TMP75 ,0x48 ); -i2c_slave_create_simple (i2c[60 ],TYPE_TMP75 ,0x49 ); +i2c_slave_create_simple_orphan (i2c[59 ],TYPE_TMP75 ,0x48 ); +i2c_slave_create_simple_orphan (i2c[60 ],TYPE_TMP75 ,0x49 );at24c_eeprom_init (i2c[65 ],0x53 ,8 * KiB); -i2c_slave_create_simple (i2c[66 ],TYPE_TMP75 ,0x49 ); -i2c_slave_create_simple (i2c[66 ],TYPE_TMP75 ,0x48 ); +i2c_slave_create_simple_orphan (i2c[66 ],TYPE_TMP75 ,0x49 ); +i2c_slave_create_simple_orphan (i2c[66 ],TYPE_TMP75 ,0x48 );at24c_eeprom_init (i2c[68 ],0x52 ,8 * KiB);at24c_eeprom_init (i2c[69 ],0x52 ,8 * KiB);at24c_eeprom_init (i2c[70 ],0x52 ,8 * KiB);at24c_eeprom_init (i2c[71 ],0x52 ,8 * KiB);at24c_eeprom_init (i2c[73 ],0x53 ,8 * KiB); -i2c_slave_create_simple (i2c[74 ],TYPE_TMP75 ,0x49 ); -i2c_slave_create_simple (i2c[74 ],TYPE_TMP75 ,0x48 ); +i2c_slave_create_simple_orphan (i2c[74 ],TYPE_TMP75 ,0x49 ); +i2c_slave_create_simple_orphan (i2c[74 ],TYPE_TMP75 ,0x48 );at24c_eeprom_init (i2c[76 ],0x52 ,8 * KiB);at24c_eeprom_init (i2c[77 ],0x52 ,8 * KiB);at24c_eeprom_init (i2c[78 ],0x52 ,8 * KiB);
@@ -103,9 +103,9 @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc)for (int i =0 ; i <8 ; i++) {at24c_eeprom_init (i2c[81 + i *8 ],0x56 ,64 * KiB); -i2c_slave_create_simple (i2c[82 + i *8 ],TYPE_TMP75 ,0x48 ); -i2c_slave_create_simple (i2c[83 + i *8 ],TYPE_TMP75 ,0x4b ); -i2c_slave_create_simple (i2c[84 + i *8 ],TYPE_TMP75 ,0x4a ); +i2c_slave_create_simple_orphan (i2c[82 + i *8 ],TYPE_TMP75 ,0x48 ); +i2c_slave_create_simple_orphan (i2c[83 + i *8 ],TYPE_TMP75 ,0x4b ); +i2c_slave_create_simple_orphan (i2c[84 + i *8 ],TYPE_TMP75 ,0x4a ); } }
hw/arm/aspeed_ast2600_gb200nvl.c +6 -6
@@ -54,12 +54,12 @@ static void gb200nvl_bmc_i2c_init(AspeedMachineState *bmc)aspeed_create_pca9554 (soc,4 ,0x21 );/* Mux I2c Expanders */ -i2c_slave_create_simple (i2c[5 ],"pca9546" ,0x71 ); -i2c_slave_create_simple (i2c[5 ],"pca9546" ,0x72 ); -i2c_slave_create_simple (i2c[5 ],"pca9546" ,0x73 ); -i2c_slave_create_simple (i2c[5 ],"pca9546" ,0x75 ); -i2c_slave_create_simple (i2c[5 ],"pca9546" ,0x76 ); -i2c_slave_create_simple (i2c[5 ],"pca9546" ,0x77 ); +i2c_slave_create_simple_orphan (i2c[5 ],"pca9546" ,0x71 ); +i2c_slave_create_simple_orphan (i2c[5 ],"pca9546" ,0x72 ); +i2c_slave_create_simple_orphan (i2c[5 ],"pca9546" ,0x73 ); +i2c_slave_create_simple_orphan (i2c[5 ],"pca9546" ,0x75 ); +i2c_slave_create_simple_orphan (i2c[5 ],"pca9546" ,0x76 ); +i2c_slave_create_simple_orphan (i2c[5 ],"pca9546" ,0x77 );/* Bus 10 */ dev =DEVICE (aspeed_create_pca9554 (soc,9 ,0x20 ));
hw/arm/aspeed_ast2600_rainier.c +23 -23
96 lines not on this page · raw message
hw/arm/aspeed_ast27x0-fc.c +1 -1
@@ -109,7 +109,7 @@ static bool ast2700fc_ca35_init(MachineState *machine, Error **errp)/* * AST2700 EVB has a LM75 temperature sensor on I2C bus 0 at address 0x4d. */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,0 ),"tmp105" ,0x4d ); +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,0 ),"tmp105" ,0x4d );aspeed_board_init_flashes (&soc->fmc,AST2700FC_FMC_MODEL ,2 ,0 );aspeed_board_init_flashes (&soc->spi[0 ],AST2700FC_SPI_MODEL ,1 ,2 );
hw/arm/aspeed_ast27x0_evb.c +1 -1
@@ -24,7 +24,7 @@ static void ast2700_evb_i2c_init(AspeedMachineState *bmc)AspeedSoCState *soc = bmc->soc;/* LM75 is compatible with TMP105 driver */ -i2c_slave_create_simple (aspeed_i2c_get_bus (&soc->i2c,0 ), +i2c_slave_create_simple_orphan (aspeed_i2c_get_bus (&soc->i2c,0 ),TYPE_TMP105 ,0x4d ); }
hw/arm/bananapi_m2u.c +1 -1
@@ -114,7 +114,7 @@ static void bpim2u_init(MachineState *machine)/* Connect AXP221 */ i2c =I2C_BUS (qdev_get_child_bus (DEVICE (&r40->i2c0),"i2c" )); -i2c_slave_create_simple (i2c,"axp221_pmu" ,0x34 ); +i2c_slave_create_simple_orphan (i2c,"axp221_pmu" ,0x34 );/* SDRAM */ memory_region_add_subregion(get_system_memory(),
hw/arm/cubieboard.c +1 -1
@@ -81,7 +81,7 @@ static void cubieboard_init(MachineState *machine)/* Connect AXP 209 */ i2c =I2C_BUS (qdev_get_child_bus (DEVICE (&a10->i2c0),"i2c" )); -i2c_slave_create_simple (i2c,"axp209_pmu" ,0x34 ); +i2c_slave_create_simple_orphan (i2c,"axp209_pmu" ,0x34 );/* Retrieve SD bus */ di =drive_get (IF_SD ,0 ,0 );
hw/arm/musicpal.c +1 -1
@@ -1327,7 +1327,7 @@ static void musicpal_init(MachineState *machine)qdev_connect_gpio_out (key_dev, i,qdev_get_gpio_in (dev, i +15 )); } - wm8750_dev =i2c_slave_new (TYPE_WM8750 ,MP_WM_ADDR ); + wm8750_dev =i2c_slave_new_orphan (TYPE_WM8750 ,MP_WM_ADDR );if (machine->audiodev) {qdev_prop_set_string (DEVICE (wm8750_dev),"audiodev" , machine->audiodev); }
hw/arm/npcm7xx_boards.c +21 -21
80 lines not on this page · raw message
hw/arm/npcm8xx_boards.c +1 -1
@@ -159,7 +159,7 @@ static void npcm8xx_connect_pwm_fan(NPCM8xxState *soc, SplitIRQ *splitter,static void npcm845_evb_i2c_init (NPCM8xxState *soc) {/* tmp100 temperature sensor on SVB, tmp105 is compatible */ -i2c_slave_create_simple (npcm8xx_i2c_get_bus (soc,6 ),"tmp105" ,0x48 ); +i2c_slave_create_simple_orphan (npcm8xx_i2c_get_bus (soc,6 ),"tmp105" ,0x48 ); }static void npcm845_evb_fan_init (NPCM8xxMachine *machine,NPCM8xxState *soc)
hw/arm/realview.c +1 -1
@@ -321,7 +321,7 @@ static void realview_init(MachineState *machine, dev =sysbus_create_simple_orphan (TYPE_ARM_SBCON_I2C ,0x10002000 ,NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" ); -i2c_slave_create_simple (i2c,"ds1338" ,0x68 ); +i2c_slave_create_simple_orphan (i2c,"ds1338" ,0x68 );/* Memory map for RealView Emulation Baseboard: */ /* 0x10000000 System registers. */
hw/arm/stellaris.c +1 -1
@@ -1209,7 +1209,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)if (board->peripherals &BP_OLED_I2C ) {I2CBus *bus = (I2CBus *)qdev_get_child_bus (i2c_dev[0 ],"i2c" ); -i2c_slave_create_simple (bus,"ssd0303" ,0x3d ); +i2c_slave_create_simple_orphan (bus,"ssd0303" ,0x3d ); }for (i =0 ; i <NUM_UART ; i++) {
hw/arm/versatilepb.c +1 -1
@@ -341,7 +341,7 @@ static void versatile_init(MachineState *machine, int board_id) dev =sysbus_create_simple_orphan (TYPE_ARM_SBCON_I2C ,0x10002000 ,NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" ); -i2c_slave_create_simple (i2c,"ds1338" ,0x68 ); +i2c_slave_create_simple_orphan (i2c,"ds1338" ,0x68 );/* Add PL041 AACI Interface to the LM4549 codec */ pl041 =qdev_new_orphan ("pl041" );
hw/arm/vexpress.c +1 -1
@@ -653,7 +653,7 @@ static void vexpress_common_init(MachineState *machine) dev =sysbus_create_simple_orphan (TYPE_ARM_SBCON_I2C , map[VE_SERIALDVI ],NULL ); i2c = (I2CBus *)qdev_get_child_bus (dev,"i2c" ); -i2c_slave_create_simple (i2c,"sii9022" ,0x39 ); +i2c_slave_create_simple_orphan (i2c,"sii9022" ,0x39 );sysbus_create_simple_orphan ("pl031" , map[VE_RTC ], pic[4 ]);/* RTC */
hw/display/sii9022.c +1 -1
@@ -164,7 +164,7 @@ static void sii9022_realize(DeviceState *dev, Error **errp)I2CBus *bus; bus =I2C_BUS (qdev_get_parent_bus (dev)); -i2c_slave_create_simple (bus,TYPE_I2CDDC ,0x50 ); +i2c_slave_create_simple_orphan (bus,TYPE_I2CDDC ,0x50 ); }static void sii9022_class_init (ObjectClass *klass,const void *data)
hw/i2c/aspeed_i2c.c +1 -1
@@ -1518,7 +1518,7 @@ static void aspeed_i2c_bus_realize(DeviceState *dev, Error **errp)sysbus_init_irq (SYS_BUS_DEVICE (dev), &s->irq); s->bus =i2c_init_bus (dev, s->name); - s->slave =i2c_slave_create_simple (s->bus,TYPE_ASPEED_I2C_BUS_SLAVE , + s->slave =i2c_slave_create_simple_orphan (s->bus,TYPE_ASPEED_I2C_BUS_SLAVE ,0xff ); memory_region_init_io(&s->mr, OBJECT(s), &aspeed_i2c_bus_ops,
hw/i2c/core.c +23 -3
@@ -364,7 +364,7 @@ const VMStateDescription vmstate_i2c_slave = { } }; -I2CSlave *i2c_slave_new (const char *name,uint8_t addr) +I2CSlave *i2c_slave_new_orphan (const char *name,uint8_t addr) {DeviceState *dev;
@@ -373,14 +373,34 @@ I2CSlave *i2c_slave_new(const char *name, uint8_t addr)return I2C_SLAVE (dev); } +I2CSlave *i2c_slave_new (Object *parent,const char *id, +const char *type,uint8_t addr) +{ +DeviceState *dev; + + dev =qdev_new (parent, id, type); +qdev_prop_set_uint8 (dev,"address" , addr); +return I2C_SLAVE (dev); +} + +I2CSlave *i2c_slave_create_simple (Object *parent,const char *id, +I2CBus *bus,const char *type, +uint8_t addr) +{ +I2CSlave *dev =i2c_slave_new (parent, id, type, addr); + +qdev_realize (DEVICE (dev),BUS (bus), &error_abort); +return dev; +} +bool i2c_slave_realize_and_unref (I2CSlave *dev,I2CBus *bus,Error **errp) {return qdev_realize_and_unref (&dev->qdev, &bus->qbus, errp); } -I2CSlave *i2c_slave_create_simple (I2CBus *bus,const char *name,uint8_t addr) +I2CSlave *i2c_slave_create_simple_orphan (I2CBus *bus,const char *name,uint8_t addr) { -I2CSlave *dev =i2c_slave_new (name, addr); +I2CSlave *dev =i2c_slave_new_orphan (name, addr);i2c_slave_realize_and_unref (dev, bus, &error_abort);
hw/i3c/core.c +1 -1
@@ -623,7 +623,7 @@ void legacy_i2c_end_transfer(I3CBus *bus)I2CSlave *legacy_i2c_device_create_simple (I3CBus *bus,const char *name,uint8_t addr) { -I2CSlave *dev =i2c_slave_new (name, addr); +I2CSlave *dev =i2c_slave_new_orphan (name, addr);i2c_slave_realize_and_unref (dev, bus->i2c_bus, &error_abort);return dev;
hw/nvram/eeprom_at24c.c +1 -1
@@ -148,7 +148,7 @@ I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t rom_size, {EEPROMState *s; - s =AT24C_EE (i2c_slave_new (TYPE_AT24C_EE , address)); + s =AT24C_EE (i2c_slave_new_orphan (TYPE_AT24C_EE , address));qdev_prop_set_uint32 (DEVICE (s),"rom-size" , rom_size);
hw/ppc/e500.c +1 -1
@@ -1025,7 +1025,7 @@ void ppce500_init(MachineState *machine)memory_region_add_subregion (ccsr_addr_space,MPC8544_I2C_REGS_OFFSET ,sysbus_mmio_get_region (s,0 )); i2c =I2C_BUS (qdev_get_child_bus (dev,"i2c" )); -i2c_slave_create_simple (i2c,"ds1338" ,RTC_REGS_OFFSET ); +i2c_slave_create_simple_orphan (i2c,"ds1338" ,RTC_REGS_OFFSET );/* eSDHC */ if (pmc->has_esdhc) {
hw/ppc/pnv.c +2 -2
@@ -2825,7 +2825,7 @@ static void pnv_rainier_i2c_init(PnvMachineState *pnv)* Add a PCA9552 I2C device for PCIe hotplug control * to engine 2, bus 1, address 0x63 */ -I2CSlave *dev =i2c_slave_create_simple (chip10->i2c[2 ].busses[1 ], +I2CSlave *dev =i2c_slave_create_simple_orphan (chip10->i2c[2 ].busses[1 ],"pca9552" ,0x63 );/*
@@ -2843,7 +2843,7 @@ static void pnv_rainier_i2c_init(PnvMachineState *pnv)* Add a PCA9554 I2C device for cable card presence detection * to engine 2, bus 1, address 0x25 */ -i2c_slave_create_simple (chip10->i2c[2 ].busses[1 ],"pca9554" ,0x25 ); +i2c_slave_create_simple_orphan (chip10->i2c[2 ].busses[1 ],"pca9554" ,0x25 ); } }
hw/ppc/sam460ex.c +1 -1
@@ -345,7 +345,7 @@ static void sam460ex_init(MachineState *machine) spd_data[20 ] =4 ;/* SO-DIMM module */ smbus_eeprom_init_one (i2c,0x50 , spd_data);/* RTC */ -i2c_slave_create_simple (i2c,"m41t80" ,0x68 ); +i2c_slave_create_simple_orphan (i2c,"m41t80" ,0x68 ); dev =sysbus_create_simple_orphan (TYPE_PPC4xx_I2C,0x4ef600800 ,qdev_get_gpio_in (uic[0 ],3 ));
hw/riscv/tt_atlantis.c +2 -2
@@ -574,8 +574,8 @@ static void tt_atlantis_machine_init(MachineState *machine) }/* I2C peripherals: qemu specific */ -i2c_slave_create_simple (i2c_get_bus (s,0 ),"ds1338" ,0x6f ); -i2c_slave_create_simple (i2c_get_bus (s,4 ),"tmp105" ,0x48 ); +i2c_slave_create_simple_orphan (i2c_get_bus (s,0 ),"ds1338" ,0x6f ); +i2c_slave_create_simple_orphan (i2c_get_bus (s,4 ),"tmp105" ,0x48 );/* Load or create device tree */ if (machine->dtb) {
include/hw/arm/aspeed.h +2 -2
@@ -83,7 +83,7 @@ void aspeed_machine_class_init_cpus_defaults(MachineClass *mc);* * Create and attach a PCA9552 LED controller device to the specified I2C bus * of the given Aspeed SoC. The device is instantiated using -* i2c_slave_create_simple() with the PCA9552 device type. +* i2c_slave_create_simple_orphan() with the PCA9552 device type. */ void aspeed_create_pca9552 (AspeedSoCState *soc,int bus_id,int addr);
@@ -95,7 +95,7 @@ void aspeed_create_pca9552(AspeedSoCState *soc, int bus_id, int addr);* * Create and attach a PCA9554 I/O expander to the specified I2C bus * of the given Aspeed SoC. The device is created via -* i2c_slave_create_simple() and returned as an #I2CSlave pointer. +* i2c_slave_create_simple_orphan() and returned as an #I2CSlave pointer. * * Returns: a pointer to the newly created #I2CSlave instance. */
include/hw/i2c/i2c.h +34 -4
@@ -163,7 +163,20 @@ bool i2c_scan_bus(I2CBus *bus, uint8_t address, bool broadcast,* properties to be set. Type @name must exist. The device still * needs to be realized. See qdev-core.h. */ -I2CSlave *i2c_slave_new (const char *name,uint8_t addr); +I2CSlave *i2c_slave_new_orphan (const char *name,uint8_t addr); + +/** +* Create a parented I2C slave device on the heap. +* @parent: the QOM parent +* @id: child<> property name +* @type: I2C slave device type name +* @addr: I2C address of the slave when put on a bus +* +* Like i2c_slave_new_orphan(), but the returned device is owned by +* @parent's child<> property. Pair with qdev_realize(). +*/ +I2CSlave *i2c_slave_new (Object *parent,const char *id, +const char *type,uint8_t addr);/** * Create and realize an I2C slave device on the heap.
@@ -174,7 +187,24 @@ I2CSlave *i2c_slave_new(const char *name, uint8_t addr);* Create the device state structure, initialize it, put it on the * specified @bus, and drop the reference to it (the device is realized). */ -I2CSlave *i2c_slave_create_simple (I2CBus *bus,const char *name,uint8_t addr); +I2CSlave *i2c_slave_create_simple_orphan (I2CBus *bus,const char *name, +uint8_t addr); + +/** +* Create, parent and realize an I2C slave device on the heap. +* @parent: the QOM parent +* @id: child<> property name +* @bus: I2C bus to put it on +* @type: I2C slave device type name +* @addr: I2C address of the slave when put on a bus +* +* Create the device state structure, add it as a child of @parent, +* put it on the specified @bus and realize it. The returned device +* is owned by @parent. +*/ +I2CSlave *i2c_slave_create_simple (Object *parent,const char *id, +I2CBus *bus,const char *type, +uint8_t addr);/** * Realize and drop a reference an I2C slave device
@@ -189,10 +219,10 @@ I2CSlave *i2c_slave_create_simple(I2CBus *bus, const char *name, uint8_t addr);* reference to it. * * This function is useful if you have created @dev via qdev_new_orphan(), -* i2c_slave_new() or i2c_slave_try_new() (which take a reference to +* i2c_slave_new_orphan() or i2c_slave_try_new() (which take a reference to * the device it returns to you), so that you can set properties on it * before realizing it. If you don't need to set properties then -* i2c_slave_create_simple() is probably better (as it does the create, +* i2c_slave_create_simple_orphan() is probably better (as it does the create, * init and realize in one step). * * If you are embedding the I2C slave into another QOM device and
scripts/coccinelle/qom-parent/i2c-slave-new-orphan.cocci new file +18 -0
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// +// Rename i2c_slave_new()/i2c_slave_create_simple() to *_orphan() +// so that the short names can be reintroduced with a mandatory +// (parent, id, ...) signature. +// +// spatch --sp-file scripts/coccinelle/qom-parent/i2c-slave-new-orphan.cocci \ +// --in-place --include-headers --dir . + +@@ +@@ +- i2c_slave_new ++ i2c_slave_new_orphan + +@@ +@@ +- i2c_slave_create_simple ++ i2c_slave_create_simple_orphan
Signature · 1 line
2.47.1
RFC PATCH v2 8/137 ssi, usb: Make bus-layer creators take a QOM parent
In reply to Alexander GrafApply the rename-and-reintroduce treatment to the remaining bus-layer helpers that wrap qdev_new_orphan():
ssi_create_peripheral() -> ssi_create_peripheral_orphan()
usb_create_simple() -> usb_create_simple_orphan()
and reintroduce the short names with a leading (parent, id, ...) pair. Also add a usb_new(parent, id, type) helper for callers that need to set properties before realize.
sd-bus, apple-desktop-bus, HDA, aux-bus and spapr-vio have no bus- layer creation wrapper: their onboard devices are open-coded via qdev_new_orphan() at each call site and will be converted directly to qdev_new(parent, id, type) in the per-subdirectory conversion patches.
The mechanical rename part is generated by
spatch --sp-file scripts/coccinelle/qom-parent/ssi-usb-orphan.cocci \
--in-place --include-headers --dir .
or equivalently
git ls-files '*.[ch]' '*.[ch].inc' '*.rst' '*.py' | \
grep -v '^subprojects/' | \
xargs sed -i \
's/\bssi_create_peripheral\b/&_orphan/g;
s/\busb_create_simple\b/&_orphan/g'AI-used-for: code (refactoring)
--- hw/arm/stellaris.c | 2 +- hw/hppa/machine.c | 4 ++-- hw/mips/loongson3_virt.c | 4 ++-- hw/ppc/mac_newworld.c | 4 ++-- hw/ppc/sam460ex.c | 4 ++-- hw/ppc/spapr.c | 4 ++-- hw/riscv/sifive_u.c | 2 +- hw/sh4/r2d.c | 2 +- hw/ssi/ssi.c | 11 ++++++++++- hw/vmapple/vmapple.c | 4 ++-- include/hw/ssi/ssi.h | 6 ++++-- include/hw/usb/usb.h | 18 +++++++++++++++++- .../coccinelle/qom-parent/ssi-usb-orphan.cocci | 18 ++++++++++++++++++ 13 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 scripts/coccinelle/qom-parent/ssi-usb-orphan.cocci
hw/arm/stellaris.c +1 -1
@@ -1300,7 +1300,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)* - Make the ssd0323 OLED controller chipselect active-low */ bus =qdev_get_child_bus (dev,"ssi" ); - sddev =ssi_create_peripheral (bus,"ssi-sd" ); + sddev =ssi_create_peripheral_orphan (bus,"ssi-sd" ); dinfo =drive_get (IF_SD ,0 ,0 ); blk = dinfo ?blk_by_legacy_dinfo (dinfo) :NULL ;
hw/hppa/machine.c +2 -2
@@ -446,8 +446,8 @@ static void machine_HP_common_init_tail(MachineState *machine, PCIBus *pci_bus,pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort)); -usb_create_simple (usb_bus,"usb-kbd" ); -usb_create_simple (usb_bus,"usb-mouse" ); +usb_create_simple_orphan (usb_bus,"usb-kbd" ); +usb_create_simple_orphan (usb_bus,"usb-mouse" ); }/* register power switch emulation */
hw/mips/loongson3_virt.c +2 -2
@@ -468,8 +468,8 @@ static inline void loongson3_virt_devices_init(MachineState *machine,pci_create_simple_orphan (pci_bus,-1 ,"pci-ohci" ); usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort)); -usb_create_simple (usb_bus,"usb-kbd" ); -usb_create_simple (usb_bus,"usb-tablet" ); +usb_create_simple_orphan (usb_bus,"usb-kbd" ); +usb_create_simple_orphan (usb_bus,"usb-tablet" ); }pci_init_nic_devices (pci_bus, mc->default_nic);
hw/ppc/mac_newworld.c +2 -2
@@ -425,8 +425,8 @@ static void ppc_core99_init(MachineState *machine) usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort)); -usb_create_simple (usb_bus,"usb-kbd" ); -usb_create_simple (usb_bus,"usb-mouse" ); +usb_create_simple_orphan (usb_bus,"usb-kbd" ); +usb_create_simple_orphan (usb_bus,"usb-mouse" ); } }
hw/ppc/sam460ex.c +2 -2
@@ -398,8 +398,8 @@ static void sam460ex_init(MachineState *machine)sysbus_connect_irq (sbdev,0 ,qdev_get_gpio_in (uic[2 ],30 )); usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort)); -usb_create_simple (usb_bus,"usb-kbd" ); -usb_create_simple (usb_bus,"usb-mouse" ); +usb_create_simple_orphan (usb_bus,"usb-kbd" ); +usb_create_simple_orphan (usb_bus,"usb-mouse" );/* PCIe buses */ dev =qdev_new_orphan (TYPE_PPC460EX_PCIE_HOST );
hw/ppc/spapr.c +2 -2
@@ -3082,8 +3082,8 @@ static void spapr_machine_init(MachineState *machine) usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort)); -usb_create_simple (usb_bus,"usb-kbd" ); -usb_create_simple (usb_bus,"usb-mouse" ); +usb_create_simple_orphan (usb_bus,"usb-kbd" ); +usb_create_simple_orphan (usb_bus,"usb-mouse" ); } }
hw/riscv/sifive_u.c +1 -1
@@ -606,7 +606,7 @@ static void sifive_u_machine_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (&s->soc.spi0),1 , flash_cs);/* Connect an SD card to SPI2 */ - sd_dev =ssi_create_peripheral (s->soc.spi2.spi,"ssi-sd" ); + sd_dev =ssi_create_peripheral_orphan (s->soc.spi2.spi,"ssi-sd" ); sd_cs =qdev_get_gpio_in_named (sd_dev,SSI_GPIO_CS ,0 );sysbus_connect_irq (SYS_BUS_DEVICE (&s->soc.spi2),1 , sd_cs);
hw/sh4/r2d.c +1 -1
@@ -320,7 +320,7 @@ static void r2d_init(MachineState *machine)/* USB keyboard */ usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_abort)); -usb_create_simple (usb_bus,"usb-kbd" ); +usb_create_simple_orphan (usb_bus,"usb-kbd" );/* Todo: register on board registers */ memset (&boot_params,0 ,sizeof (boot_params));
hw/ssi/ssi.c +10 -1
@@ -138,7 +138,16 @@ bool ssi_realize_and_unref(DeviceState *dev, SSIBus *bus, Error **errp)return qdev_realize_and_unref (dev, &bus->parent_obj, errp); } -DeviceState *ssi_create_peripheral (SSIBus *bus,const char *name) +DeviceState *ssi_create_peripheral (Object *parent,const char *id, +SSIBus *bus,const char *type) +{ +DeviceState *dev =qdev_new (parent, id, type); + +qdev_realize (dev,BUS (bus), &error_fatal); +return dev; +} + +DeviceState *ssi_create_peripheral_orphan (SSIBus *bus,const char *name) {DeviceState *dev =qdev_new_orphan (name);
hw/vmapple/vmapple.c +2 -2
@@ -425,8 +425,8 @@ static void create_pcie(VMAppleMachineState *vms) usb_bus =USB_BUS (object_resolve_type_unambiguous (TYPE_USB_BUS , &error_fatal)); -usb_create_simple (usb_bus,"usb-kbd" ); -usb_create_simple (usb_bus,"usb-tablet" ); +usb_create_simple_orphan (usb_bus,"usb-kbd" ); +usb_create_simple_orphan (usb_bus,"usb-tablet" ); } }
include/hw/ssi/ssi.h +4 -2
@@ -81,7 +81,9 @@ extern const VMStateDescription vmstate_ssi_peripheral; .offset = vmstate_offset_value(_state, _field, SSIPeripheral), \ } -DeviceState *ssi_create_peripheral (SSIBus *bus,const char *name); +DeviceState *ssi_create_peripheral (Object *parent,const char *id, +SSIBus *bus,const char *type); +DeviceState *ssi_create_peripheral_orphan (SSIBus *bus,const char *name);/** * ssi_realize_and_unref: realize and unref an SSI peripheral * @dev: SSI peripheral to realize
@@ -95,7 +97,7 @@ DeviceState *ssi_create_peripheral(SSIBus *bus, const char *name);* This function is useful if you have created @dev via qdev_new_orphan() * (which takes a reference to the device it returns to you), so that * you can set properties on it before realizing it. If you don't need -* to set properties then ssi_create_peripheral() is probably better (as it +* to set properties then ssi_create_peripheral_orphan() is probably better (as it * does the create, init and realize in one step). * * If you are embedding the SSI peripheral into another QOM device and
include/hw/usb/usb.h +17 -1
@@ -584,7 +584,23 @@ static inline bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **erreturn qdev_realize_and_unref (&dev->qdev, &bus->qbus, errp); } -static inline USBDevice *usb_create_simple (USBBus *bus,const char *name) +static inline USBDevice *usb_new (Object *parent,const char *id, +const char *type) +{ +return USB_DEVICE (qdev_new (parent, id, type)); +} + +static inline USBDevice *usb_create_simple (Object *parent,const char *id, +USBBus *bus,const char *type) +{ +USBDevice *dev =usb_new (parent, id, type); + +qdev_realize (DEVICE (dev),BUS (bus), &error_abort); +return dev; +} + +static inline USBDevice *usb_create_simple_orphan (USBBus *bus, +const char *name) {USBDevice *dev =USB_DEVICE (qdev_new_orphan (name));
scripts/coccinelle/qom-parent/ssi-usb-orphan.cocci new file +18 -0
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// +// Rename ssi_create_peripheral()/usb_create_simple() to *_orphan() +// so that the short names can be reintroduced with a mandatory +// (parent, id, ...) signature. +// +// spatch --sp-file scripts/coccinelle/qom-parent/ssi-usb-orphan.cocci \ +// --in-place --include-headers --dir . + +@@ +@@ +- ssi_create_peripheral ++ ssi_create_peripheral_orphan + +@@ +@@ +- usb_create_simple ++ usb_create_simple_orphan
Signature · 1 line
2.47.1