All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <graf@amazon.com>
To: <qemu-devel@nongnu.org>
Cc: qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org,
	qemu-s390x@nongnu.org, "Song Gao" <17746591750@163.com>,
	"Aditya Gupta" <adityag@linux.ibm.com>,
	"Alexey Kardashevskiy" <aik@ozlabs.ru>,
	"Farhan Ali" <alifm@linux.ibm.com>,
	"Alistair Francis" <alistair.francis@wdc.com>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Antony Pavlov" <antonynpavlov@gmail.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>,
	"BALATON Zoltan" <balaton@eik.bme.hu>,
	"Felipe Balbi" <balbi@kernel.org>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Brian Cain" <brian.cain@oss.qualcomm.com>,
	"Hendrik Brueckner" <brueckner@linux.ibm.com>,
	"Chao Liu" <chao.liu@processmission.com>,
	"Huacai Chen" <chenhuacai@kernel.org>,
	"Clément Chigot" <chigot@adacore.com>,
	"Cédric Le Goater" <clg@kaod.org>, "Helge Deller" <deller@gmx.de>,
	"Dorjoy Chowdhury" <dorjoychy111@gmail.com>,
	"Edgar E . Iglesias" <edgar.iglesias@gmail.com>,
	"Alexandre Iooss" <erdnaxe@crans.org>,
	"Eric Farman" <farman@linux.ibm.com>,
	"Francisco Iglesias" <francisco.iglesias@amd.com>,
	"Gaurav Sharma" <gaurav.sharma_7@nxp.com>,
	"Gautam Gala" <ggala@linux.ibm.com>,
	"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Jan Kiszka" <jan.kiszka@web.de>,
	"Max Filippov" <jcmvbkbc@gmail.com>,
	"Joel Stanley" <joel@jms.id.au>,
	"Jared Rossi" <jrossi@linux.ibm.com>,
	"Tyrone Ting" <kfting@nuvoton.com>,
	"Frederic Konrad" <konrad.frederic@yahoo.fr>,
	"Laurent Vivier" <laurent@vivier.eu>,
	"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
	"Bibo Mao" <maobibo@loongson.cn>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Glenn Miles" <milesg@linux.ibm.com>,
	"Matthew Rosato" <mjrosato@linux.ibm.com>,
	"Michael Rolnik" <mrolnik@gmail.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	"Niek Linnenbank" <nieklinnenbank@gmail.com>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@mailo.com>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Sai Pavan Boddu" <sai.pavan.boddu@amd.com>,
	"Samuel Tardieu" <sam@rfc1149.net>,
	"Bernhard Beschow" <shentey@gmail.com>,
	"Stafford Horne" <shorne@gmail.com>,
	"Sergio Lopez" <slp@redhat.com>,
	"Subbaraya Sundeep" <sundeep.lkml@gmail.com>,
	"Thomas Huth" <th.huth+qemu@posteo.eu>,
	"Ran Wang" <wangran@bosc.ac.cn>, "Hao Wu" <wuhaotsh@google.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>
Subject: [RFC PATCH 004/134] sysbus: Make sysbus_create_simple()/_varargs() take a QOM parent
Date: Sat, 11 Jul 2026 22:34:57 +0000	[thread overview]
Message-ID: <20260711223707.42139-5-graf@amazon.com> (raw)
In-Reply-To: <20260711223707.42139-1-graf@amazon.com>

Sysbus 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'

Assisted-by: Kiro
Signed-off-by: Alexander Graf <graf@amazon.com>
---
 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                      | 32 ++++++++++++++---
 .../qom-parent/sysbus-create-orphan.cocci     | 18 ++++++++++
 42 files changed, 206 insertions(+), 131 deletions(-)
 create mode 100644 scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci

diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
index 262e99b3f9..427dbad7c3 100644
--- a/hw/arm/allwinner-h3.c
+++ b/hw/arm/allwinner-h3.c
@@ -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));
 
diff --git a/hw/arm/collie.c b/hw/arm/collie.c
index 91f0a94b6f..81bc019460 100644
--- a/hw/arm/collie.c
+++ b/hw/arm/collie.c
@@ -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);
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 2b6e61abd0..3199ea9cb7 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -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 ***/
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index eec9673c6f..103adcc2bd 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -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;
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index 8a56165cc2..3df488921a 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -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,
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
index 96af49e213..5a0384a412 100644
--- a/hw/arm/mps2.c
+++ b/hw/arm/mps2.c
@@ -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
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 6dd18a67b2..3bcdea7db8 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -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,
diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
index c27f149c04..87734c1cfb 100644
--- a/hw/arm/npcm7xx.c
+++ b/hw/arm/npcm7xx.c
@@ -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",
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index 0fce9b624f..287c092c2d 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -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);
 
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
index 47a1a82a39..a821833fa7 100644
--- a/hw/arm/sbsa-ref.c
+++ b/hw/arm/sbsa-ref.c
@@ -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 */
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index 1f816a3965..3f72cedf2e 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -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;
diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c
index 0c6b04f805..f67aaa23ed 100644
--- a/hw/arm/strongarm.c
+++ b/hw/arm/strongarm.c
@@ -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");
 
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index 5e9d76859f..b80410db0d 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -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);
 
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index 716f55a086..5a0012cb4f 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -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]);
     }
 
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 3f62c8fc2d..686dde5996 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -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));
     }
 
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
index 8c3b47d07a..7f31cd6088 100644
--- a/hw/arm/xilinx_zynq.c
+++ b/hw/arm/xilinx_zynq.c
@@ -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);
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index fe8baf73b5..bbacb07e1a 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -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;
diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
index e3dad136d3..de0df2c82a 100644
--- a/hw/i386/kvm/clock.c
+++ b/hw/i386/kvm/clock.c
@@ -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);
     }
 }
 
diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c
index 8b243984e4..1a406fbc00 100644
--- a/hw/i386/kvm/xen_evtchn.c
+++ b/hw/i386/kvm/xen_evtchn.c
@@ -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;
 
diff --git a/hw/i386/kvm/xen_gnttab.c b/hw/i386/kvm/xen_gnttab.c
index 85b324e62d..eb43e9f385 100644
--- a/hw/i386/kvm/xen_gnttab.c
+++ b/hw/i386/kvm/xen_gnttab.c
@@ -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));
 }
 
diff --git a/hw/i386/kvm/xen_overlay.c b/hw/i386/kvm/xen_overlay.c
index 74cadffb72..1ef47539e4 100644
--- a/hw/i386/kvm/xen_overlay.c
+++ b/hw/i386/kvm/xen_overlay.c
@@ -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. */
diff --git a/hw/i386/kvm/xen_primary_console.c b/hw/i386/kvm/xen_primary_console.c
index bf61f6235b..f22ce4b14b 100644
--- a/hw/i386/kvm/xen_primary_console.c
+++ b/hw/i386/kvm/xen_primary_console.c
@@ -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();
 
diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c
index 0dc0edf3bf..92493bcb6d 100644
--- a/hw/i386/kvm/xen_xenstore.c
+++ b/hw/i386/kvm/xen_xenstore.c
@@ -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);
 
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 08d54c277f..22688687c4 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -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]);
     }
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index 49c03a5bce..aaa7dca480 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -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) {
diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index 23751c46d7..45acdc3ec1 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -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));
 
diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
index 5bb123594d..0c1f5b4481 100644
--- a/hw/m68k/next-cube.c
+++ b/hw/m68k/next-cube.c
@@ -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);
diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c
index f86d55d96c..e2af0196e8 100644
--- a/hw/m68k/virt.c
+++ b/hw/m68k/virt.c
@@ -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 */
diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c
index f9be67249f..a902e400cf 100644
--- a/hw/mips/jazz.c
+++ b/hw/mips/jazz.c
@@ -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);
 }
diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
index d3b728339e..854f7f6801 100644
--- a/hw/mips/loongson3_virt.c
+++ b/hw/mips/loongson3_virt.c
@@ -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");
diff --git a/hw/or1k/virt.c b/hw/or1k/virt.c
index 3067a5b2e7..9451a0b7df 100644
--- a/hw/or1k/virt.c
+++ b/hw/or1k/virt.c
@@ -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);
diff --git a/hw/ppc/amigaone.c b/hw/ppc/amigaone.c
index bcdf36b344..528c2c656a 100644
--- a/hw/ppc/amigaone.c
+++ b/hw/ppc/amigaone.c
@@ -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) {
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 65e71826a4..05c305b72c 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -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;
diff --git a/hw/ppc/pegasos.c b/hw/ppc/pegasos.c
index 9d7e279123..3dc02423ee 100644
--- a/hw/ppc/pegasos.c
+++ b/hw/ppc/pegasos.c
@@ -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;
diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
index e76d359e43..7a6c3ebec5 100644
--- a/hw/ppc/ppc440_bamboo.c
+++ b/hw/ppc/ppc440_bamboo.c
@@ -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]),
diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
index 778b04c532..88c4e66b2d 100644
--- a/hw/ppc/sam460ex.c
+++ b/hw/ppc/sam460ex.c
@@ -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"));
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 449cb52201..44e1cfa7be 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -1474,7 +1474,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));
     }
@@ -1487,7 +1487,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++) {
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 69a287937e..80e37555b1 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -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]);
     }
 
diff --git a/hw/vmapple/vmapple.c b/hw/vmapple/vmapple.c
index 9f69ab2bc7..bf19faa04a 100644
--- a/hw/vmapple/vmapple.c
+++ b/hw/vmapple/vmapple.c
@@ -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));
 }
 
diff --git a/hw/xen/xen-pvh-common.c b/hw/xen/xen-pvh-common.c
index 4c9a4fdea8..17f545d07c 100644
--- a/hw/xen/xen-pvh-common.c
+++ b/hw/xen/xen-pvh-common.c
@@ -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,
diff --git a/include/hw/core/sysbus.h b/include/hw/core/sysbus.h
index f3c4259d29..7737c959c5 100644
--- a/include/hw/core/sysbus.h
+++ b/include/hw/core/sysbus.h
@@ -91,15 +91,39 @@ 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.
+ */
+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 */
diff --git a/scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci b/scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci
new file mode 100644
index 0000000000..b925d9396f
--- /dev/null
+++ b/scripts/coccinelle/qom-parent/sysbus-create-orphan.cocci
@@ -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
-- 
2.47.1



  parent reply	other threads:[~2026-07-11 22:38 UTC|newest]

Thread overview: 156+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-11 22:34 [RFC PATCH 000/134] qom: Make composition-tree parenting mandatory Alexander Graf
2026-07-11 22:34 ` [RFC PATCH 001/134] qom: Introduce object_new_child() Alexander Graf
2026-07-13  8:47   ` Daniel P. Berrangé
2026-07-13  9:01     ` Graf (AWS), Alexander
2026-07-13 16:49   ` Richard Henderson
2026-07-13 18:15     ` Peter Maydell
2026-07-13 18:47       ` Daniel P. Berrangé
2026-07-13 19:07         ` Peter Maydell
2026-07-11 22:34 ` [RFC PATCH 002/134] qdev: Rename qdev_new()/qdev_try_new() to *_orphan() Alexander Graf
2026-07-13  8:22   ` Philippe Mathieu-Daudé
2026-07-11 22:34 ` [RFC PATCH 003/134] qdev: Reintroduce qdev_new() with a mandatory QOM parent Alexander Graf
2026-07-13 10:55   ` Philippe Mathieu-Daudé
2026-07-11 22:34 ` Alexander Graf [this message]
2026-07-13 10:54   ` [RFC PATCH 004/134] sysbus: Make sysbus_create_simple()/_varargs() take a " Philippe Mathieu-Daudé
2026-07-11 22:34 ` [RFC PATCH 005/134] pci: Make pci_new*()/pci_create_simple*() " Alexander Graf
2026-07-11 22:34 ` [RFC PATCH 006/134] isa: Make isa_new()/isa_try_new()/isa_create_simple() " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 007/134] i2c: Make i2c_slave_new()/i2c_slave_create_simple() " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 008/134] ssi, usb: Make bus-layer creators " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 009/134] cpu: Make cpu_create() " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 010/134] hw/avr: Give onboard devices " Alexander Graf
2026-07-13  8:25   ` Philippe Mathieu-Daudé
2026-07-11 22:35 ` [RFC PATCH 011/134] hw/tricore: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 012/134] hw/xtensa: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 013/134] hw/alpha: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 014/134] hw/nitro: " Alexander Graf
2026-07-13  8:29   ` Philippe Mathieu-Daudé
2026-07-11 22:35 ` [RFC PATCH 015/134] hw/vmapple: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 016/134] hw/hppa: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 017/134] hw/microblaze: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 018/134] hw/sh4: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 019/134] hw/s390x: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 020/134] hw/or1k: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 021/134] hw/loongarch: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 022/134] hw/intc: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 023/134] hw/pci-host: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 024/134] hw/core: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 025/134] hw/remote: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 026/134] hw/ufs: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 027/134] hw/nvme: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 028/134] hw/vfio: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 029/134] hw/mem: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 030/134] hw/cxl: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 031/134] hw/hexagon: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 032/134] hw/xen: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 033/134] hw/display: " Alexander Graf
2026-07-13  8:32   ` Philippe Mathieu-Daudé
2026-07-11 22:35 ` [RFC PATCH 034/134] hw/nvram: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 035/134] hw/dma: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 036/134] hw/misc: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 037/134] hw/scsi: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 038/134] hw/net: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 039/134] hw/ide: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 040/134] hw/i3c: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 041/134] hw/pci-bridge: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 042/134] hw/sparc64: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 043/134] hw/sparc: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 044/134] hw/m68k: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 045/134] hw/rtc: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 046/134] hw/i2c: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 047/134] hw/block: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 048/134] hw/char: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 049/134] hw/isa: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 050/134] hw/pci: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 051/134] hw/riscv: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 052/134] hw/mips: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 053/134] hw/i386: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 054/134] hw/ppc: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 055/134] hw/pci, hw/isa: Give VGA and slot-NIC helpers " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 056/134] hw/arm/virt: Give onboard devices " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 057/134] hw/arm/sbsa-ref: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 058/134] hw/arm/xilinx-zynq: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 059/134] hw/arm/xlnx-versal, xlnx-zynqmp: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 060/134] hw/arm/realview, integratorcp: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 061/134] hw/arm/npcm: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 062/134] hw/arm/versatile, vexpress: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 063/134] hw/arm/stellaris, musicpal: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 064/134] hw/arm/exynos: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 065/134] hw/arm/allwinner: " Alexander Graf
2026-07-11 22:35 ` [RFC PATCH 066/134] hw/arm/strongarm: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 067/134] hw/arm/omap: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 068/134] hw/arm/mps2: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 069/134] hw/arm/imx: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 070/134] hw/arm/misc: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 071/134] hw/arm/aspeed: Give onboard devices a QOM parent (part 1) Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 072/134] hw/arm/aspeed: Give onboard devices a QOM parent (part 2) Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 073/134] hw/nvram/at24c: Give at24c_eeprom_init() a QOM parent Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 074/134] hw/i386/pc: Give pcspk " Alexander Graf
2026-07-13  8:34   ` Philippe Mathieu-Daudé
2026-07-11 22:36 ` [RFC PATCH 075/134] hw/timer, hw/net: Give i8254 and isa-ne2000 helpers " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 076/134] hw/misc/unimp: Give create_unimplemented_device() " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 077/134] hw/usb: Give -usbdevice and auto-hub devices " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 078/134] hw/audio: Give -audio model= " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 079/134] hw/xen: Give xenstore-driven backend " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 080/134] hw/nitro: Give the vsock bridge " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 081/134] hw/isa: Give the isabus-bridge " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 082/134] net, target/mips: Give -nic and CPU-with-clock helpers " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 083/134] usb, ssi, i2c: Remove *_orphan() creator variants Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 084/134] isa: " Alexander Graf
2026-07-13  8:35   ` Philippe Mathieu-Daudé
2026-07-11 22:36 ` [RFC PATCH 085/134] pci: " Alexander Graf
2026-07-13  8:36   ` Philippe Mathieu-Daudé
2026-07-11 22:36 ` [RFC PATCH 086/134] cpu: Remove cpu_create_orphan() Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 087/134] sysbus: Remove *_orphan() creator variants Alexander Graf
2026-07-13  8:36   ` Philippe Mathieu-Daudé
2026-07-11 22:36 ` [RFC PATCH 088/134] qdev: Remove qdev_new_orphan() and qdev_try_new_orphan() Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 089/134] memory: Accept non-device owners in memory_region_init_ram() Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 090/134] hw/misc-boards: Give memory regions an explicit owner Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 091/134] hw/mips: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 092/134] hw/riscv: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 093/134] hw/i386: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 094/134] hw/arm: " Alexander Graf
2026-07-12 15:12   ` Bernhard Beschow
2026-07-11 22:36 ` [RFC PATCH 095/134] hw/arm/omap1: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 096/134] hw/sh4: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 097/134] hw/m68k: " Alexander Graf
2026-07-12 14:20   ` Thomas Huth
2026-07-11 22:36 ` [RFC PATCH 098/134] hw/ppc: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 099/134] hw/tricore: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 100/134] hw/xtensa: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 101/134] hw/display: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 102/134] hw/arm/omap: Give lcdc and dma " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 103/134] hw/char: Give parallel and htif " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 104/134] hw/remote: Give " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 105/134] system, backends: Give named " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 106/134] hw/ide: Let ide_init_ioport() take " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 107/134] memory: Require an owner for named memory regions Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 108/134] irq: Rename qemu_allocate_irq*() and friends to *_orphan() Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 109/134] irq: Reintroduce qemu_allocate_irq*() with a mandatory owner and name Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 110/134] hw/pci, hw/usb, system: Give allocated IRQs an " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 111/134] hw/i386, hw/xen: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 112/134] hw/arm: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 113/134] hw/xtensa: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 114/134] hw: " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 115/134] hw/core: Parent GPIO input IRQs and embedded IRQState via QOM Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 116/134] irq: Delete the *_orphan() IRQ allocation variants Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 117/134] sysbus: Parent main-system-bus directly under /machine Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 118/134] accel: Parent the accelerator singleton " Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 119/134] hw/core/reset: Give the root reset container and legacy shims a QOM path Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 120/134] system: Parent per-MR helper objects under their owner Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 121/134] hw/virtio, hw/display: Parent per-device helper objects Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 122/134] hw/i386/amd_iommu: Parent internally-created AMDVI-PCI under the IOMMU Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 123/134] hw/s390x, hw/remote: Parent per-devfn IOMMU objects Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 124/134] hw/pci-host/raven: Parent the OR-IRQ under the host bridge Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 125/134] hw/arm/mps2: Parent the OR-IRQ gates under the machine Alexander Graf
2026-07-11 22:36 ` [RFC PATCH 126/134] hw/arm/digic: Parent the DIGIC SoC " Alexander Graf
2026-07-11 22:37 ` [RFC PATCH 127/134] hw/microblaze: Parent the CPU " Alexander Graf
2026-07-11 22:37 ` [RFC PATCH 128/134] hw: Pair object_initialize_child() with plain realize() Alexander Graf
2026-07-11 22:37 ` [RFC PATCH 129/134] hw: Parent board-created CPUs under the machine Alexander Graf
2026-07-13 16:35   ` Bernhard Beschow
2026-07-13 20:01   ` Brian Cain
2026-07-11 22:37 ` [RFC PATCH 130/134] hw/pci-host/versatile: Use object_initialize_child() for pci_dev Alexander Graf
2026-07-11 22:37 ` [RFC PATCH 131/134] docs, qapi, scripts, iotests: Update /machine/unattached path references Alexander Graf
2026-07-11 22:37 ` [RFC PATCH 132/134] qom: Delete /machine/unattached and error on unparented realize Alexander Graf
2026-07-11 22:37 ` [RFC PATCH 133/134] docs/devel/qom: Document the composition-tree parenting contract Alexander Graf
2026-07-11 22:37 ` [RFC PATCH 134/134] MAINTAINERS: Add scripts/coccinelle/qom-parent/ under QOM Alexander Graf
2026-07-12 10:56 ` [RFC PATCH 000/134] qom: Make composition-tree parenting mandatory Bernhard Beschow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260711223707.42139-5-graf@amazon.com \
    --to=graf@amazon.com \
    --cc=17746591750@163.com \
    --cc=adityag@linux.ibm.com \
    --cc=aik@ozlabs.ru \
    --cc=alifm@linux.ibm.com \
    --cc=alistair.francis@wdc.com \
    --cc=alistair@alistair23.me \
    --cc=antonynpavlov@gmail.com \
    --cc=armbru@redhat.com \
    --cc=atar4qemu@gmail.com \
    --cc=balaton@eik.bme.hu \
    --cc=balbi@kernel.org \
    --cc=berrange@redhat.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=brian.cain@oss.qualcomm.com \
    --cc=brueckner@linux.ibm.com \
    --cc=chao.liu@processmission.com \
    --cc=chenhuacai@kernel.org \
    --cc=chigot@adacore.com \
    --cc=clg@kaod.org \
    --cc=deller@gmx.de \
    --cc=dorjoychy111@gmail.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=erdnaxe@crans.org \
    --cc=farman@linux.ibm.com \
    --cc=francisco.iglesias@amd.com \
    --cc=gaurav.sharma_7@nxp.com \
    --cc=ggala@linux.ibm.com \
    --cc=harshpb@linux.ibm.com \
    --cc=hpoussin@reactos.org \
    --cc=jan.kiszka@web.de \
    --cc=jcmvbkbc@gmail.com \
    --cc=joel@jms.id.au \
    --cc=jrossi@linux.ibm.com \
    --cc=kfting@nuvoton.com \
    --cc=konrad.frederic@yahoo.fr \
    --cc=laurent@vivier.eu \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=maobibo@loongson.cn \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=milesg@linux.ibm.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=mrolnik@gmail.com \
    --cc=mst@redhat.com \
    --cc=nieklinnenbank@gmail.com \
    --cc=npiggin@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@mailo.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=sai.pavan.boddu@amd.com \
    --cc=sam@rfc1149.net \
    --cc=shentey@gmail.com \
    --cc=shorne@gmail.com \
    --cc=slp@redhat.com \
    --cc=sundeep.lkml@gmail.com \
    --cc=th.huth+qemu@posteo.eu \
    --cc=wangran@bosc.ac.cn \
    --cc=wuhaotsh@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.