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: Fix portability issue of lspci opti

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xend: Fix portability issue of lspci option.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 01 Aug 2008 02:20:19 -0700
Delivery-date: Fri, 01 Aug 2008 02:21:02 -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 1217504396 -3600
# Node ID 8182a85460f74d14f3b2fd49df43c528872700db
# Parent  a23f0d91e2fcb492c8c26659e14d004e9b6f7caf
xend: Fix portability issue of lspci option.

Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@xxxxxxxxxxxxx>
---
 tools/python/xen/util/pci.py |   29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)

diff -r a23f0d91e2fc -r 8182a85460f7 tools/python/xen/util/pci.py
--- a/tools/python/xen/util/pci.py      Thu Jul 31 12:38:32 2008 +0100
+++ b/tools/python/xen/util/pci.py      Thu Jul 31 12:39:56 2008 +0100
@@ -111,15 +111,22 @@ def parse_hex(val):
         return None
 
 def parse_pci_name(pci_name_string):
-    # Format: xxxx:xx:xx.x
-    s = pci_name_string
-    s = s.split(':')
-    dom = parse_hex(s[0])
-    bus = parse_hex(s[1])
-    s = s[2].split('.')
-    dev = parse_hex(s[0])
-    func =  parse_hex(s[1])
-    return (dom, bus, dev, func)
+    pci_match = re.match(r"((?P<domain>[0-9a-fA-F]{1,4})[:,])?" + \
+            r"(?P<bus>[0-9a-fA-F]{1,2})[:,]" + \
+            r"(?P<slot>[0-9a-fA-F]{1,2})[.,]" + \
+            r"(?P<func>[0-7])$", pci_name_string)
+    if pci_match is None:
+        raise PciDeviceParseError(('Failed to parse pci device name: %s' %
+            pci_name_string))
+    pci_dev_info = pci_match.groupdict('0')
+
+    domain = parse_hex(pci_dev_info['domain'])
+    bus = parse_hex(pci_dev_info['bus'])
+    slot = parse_hex(pci_dev_info['slot'])
+    func = parse_hex(pci_dev_info['func'])
+
+    return (domain, bus, slot, func)
+ 
 
 def find_sysfs_mnt():
     global sysfs_mnt_point
@@ -175,14 +182,14 @@ def create_lspci_info():
 
     # Execute 'lspci' command and parse the result.
     # If the command does not exist, lspci_info will be kept blank ({}).
-    for paragraph in os.popen(LSPCI_CMD + ' -vmmD').read().split('\n\n'):
+    for paragraph in os.popen(LSPCI_CMD + ' -vmm').read().split('\n\n'):
         device_name = None
         device_info = {}
         for line in paragraph.split('\n'):
             try:
                 (opt, value) = line.split(':\t')
                 if opt == 'Slot':
-                    device_name = value
+                    device_name = PCI_DEV_FORMAT_STR % parse_pci_name(value)
                 else:
                     device_info[opt] = value
             except:

_______________________________________________
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: Fix portability issue of lspci option., Xen patchbot-unstable <=