@@ -1677,6 +1677,23 @@ static PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_num)
return NULL;
}
+void pci_for_each_bus(PCIBus *bus,
+ void (*fn)(PCIBus *bus, void *opaque),
+ void *opaque)
+{
+ PCIBus *sec;
+
+ if (!bus) {
+ return;
+ }
+
+ fn(bus, opaque);
+
+ QLIST_FOREACH(sec, &bus->child, sibling) {
+ pci_for_each_bus(sec, fn, opaque);
+ }
+}
+
PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn)
{
bus = pci_find_bus_nr(bus, bus_num);
@@ -390,6 +390,10 @@ int pci_bus_num(PCIBus *s);
void pci_for_each_device(PCIBus *bus, int bus_num,
void (*fn)(PCIBus *bus, PCIDevice *d, void *opaque),
void *opaque);
+
+void pci_for_each_bus(PCIBus *bus,
+ void (*fn)(PCIBus *bus, void *opaque),
+ void *opaque);
PCIBus *pci_find_root_bus(int domain);
int pci_find_domain(const PCIBus *bus);
PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
This will be useful for bridge ACPI hotplug. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> --- hw/pci/pci.c | 17 +++++++++++++++++ include/hw/pci/pci.h | 4 ++++ 2 files changed, 21 insertions(+)