WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xend: pci: only extract the exact pci BDF

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xend: pci: only extract the exact pci BDFs
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 04 Jun 2009 10:25:46 -0700
Delivery-date: Thu, 04 Jun 2009 10:28:57 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1244108876 -3600
# Node ID d8b7b51f482b709a8691c3020cfec68bee4a204c
# Parent  265de5701b82997f8367ecf0e1ef7f092ea5e160
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>
---
 tools/python/xen/util/pci.py |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff -r 265de5701b82 -r d8b7b51f482b tools/python/xen/util/pci.py
--- a/tools/python/xen/util/pci.py      Thu Jun 04 10:46:13 2009 +0100
+++ b/tools/python/xen/util/pci.py      Thu Jun 04 10:47:56 2009 +0100
@@ -152,6 +152,18 @@ def parse_pci_name(pci_name_string):
     func = parse_hex(pci_dev_info['func'])
 
     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:
@@ -253,7 +265,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)
@@ -454,7 +466,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:
@@ -491,7 +503,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):
@@ -578,7 +590,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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xend: pci: only extract the exact pci BDFs, Xen patchbot-unstable <=