[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [patch 01/17] xend: Support older pciutils without -vmm option
From: Zhigang Wang <zhigang.x.wang@xxxxxxxxxx> xend: Support older pciutils without -vmm option This patch adds support for older pciutils without -vmm option, and improves error handling in get_info_from_lspci(). pciutils before commit: 3fd6b4d2e2fda814047664ffc67448ac782a8089 in git://git.kernel.org/pub/scm/utils/pciutils/pciutils.git has no -vmm option (it equals -vm). the result of lspci -vmm looks like: Device: 02:00.0 Class: Ethernet controller Vendor: Broadcom Corporation Device: NetXtreme BCM5751 Gigabit Ethernet PCI Express SVendor: Dell SDevice: Optiplex GX620 Rev: 01 Two Device as key. pciutils with -vmm option: Slot: 07:07.0 Class: IDE interface Vendor: Silicon Image, Inc. Device: PCI0680 Ultra ATA-133 Host Controller SVendor: Silicon Image, Inc. SDevice: SiI 0680 ATA/133 Controller Rev: 02 ProgIf: 85 The first Device becomes Slot. For the second part of this patch: without this patch, only an KeyError raise, it will not parse the extra keys, while the other keys still contains useful info. Eg. Slot: 07:02.0 Class: VGA compatible controller Vendor: ATI Technologies Inc Device: Radeon RV100 QY [Radeon 7000/VE] SVendor: Dell SDevice: Device 0183 without a "Rev", it will not parse any of these fields. Acked-by: Simon Horman <horms@xxxxxxxxxxxx> Signed-off-by: Zhigang Wang <zhigang.x.wang@xxxxxxxxxx> --- a/tools/python/xen/util/pci.py 2009-06-09 00:02:19.000000000 +0800 +++ a/tools/python/xen/util/pci.py 2009-06-15 16:12:26.000000000 +0800 @@ -221,11 +221,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: @@ -979,18 +984,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-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |