From c10bf6159ff24501852c91a342c3077d5388b184 Mon Sep 17 00:00:00 2001 From: Marcelo Tosatti Date: Tue, 11 Mar 2008 17:11:54 -0300 Subject: [PATCH] kvm: qemu: add pci_find_bus Return PCIBus pointer from bus number integer. Signed-off-by: Marcelo Tosatti Signed-off-by: Avi Kivity --- qemu/hw/pci.c | 10 ++++++++++ qemu/hw/pci.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/qemu/hw/pci.c b/qemu/hw/pci.c index b6df5ade..91823076 100644 --- a/qemu/hw/pci.c +++ b/qemu/hw/pci.c @@ -675,6 +675,16 @@ static void pci_bridge_write_config(PCIDevice *d, pci_default_write_config(d, address, val, len); } +PCIBus *pci_find_bus(int bus_num) +{ + PCIBus *bus = first_bus; + + while (bus && bus->bus_num != bus_num) + bus = bus->next; + + return bus; +} + PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id, pci_map_irq_fn map_irq, const char *name) { diff --git a/qemu/hw/pci.h b/qemu/hw/pci.h index e870987f..b96348b1 100644 --- a/qemu/hw/pci.h +++ b/qemu/hw/pci.h @@ -3,6 +3,7 @@ /* PCI includes legacy ISA access. */ #include "isa.h" +#include /* PCI bus */ @@ -91,6 +92,7 @@ void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len); uint32_t pci_data_read(void *opaque, uint32_t addr, int len); int pci_bus_num(PCIBus *s); void pci_for_each_device(int bus_num, void (*fn)(PCIDevice *d)); +PCIBus *pci_find_bus(int bus_num); void pci_info(void); PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id, -- 2.11.4.GIT