aboutsummaryrefslogtreecommitdiff
path: root/hw/pci.c
diff options
context:
space:
mode:
authorIsaku Yamahata <yamahata@valinux.co.jp>2010-05-28 18:30:46 +0900
committerMichael S. Tsirkin <mst@redhat.com>2010-05-31 16:39:55 +0300
commite075e788c9e882f5bebfb350f725ee7e4273033f (patch)
treecee279dff54e91932b3915f702324fd55e6630e9 /hw/pci.c
parent1b4e8f732d118d1bd64c49e3c9d90832f8214272 (diff)
pci-hotplug: make them aware of pci domain.
add helper function which converts root bus to pci domain. make them aware of pci domain. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/pci.c')
-rw-r--r--hw/pci.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/hw/pci.c b/hw/pci.c
index 3362842bf2..f084cc0285 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -200,6 +200,26 @@ PCIBus *pci_find_root_bus(int domain)
return NULL;
}
+int pci_find_domain(const PCIBus *bus)
+{
+ PCIDevice *d;
+ struct PCIHostBus *host;
+
+ /* obtain root bus */
+ while ((d = bus->parent_dev) != NULL) {
+ bus = d->bus;
+ }
+
+ QLIST_FOREACH(host, &host_buses, next) {
+ if (host->bus == bus) {
+ return host->domain;
+ }
+ }
+
+ abort(); /* should not be reached */
+ return -1;
+}
+
void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
const char *name, int devfn_min)
{
@@ -505,7 +525,7 @@ PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
}
*devfnp = slot << 3;
- return pci_find_bus(pci_find_root_bus(0), bus);
+ return pci_find_bus(pci_find_root_bus(dom), bus);
}
static void pci_init_cmask(PCIDevice *dev)