[RFC PATCH v2 025/137] hw/remote: Give onboard devices a QOM parent

Alexander Graf <[email protected]>
Newsgroups org.nongnu.qemu-arm,org.nongnu.qemu-devel,org.nongnu.qemu-riscv
Message-ID <[email protected]>
Convert the *_orphan() device-creation calls in hw/remote 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/remote/machine.c:42 | qdev_new | OBJECT(s) | "remote-pcihost" | Board init; collapses existing object_property_add_child() with same name

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

diff --git a/hw/remote/machine.c b/hw/remote/machine.c
index 28cb48a4f6..e8e9cf259f 100644
--- a/hw/remote/machine.c
+++ b/hw/remote/machine.c
@@ -39,7 +39,8 @@ 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_orphan(TYPE_REMOTE_PCIHOST));
+    rem_host = REMOTE_PCIHOST(qdev_new(OBJECT(s), "remote-pcihost",
+                                       TYPE_REMOTE_PCIHOST));
 
     rem_host->mr_pci_mem = pci_memory;
     rem_host->mr_sys_mem = system_memory;
@@ -47,7 +48,6 @@ static void remote_machine_init(MachineState *machine)
 
     s->host = rem_host;
 
-    object_property_add_child(OBJECT(s), "remote-pcihost", OBJECT(rem_host));
     memory_region_add_subregion_overlap(system_memory, 0x0, pci_memory, -1);
 
     qdev_realize(DEVICE(rem_host), sysbus_get_default(), &error_fatal);
-- 
2.47.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.