All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Subject: Re: [PATCH] hw/pci: Avoid adding PCI devices to the "unattached" QOM tree node
Date: Thu, 19 Feb 2026 16:18:22 +0100	[thread overview]
Message-ID: <20260219161822.55e83382@imammedo> (raw)
In-Reply-To: <20260219160641.6f63c27d@imammedo>

On Thu, 19 Feb 2026 16:06:41 +0100
Igor Mammedov <imammedo@redhat.com> wrote:

> On Tue, 17 Feb 2026 07:55:12 +0100
> Thomas Huth <thuth@redhat.com> wrote:
> 
> > 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);  
> there are a few more places that have similar pattern, should we fix them to?
> 
> >      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);  
> this one also takes bus as an argument, and then goes down to
>  qdev_realize_and_unref->qdev_realize->qdev_set_parent_bus->bus_add_child
> that eventually creates a link to device.
> 
> wouldn't pci_dev_property_add_child() create a duplicate entry
> as a child with different name component there?
> 
> another question, should we 'fix' qdev_set_parent_bus->bus_add_child
> to add a child instead of a link? That would do what patch intends
> but consistently for all devices with parent bus.

and then this rises a question if the bus should be a parent or
the owner of the bus is the parent?

> 
> 
> >      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;
> >  }  
> 



  reply	other threads:[~2026-02-19 15:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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=20260219161822.55e83382@imammedo \
    --to=imammedo@redhat.com \
    --cc=armbru@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /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.