From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42743 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OUjml-00035C-Mv for qemu-devel@nongnu.org; Fri, 02 Jul 2010 13:12:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OUjmk-0007H5-IX for qemu-devel@nongnu.org; Fri, 02 Jul 2010 13:12:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53688) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OUjmk-0007Gt-8P for qemu-devel@nongnu.org; Fri, 02 Jul 2010 13:12:18 -0400 From: Alex Williamson Date: Fri, 02 Jul 2010 11:12:15 -0600 Message-ID: <20100702171215.30243.51513.stgit@localhost.localdomain> In-Reply-To: <20100702171054.30243.19599.stgit@localhost.localdomain> References: <20100702171054.30243.19599.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH v3 04/16] pci: Implement BusInfo.get_dev_path() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com This works great for PCI since a ::. uniquely describes a global address. No need to traverse up the qdev tree. PCI segment support is a placeholder for compatibility once we support multiple segments. Signed-off-by: Alex Williamson --- hw/pci.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 7787005..1e77ae6 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -58,11 +58,13 @@ struct PCIBus { }; static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent); +static char *pcibus_get_dev_path(DeviceState *dev); static struct BusInfo pci_bus_info = { .name = "PCI", .size = sizeof(PCIBus), .print_dev = pcibus_dev_print, + .get_dev_path = pcibus_get_dev_path, .props = (Property[]) { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), DEFINE_PROP_STRING("romfile", PCIDevice, romfile), @@ -1853,6 +1855,18 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent) } } +static char *pcibus_get_dev_path(DeviceState *dev) +{ + PCIDevice *d = (PCIDevice *)dev; + char path[16]; + + snprintf(path, sizeof(path), "%04x:%02x:%02x.%x", + pci_find_domain(d->bus), d->config[PCI_SECONDARY_BUS], + PCI_SLOT(d->devfn), PCI_FUNC(d->devfn)); + + return strdup(path); +} + static PCIDeviceInfo bridge_info = { .qdev.name = "pci-bridge", .qdev.size = sizeof(PCIBridge),