diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2009-06-04 10:47:56 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2009-06-04 10:47:56 +0100 |
commit | e6e2645a5373dbe99685767f9c22616392ade016 (patch) | |
tree | 6ab862cfabd2c678a6bbb25654bd589a620fb5f3 | |
parent | a161e0d852981658b56c0de457e213f7d9b02c22 (diff) | |
download | xen-e6e2645a5373dbe99685767f9c22616392ade016.tar.gz xen-e6e2645a5373dbe99685767f9c22616392ade016.tar.bz2 xen-e6e2645a5373dbe99685767f9c22616392ade016.zip |
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@intel.com>
-rw-r--r-- | tools/python/xen/util/pci.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/tools/python/xen/util/pci.py b/tools/python/xen/util/pci.py index be7ab7108e..f4f9f7bfcf 100644 --- a/tools/python/xen/util/pci.py +++ b/tools/python/xen/util/pci.py @@ -153,6 +153,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: return utils.find_sysfs_mount() @@ -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): |