qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paul Brook <paul@codesourcery.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Name the default PCI bus "pci.0" on all architectures
Date: Wed, 2 Jun 2010 16:13:56 +0100	[thread overview]
Message-ID: <201006021613.56797.paul@codesourcery.com> (raw)
In-Reply-To: <m3wrunqohb.fsf@blackfin.pond.sub.org>

> Paul Brook <paul@codesourcery.com> writes:
> >> The system emulators for each arch are using inconsistent
> >> naming for the default PCI bus "pci" vs "pci.0". Since it
> >> is conceivable we'll have multiple PCI buses in the future
> >> standardize on "pci.0" for all architectures. This ensures
> >> mgmt apps can rely on a name when assigning PCI devices an
> >> address on the bus using eg '-device e1000,bus=pci.0,addr=3'
> > 
> > No. Bus names are local to the parent device.  None of the host bridges
> > support multiple bridges, so the ".0" suffix makes no sense.  The parent
> > device has no idea whether it owns the "default" pci bus or not.
> > If you have multiple PCI busses then you can identify them by the device
> > path.
> 
> From qbus_create_inplace():
> 
>     if (name) {
>         /* use supplied name */
>         bus->name = qemu_strdup(name);
>     } else if (parent && parent->id) {
>         /* parent device has id -> use it for bus name */
>         len = strlen(parent->id) + 16;
>         buf = qemu_malloc(len);
>         snprintf(buf, len, "%s.%d", parent->id, parent->num_child_bus);
>         bus->name = buf;
>     } else {
>         /* no id -> use lowercase bus type for bus name */
>         len = strlen(info->name) + 16;
>         buf = qemu_malloc(len);
>         len = snprintf(buf, len, "%s.%d", info->name,
>                        parent ? parent->num_child_bus : 0);
>         for (i = 0; i < len; i++)
>             buf[i] = qemu_tolower(buf[i]);
>         bus->name = buf;
>     }
> 
> If appending ".0" really makes no sense when the device has just one
> bus, then we shouldn't append it in cases 2 & 3.

IMO the code you quote is completely bogus.  All devices should specify names 
for their child busses, failure to do so is a bug.

These bus names are local to the parent device. Trying to use them as global 
identifiers is just plain wrong.  A given device [type] should always have the 
same set of properties/child busses regardless of where it occurs in the 
device tree.
Using a single counter for all busses is also wrong. The order of bus creation 
is a device implementation detail, under no circumstances should it be part of 
the user visible API.  Consider a device that has both a PCI and I2C bus. It 
makes no sense to call there pci.0 and i2c.1.

Paul

  reply	other threads:[~2010-06-02 15:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-19 16:42 [Qemu-devel] [PATCH] Name the default PCI bus "pci.0" on all architectures Daniel P. Berrange
2010-05-19 19:19 ` Blue Swirl
2010-05-20 10:00   ` Daniel P. Berrange
2010-05-28 19:39 ` Paul Brook
2010-05-29  5:13   ` Markus Armbruster
2010-06-02 15:13     ` Paul Brook [this message]
2010-06-11 13:00       ` Markus Armbruster
2010-06-11 14:28         ` Paul Brook
2010-06-02 14:12   ` Daniel P. Berrange
2010-06-02 15:10     ` Paul Brook
2010-06-02 21:03       ` Gerd Hoffmann
2010-06-03  5:45         ` Paul Brook
2010-06-03 10:14     ` Andreas Färber

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=201006021613.56797.paul@codesourcery.com \
    --to=paul@codesourcery.com \
    --cc=armbru@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).