On 12/7/26 00:34, Alexander Graf wrote:
qdev_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. Assisted-by: Kiro Signed-off-by: Alexander Graf <[email protected]> --- 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
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
