From patchwork Fri Jun 25 17:08:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 56981 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E8140B6F01 for ; Sat, 26 Jun 2010 05:52:06 +1000 (EST) Received: from localhost ([127.0.0.1]:48434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OSDwV-0001FS-Ne for incoming@patchwork.ozlabs.org; Fri, 25 Jun 2010 14:47:59 -0400 Received: from [140.186.70.92] (port=44167 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OSCvI-0002Dc-LW for qemu-devel@nongnu.org; Fri, 25 Jun 2010 13:42:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OSCOl-00062p-IP for qemu-devel@nongnu.org; Fri, 25 Jun 2010 13:09:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59644) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OSCOl-00062e-BB for qemu-devel@nongnu.org; Fri, 25 Jun 2010 13:09:03 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5PH91Ox024768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 25 Jun 2010 13:09:01 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5PH90ok014847; Fri, 25 Jun 2010 13:09:00 -0400 From: Alex Williamson To: qemu-devel@nongnu.org Date: Fri, 25 Jun 2010 11:08:59 -0600 Message-ID: <20100625170859.8325.99871.stgit@localhost.localdomain> In-Reply-To: <20100625170544.8325.62081.stgit@localhost.localdomain> References: <20100625170544.8325.62081.stgit@localhost.localdomain> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: alex.williamson@redhat.com Subject: [Qemu-devel] [PATCH v2 04/16] pci: Implement BusInfo.get_dev_path() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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),