All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw/pci: Avoid adding PCI devices to the "unattached" QOM tree node
@ 2026-02-17  6:55 Thomas Huth
  2026-02-19 15:06 ` Igor Mammedov
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Huth @ 2026-02-17  6:55 UTC (permalink / raw)
  To: Michael S. Tsirkin, qemu-devel, Markus Armbruster; +Cc: Marcel Apfelbaum

From: Thomas Huth <thuth@redhat.com>

PCI devices that are added via pci_create_simple_multifunction(),
pci_create_simple() or pci_init_nic_in_slot() currently show up
under "/machine/unattached" in the QOM tree. This is somewhat ugly,
the parent should rather be the PCI bus node instead, so let's add
the proper relation here.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/pci/pci.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 90d6d71efdc..2f4d2be50fd 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2071,6 +2071,15 @@ const pci_class_desc *get_class_desc(int class)
     return desc;
 }
 
+static void pci_dev_property_add_child(PCIBus *bus, const char *name,
+                                       PCIDevice *dev)
+{
+    g_autofree char *childname = g_strdup_printf("%s[%d.%d]", name,
+                                                 PCI_SLOT(dev->devfn),
+                                                 PCI_FUNC(dev->devfn));
+    object_property_add_child(OBJECT(bus), childname, OBJECT(dev));
+}
+
 void pci_init_nic_devices(PCIBus *bus, const char *default_model)
 {
     qemu_create_nic_bus_devices(&bus->qbus, TYPE_PCI_DEVICE, default_model,
@@ -2114,6 +2123,7 @@ bool pci_init_nic_in_slot(PCIBus *rootbus, const char *model,
 
     pci_dev = pci_new(devfn, model);
     qdev_set_nic_properties(&pci_dev->qdev, nd);
+    pci_dev_property_add_child(bus, model, pci_dev);
     pci_realize_and_unref(pci_dev, bus, &error_fatal);
     return true;
 }
@@ -2412,6 +2422,8 @@ PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn,
                                            const char *name)
 {
     PCIDevice *dev = pci_new_multifunction(devfn, name);
+
+    pci_dev_property_add_child(bus, name, dev);
     pci_realize_and_unref(dev, bus, &error_fatal);
     return dev;
 }
@@ -2419,6 +2431,8 @@ PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn,
 PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)
 {
     PCIDevice *dev = pci_new(devfn, name);
+
+    pci_dev_property_add_child(bus, name, dev);
     pci_realize_and_unref(dev, bus, &error_fatal);
     return dev;
 }
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-02-27  7:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-17  6:55 [PATCH] hw/pci: Avoid adding PCI devices to the "unattached" QOM tree node Thomas Huth
2026-02-19 15:06 ` Igor Mammedov
2026-02-19 15:18   ` Igor Mammedov
2026-02-23 17:43     ` Thomas Huth
2026-02-27  7:59     ` Markus Armbruster

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.