Re: [Qemu-devel] [RFC PATCH 1/5] qdev: Create qdev_get_dev_path()

Alex Williamson
2010-06-18T15:01:36Z

On Fri, 2010-06-18 at 11:16 +0200, Jan Kiszka wrote:
> Alex Williamson wrote:
> > On Wed, 2010-06-16 at 10:23 +0200, Markus Armbruster wrote:
> >> Alex Williamson <alex.williamson@redhat.com> writes:
> >>
> >>> On Tue, 2010-06-15 at 12:28 +0100, Paul Brook wrote:
> >>>>>> Alex proposed to disambiguate by adding "identified properties of the
> >>>>>> immediate parent bus and device" to the path component. For PCI, these
> >>>>>> are dev.fn. Likewise for any other bus where devices have unambigous
> >>>>>> bus address. The driver name carries no information!
> >>>>> From user POV, driver names are very handly to address a device
> >>>>> intuitively - except for the case you have tones of devices on the same
> >>>>> bus that are handled by the same driver. For that case we need to
> >>>>> augment the device name with a useful per-bus ID, derived from the bus
> >>>>> address where available, otherwise based on instance numbers.
> >>>> This is where I think you're missing a trick. We don't need to augment the
> >>>> name, we just need to allow the bus id to be used instead.
> >>> For the case of a hot remove, I agree. If the user specifies "pci_del
> >>> pci.0/03.0", that's completely sufficient because we don't care what's
> >>> in that slot, just remove it. However, I still see some use cases for
> >>> device names in the path. Take for example:
> >>>
> >>> (A): /i440FX-pcihost/pci.0/e1000.05.0
> >>>
> >>> vs
> >>>
> >>> (B): /pci.0/05.0
> >>>
> >>> (removing both the root bridge driver name and the device driver name)
> >> / is the main system bus. System bus defines no bus address at the
> >> moment. Therefore, you have to use the driver name i440FX-pcihost.
> >
> > So is the general rule "If a device's parent bus does not provide an
> > address, print device name"?
>
> What is the device name?

dev->info->name

> >
> >> /i440FX-pcihost/pci.0 is the PCI bus. PCI bus defines a bus address:
> >> dev.fn. Therefore, you can either use the bus address @05.0, or the
> >> driver name e1000.
> >>
> >> We have "/i440FX-pcihost/pci.0/e1000" vs. "/i440FX-pcihost/pci.0/@05.0".
> >
> > I object to being able to use anything but an address under a bus that
> > supports hotplug, but that aside, I think the paths for my example
> > system look like below. Note that anything behind and including the $
> > is not the canonical path, that begins the free form, usage specific
> > string, here filled by missing device names (open to suggestions other
> > than $ here).
>
> What about ":" instead of "$"? Visually more appealing IMO.

Sure, that works.

> > Note that were isa devices do not have a bus identifier,
> > I'm using the device name,
>
> Don't understand. Why don't they have their I/O base as prefix? This is
> inconsistent, and if we consider anything behind "$" (or ":")
> informative, the bus address is mandatory for any device (on a bus with
> an addressing scheme).

Not all isa devices expose an iobase property. isa doesn't have an
addressing scheme, it's basically a free for all of grabbing addresses
and interrupts and hoping they don't conflict with no means to uniquely
address a specific device. That's why isa cards are loaded with jumpers
so you can try to move them around.

> > which I think follows the same rule as
> > i440FX-pcihost. Can we agree this is the goal? Thanks,
>
> It looks almost acceptable from my POV. We just need to define how to
> get hold of devices on buses without an addressing scheme (e.g. the
> system bus). Using the driver name is insufficient once you have > 1
> devices of the same type. Introducing device instance numbers to those
> buses would be straightforward IMO.

Yep, as I mentioned, I can live with instance numbers for devices that
do not live on a hotpluggable bus. Where will the instance number go?
A property on the parent bus, the device, field in the DeviceState?
Thanks,

Alex