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

[Xen-changelog] [xen-3.4-testing] xend: pci: only extract the exact pci BDFs



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1244109936 -3600
# Node ID ad354423c3ffcd1ac36c1f3013238dd4265a68f4
# Parent  61322608361ea2ac6ab3013a8b5928fd6d45b5be
xend: pci: only extract the exact pci BDFs

On some hosts:
[root@localhost ~]# ls /sys/bus/pci/devices/0000:00:05.0/
0000:00:05.0:pcie00  0000:05:00.0          class   driver  local_cpus
resource          subsystem_vendor
0000:00:05.0:pcie01  broken_parity_status  config  enable  modalias
subsystem         uevent
0000:00:05.0:pcie02  bus                   device  irq     power
subsystem_device  vendor

Here we should only get 0000:05:00.0, but we also get 0000:00:05.0
unexpectedly. With this patch, xend only extracts the exact BDF(s).

Signed-off-by: Dexuan Cui <dexuan.cui@xxxxxxxxx>
xen-unstable changeset:   19726:d8b7b51f482b
xen-unstable date:        Thu Jun 04 10:47:56 2009 +0100
---
 tools/python/xen/util/pci.py |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff -r 61322608361e -r ad354423c3ff tools/python/xen/util/pci.py
--- a/tools/python/xen/util/pci.py      Thu Jun 04 11:05:05 2009 +0100
+++ b/tools/python/xen/util/pci.py      Thu Jun 04 11:05:36 2009 +0100
@@ -139,6 +139,18 @@ def parse_pci_name(pci_name_string):
 
     return (domain, bus, slot, func)
  
+
+def extract_the_exact_pci_names(pci_names):
+    result = []
+    pci_names = pci_names.split()
+    for pci in pci_names:
+        # The length of DDDD:bb:dd.f is 12.
+        if len(pci) !=  12:
+            continue
+        if re.match(PCI_DEV_REG_EXPRESS_STR, pci) is None:
+            continue
+        result = result + [pci]
+    return result
 
 def find_sysfs_mnt():
     try:
@@ -240,7 +252,7 @@ def find_all_devices_owned_by_pciback():
     sysfs_mnt = find_sysfs_mnt()
     pciback_path = sysfs_mnt + SYSFS_PCIBACK_PATH
     pci_names = os.popen('ls ' + pciback_path).read()
-    pci_list = re.findall(PCI_DEV_REG_EXPRESS_STR, pci_names)
+    pci_list = extract_the_exact_pci_names(pci_names)
     dev_list = []
     for pci in pci_list:
         (dom, b, d, f) = parse_pci_name(pci)
@@ -435,7 +447,7 @@ class PciDevice:
         sysfs_mnt = find_sysfs_mnt()
         self_path = sysfs_mnt + SYSFS_PCI_DEVS_PATH + '/' + self.name
         pci_names = os.popen('ls ' + self_path).read()
-        dev_list = re.findall(PCI_DEV_REG_EXPRESS_STR, pci_names)
+        dev_list = extract_the_exact_pci_names(pci_names)
 
         list = [self.name]
         for pci_str in dev_list:
@@ -472,7 +484,7 @@ class PciDevice:
             return [self.name]
 
         dev_list = dev.find_all_devices_behind_the_bridge(ignore_bridge)
-        dev_list = re.findall(PCI_DEV_REG_EXPRESS_STR, '%s' % dev_list)
+        dev_list = extract_the_exact_pci_names('%s' % dev_list)
         return dev_list
 
     def do_secondary_bus_reset(self, target_bus, devs):
@@ -559,7 +571,7 @@ class PciDevice:
         parent = PCI_DEV_FORMAT_STR % self.find_parent()
         pci_names = os.popen('ls ' + sysfs_mnt + SYSFS_PCI_DEVS_PATH + '/' + \
             parent + '/').read()
-        funcs = re.findall(PCI_DEV_REG_EXPRESS_STR, pci_names)
+        funcs = extract_the_exact_pci_names(pci_names)
         return funcs
 
     def find_coassigned_devices(self):

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.