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

[Xen-changelog] [xen-unstable] xend: pci: show error msg properly if pciback/pci-stub are not loaded



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1258960987 0
# Node ID 2864f194279092b827e4dd1eeea949a48010b142
# Parent  005bd672d3af540c19e5c6dc9215556953aa8771
xend: pci: show error msg properly if pciback/pci-stub are not loaded

Signed-off-by: Dexuan Cui <dexuan.cui@xxxxxxxxx>
---
 tools/python/xen/util/pci.py      |   17 +++++++----------
 tools/python/xen/xend/XendNode.py |    2 ++
 tools/python/xen/xm/main.py       |    3 +++
 3 files changed, 12 insertions(+), 10 deletions(-)

diff -r 005bd672d3af -r 2864f1942790 tools/python/xen/util/pci.py
--- a/tools/python/xen/util/pci.py      Mon Nov 23 07:22:28 2009 +0000
+++ b/tools/python/xen/util/pci.py      Mon Nov 23 07:23:07 2009 +0000
@@ -517,20 +517,17 @@ def find_all_assignable_devices():
     '''
     sysfs_mnt = find_sysfs_mnt()
     pciback_path = sysfs_mnt + SYSFS_PCIBACK_PATH
-    pci_names = os.popen('ls ' + pciback_path).read()
-    pci_list = extract_the_exact_pci_names(pci_names)
+    pcistub_path = sysfs_mnt + SYSFS_PCISTUB_PATH
+    pci_names1 = os.popen('ls %s 2>/dev/null' % pciback_path).read()
+    pci_names2 = os.popen('ls %s 2>/dev/null' % pcistub_path).read()
+    if len(pci_names1) + len(pci_names2) == 0 :
+        return None
+    pci_list = extract_the_exact_pci_names(pci_names1)
+    pci_list = pci_list + extract_the_exact_pci_names(pci_names2)
     dev_list = []
     for pci in pci_list:
         dev = PciDevice(parse_pci_name(pci))
         dev_list = dev_list + [dev]
-
-    pcistub_path = sysfs_mnt + SYSFS_PCISTUB_PATH
-    pci_names = os.popen('ls ' + pcistub_path).read()
-    pci_list = extract_the_exact_pci_names(pci_names)
-    for pci in pci_list:
-        dev = PciDevice(parse_pci_name(pci))
-        dev_list = dev_list + [dev]
-
     return dev_list
 
 def transform_list(target, src):
diff -r 005bd672d3af -r 2864f1942790 tools/python/xen/xend/XendNode.py
--- a/tools/python/xen/xend/XendNode.py Mon Nov 23 07:22:28 2009 +0000
+++ b/tools/python/xen/xend/XendNode.py Mon Nov 23 07:23:07 2009 +0000
@@ -924,6 +924,8 @@ class XendNode:
 
         # Each element of dev_list is a PciDevice
         dev_list = PciUtil.find_all_assignable_devices()
+        if dev_list is None:
+            return None
  
         # Each element of devs_list is a list of PciDevice
         devs_list = PciUtil.check_FLR_capability(dev_list)
diff -r 005bd672d3af -r 2864f1942790 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Mon Nov 23 07:22:28 2009 +0000
+++ b/tools/python/xen/xm/main.py       Mon Nov 23 07:23:07 2009 +0000
@@ -2313,6 +2313,9 @@ def xm_pci_list_assignable_devices(args)
     arg_check(args, "pci-list-assignable-devices", 0)
 
     devs =  server.xend.node.pciinfo()
+    if devs is None:
+        print "Error: pciback/pci-stub not loaded?"
+        return
  
     fmt_str = "%(domain)04x:%(bus)02x:%(slot)02x.%(func)01x"
     for x in devs:

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