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

[Xen-changelog] [xen-unstable] xend: support for older pciutils without -vmm option, and improve



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1245149627 -3600
# Node ID 45ca3f3c3f98118efa6ec207b094c4e61fbee79d
# Parent  d96cf4c974d58a82cbaee72820ae3ea637a5ebdb
xend: support for older pciutils without -vmm option, and improve
error handling in get_info_from_lspci().

Signed-off-by: Zhigang Wang <zhigang.x.wang@xxxxxxxxxx>
---
 tools/python/xen/util/pci.py |   31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)

diff -r d96cf4c974d5 -r 45ca3f3c3f98 tools/python/xen/util/pci.py
--- a/tools/python/xen/util/pci.py      Tue Jun 16 11:47:09 2009 +0100
+++ b/tools/python/xen/util/pci.py      Tue Jun 16 11:53:47 2009 +0100
@@ -233,11 +233,16 @@ def _create_lspci_info():
     for paragraph in os.popen(LSPCI_CMD + ' -vmm').read().split('\n\n'):
         device_name = None
         device_info = {}
+        # FIXME: workaround for pciutils without the -mm option.
+        # see: git://git.kernel.org/pub/scm/utils/pciutils/pciutils.git
+        # commit: 3fd6b4d2e2fda814047664ffc67448ac782a8089
+        first_device = True
         for line in paragraph.split('\n'):
             try:
                 (opt, value) = line.split(':\t')
-                if opt == 'Slot':
+                if opt == 'Slot' or (opt == 'Device' and first_device):
                     device_name = PCI_DEV_FORMAT_STR % parse_pci_name(value)
+                    first_device = False
                 else:
                     device_info[opt] = value
             except:
@@ -980,18 +985,18 @@ class PciDevice:
             if lspci_info is None:
                 _create_lspci_info()
 
-            try:
-                device_info = lspci_info[self.name]
-                self.revision = int(device_info['Rev'], 16)
-                self.vendorname = device_info['Vendor']
-                self.devicename = device_info['Device']
-                self.classname = device_info['Class']
-                self.subvendorname = device_info['SVendor']
-                self.subdevicename = device_info['SDevice']
-            except KeyError:
-                pass
-
-            return True
+            device_info = lspci_info.get(self.name)
+            if device_info:
+                try:
+                    self.revision = int(device_info.get('Rev', '0'), 16)
+                except ValueError:
+                    pass
+                self.vendorname = device_info.get('Vendor', '')
+                self.devicename = device_info.get('Device', '')
+                self.classname = device_info.get('Class', '')
+                self.subvendorname = device_info.get('SVendor', '')
+                self.subdevicename = device_info.get('SDevice', '')
+                return True
         finally:
             lspci_info_lock.release()
 

_______________________________________________
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®.