qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [patch 14/24] QEMU/KVM: add pci_find_device


From: Marcelo Tosatti
Subject: [Qemu-devel] [patch 14/24] QEMU/KVM: add pci_find_device
Date: Tue, 11 Mar 2008 17:12:05 -0300
User-agent: quilt/0.46-1

Return PCIDevice from bus number and slot.

Signed-off-by: Marcelo Tosatti <address@hidden>

Index: kvm-userspace.hotplug/qemu/hw/pci.c
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pci.c
+++ kvm-userspace.hotplug/qemu/hw/pci.c
@@ -689,6 +689,23 @@ PCIBus *pci_find_bus(int bus_num)
     return bus;
 }
 
+PCIDevice *pci_find_device(int bus_num, int slot)
+{
+    int devfn;
+    PCIDevice *d;
+    PCIBus *bus = pci_find_bus(bus_num);
+
+    if (!bus)
+        return NULL;
+
+    for(devfn = 0; devfn < 256; devfn++) {
+        d = bus->devices[devfn];
+            if (d && PCI_SLOT(devfn) == slot)
+                return d;
+    }
+    return NULL;
+}
+
 PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,
                         pci_map_irq_fn map_irq, const char *name)
 {
Index: kvm-userspace.hotplug/qemu/hw/pci.h
===================================================================
--- kvm-userspace.hotplug.orig/qemu/hw/pci.h
+++ kvm-userspace.hotplug/qemu/hw/pci.h
@@ -93,6 +93,7 @@ uint32_t pci_data_read(void *opaque, uin
 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);
+PCIDevice *pci_find_device(int bus_num, int slot);
 
 void pci_info(void);
 PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,

-- 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]