Convert the *_orphan() device-creation calls in hw/vfio to the new
parented API introduced earlier in this series, so every onboard
device gets a stable path in the composition tree instead of landing
in /machine/unattached with an unstable device[N] name.

The parent for each device is the object that owns its lifetime: the
machine for board-created devices, the containing device for
composite children.  Names follow existing QOM conventions.

Per-site rationale (reviewers: dispute the modeling here):

hw/vfio/igd.c:337 | pci_create_simple | OBJECT(vdev) | "igd-lpc-bridge" | 
Called from IGD quirk during vfio-pci realize; the LPC stub is created by and 
lives with the passed-through IGD device

Link: https://lore.kernel.org/qemu-devel/[email protected]/
AI-used-for: code (refactoring)
Signed-off-by: Alexander Graf <[email protected]>
---
 hw/vfio/igd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c
index bea0d57a11..aee40646ed 100644
--- a/hw/vfio/igd.c
+++ b/hw/vfio/igd.c
@@ -334,8 +334,9 @@ 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_orphan(pci_device_root_bus(pdev),
-                                 PCI_DEVFN(0x1f, 0), 
"vfio-pci-igd-lpc-bridge");
+        lpc_bridge = pci_create_simple(OBJECT(vdev), "igd-lpc-bridge",
+                                       pci_device_root_bus(pdev),
+                                       PCI_DEVFN(0x1f, 0), 
"vfio-pci-igd-lpc-bridge");
     }
 
     ret = vfio_pci_igd_copy(vdev, lpc_bridge, info, igd_lpc_bridge_infos,
-- 
2.47.1


Reply via email to