From: Thomas Huth <thuth@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>,
qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Subject: [PATCH] hw/pci: Avoid adding PCI devices to the "unattached" QOM tree node
Date: Tue, 17 Feb 2026 07:55:12 +0100 [thread overview]
Message-ID: <20260217065512.245237-1-thuth@redhat.com> (raw)
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
next reply other threads:[~2026-02-17 6:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-17 6:55 Thomas Huth [this message]
2026-02-19 15:06 ` [PATCH] hw/pci: Avoid adding PCI devices to the "unattached" QOM tree node Igor Mammedov
2026-02-19 15:18 ` Igor Mammedov
2026-02-23 17:43 ` Thomas Huth
2026-02-27 7:59 ` Markus Armbruster
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=20260217065512.245237-1-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=armbru@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/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.