All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: xen-devel@lists.xensource.com
Cc: Zhigang Wang <zhigang.x.wang@oracle.com>,
	Akio Takebe <takebe_akio@jp.fujitsu.com>,
	Masaki Kanno <kanno.masaki@jp.fujitsu.com>,
	Dexuan Cui <dexuan.cui@intel.com>
Subject: [patch 01/17] xend: Support older pciutils without -vmm option
Date: Wed, 17 Jun 2009 12:56:13 +1000	[thread overview]
Message-ID: <20090617032044.641089269@vergenet.net> (raw)
In-Reply-To: 20090617025612.786241401@vergenet.net

[-- Attachment #1: fix-pci.py.patch --]
[-- Type: text/plain, Size: 3656 bytes --]

From: Zhigang Wang <zhigang.x.wang@oracle.com>

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@verge.net.au>
Signed-off-by: Zhigang Wang <zhigang.x.wang@oracle.com>

--- 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()
 

-- 

  reply	other threads:[~2009-06-17  2:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-17  2:56 [patch 00/17] xend: pass-through: various clean-ups and infrastructure: take iii Simon Horman
2009-06-17  2:56 ` Simon Horman [this message]
2009-06-17  2:56 ` [patch 02/17] xend: pass-through: Only call setupOneDevice() once per device Simon Horman
2009-06-17  2:56 ` [patch 03/17] xend: pass-through: fix typo: spx -> sxp Simon Horman
2009-06-17  2:56 ` [patch 04/17] xend: pass-through: tidy up PciController() Simon Horman
2009-06-17  2:56 ` [patch 05/17] xend: pass-through: cleanupDevice: move and remove recently added vslot entry Simon Horman
2009-06-17  2:56 ` [patch 06/17] xend: pass-through: sxp.merge() cant deal with values being a list Simon Horman
2009-06-17  2:56 ` [patch 07/17] xend: pass-through: Remove PciDeviceNotFoundError, it is never used Simon Horman
2009-06-17  2:56 ` [patch 08/17] xend: pass-through: Use PCIDevice as the parameter for the constructor for PCIQuirk Simon Horman
2009-06-17  2:56 ` [patch 09/17] xend: pass-through: Common parse_pci_name() Simon Horman
2009-06-17  2:56 ` [patch 10/17] xend: pass-through: Use common parsing code in preprocess_pci() Simon Horman
2009-06-17  2:56 ` [patch 11/17] xend: pass-through: Add pci_dict_cmp() Simon Horman
2009-06-17  2:56 ` [patch 12/17] xend: pass-through: Move pci conversion functions to pci.py Simon Horman
2009-06-17  2:56 ` [patch 13/17] xend: pass-through: Use generic code in pci_opts_list_to_sxp() Simon Horman
2009-06-17  2:56 ` [patch 14/17] xend: pass-through: Add pci_tuple_to_dict() Simon Horman
2009-06-17  2:56 ` [patch 15/17] xend: pass-through: Use common parsing code in parse_pci_configuration() Simon Horman
2009-06-17  2:56 ` [patch 16/17] xend: pass-through: Use common parsing code in getDeviceConfiguration() Simon Horman
2009-06-17  2:56 ` [patch 17/17] xend: pass-through: Clean up hvm_destroyPCIDevice() Simon Horman
2009-06-17  6:12 ` [patch 00/17] xend: pass-through: various clean-ups and infrastructure: take iii Keir Fraser
2009-06-17  6:41   ` Keir Fraser
2009-06-17  6:55     ` Simon Horman
2009-06-17  7:17       ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090617032044.641089269@vergenet.net \
    --to=horms@verge.net.au \
    --cc=dexuan.cui@intel.com \
    --cc=kanno.masaki@jp.fujitsu.com \
    --cc=takebe_akio@jp.fujitsu.com \
    --cc=xen-devel@lists.xensource.com \
    --cc=zhigang.x.wang@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.