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

[Xen-changelog] [xen-unstable] xend: pci: improve the assignability checking



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1243939816 -3600
# Node ID f72d26c0000292889cfe3a85008d2c4482fee772
# Parent  42fe00c6f8b4e7f5c7c13ab8928d8dae24f19a72
xend: pci: improve the assignability checking

1) fix some small typos in util/pci.py;
2) find_all_the_multi_functions(): BDFs of a multi-function PCIe
device could be different in all the 3 fields (bus, device, function),
so we need self.find_parent() and list all t
he BDFs below the parent;
3) to assign a device of the must-be-co-assigned devices, we require
all the related devices should be owned by pciback;
4) detect and disallow duplicate pci string specified in guest config
file due to carelessness.

Signed-off-by: Dexuan Cui <dexuan.cui@xxxxxxxxx>
---
 tools/python/xen/util/pci.py            |   10 +++++-----
 tools/python/xen/xend/XendDomainInfo.py |    1 +
 tools/python/xen/xend/server/pciif.py   |    5 +++++
 3 files changed, 11 insertions(+), 5 deletions(-)

diff -r 42fe00c6f8b4 -r f72d26c00002 tools/python/xen/util/pci.py
--- a/tools/python/xen/util/pci.py      Tue Jun 02 11:49:34 2009 +0100
+++ b/tools/python/xen/util/pci.py      Tue Jun 02 11:50:16 2009 +0100
@@ -372,7 +372,7 @@ class PciDeviceAssignmentError(Exception
     def __init__(self,msg):
         self.message = msg
     def __str__(self):
-        return 'pci: impproper device assignment spcified: ' + \
+        return 'pci: improper device assignment specified: ' + \
             self.message
 
 class PciDeviceVslotMissing(Exception):
@@ -582,10 +582,10 @@ class PciDevice:
 
     def find_all_the_multi_functions(self):
         sysfs_mnt = find_sysfs_mnt()
-        pci_names = os.popen('ls ' + sysfs_mnt + SYSFS_PCI_DEVS_PATH).read()
-        p = self.name
-        p = p[0 : p.rfind('.')] + '.[0-7]'
-        funcs = re.findall(p, pci_names)
+        parent = PCI_DEV_FORMAT_STR % self.find_parent()
+        pci_names = os.popen('ls ' + sysfs_mnt + SYSFS_PCI_DEVS_PATH + '/' + \
+            parent + '/').read()
+        funcs = re.findall(PCI_DEV_REG_EXPRESS_STR, pci_names)
         return funcs
 
     def find_coassigned_devices(self):
diff -r 42fe00c6f8b4 -r f72d26c00002 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Tue Jun 02 11:49:34 2009 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py   Tue Jun 02 11:50:16 2009 +0100
@@ -708,6 +708,7 @@ class XendDomainInfo:
         # co-assignment devices hasn't been assigned, or has been assigned to
         # domN.
         coassignment_list = pci_device.find_coassigned_devices()
+        pci_device.devs_check_driver(coassignment_list)
         assigned_pci_device_str_list = self._get_assigned_pci_devices()
         for pci_str in coassignment_list:
             (domain, bus, dev, func) = parse_pci_name(pci_str) 
diff -r 42fe00c6f8b4 -r f72d26c00002 tools/python/xen/xend/server/pciif.py
--- a/tools/python/xen/xend/server/pciif.py     Tue Jun 02 11:49:34 2009 +0100
+++ b/tools/python/xen/xend/server/pciif.py     Tue Jun 02 11:50:16 2009 +0100
@@ -379,6 +379,9 @@ class PciController(DevController):
             pci_str_list = pci_str_list + [pci_str]
             pci_dev_list = pci_dev_list + [(domain, bus, slot, func)]
 
+        if len(pci_str_list) != len(set(pci_str_list)):
+            raise VmError('pci: duplicate devices specified in guest config?')
+
         for (domain, bus, slot, func) in pci_dev_list:
             try:
                 dev = PciDevice(domain, bus, slot, func)
@@ -395,6 +398,7 @@ class PciController(DevController):
                     log.warn(err_msg % dev.name)
                 else:
                     funcs = dev.find_all_the_multi_functions()
+                    dev.devs_check_driver(funcs)
                     for f in funcs:
                         if not f in pci_str_list:
                             (f_dom, f_bus, f_slot, f_func) = parse_pci_name(f)
@@ -422,6 +426,7 @@ class PciController(DevController):
                     # Remove the element 0 which is a bridge
                     del devs_str[0]
 
+                    dev.devs_check_driver(devs_str)
                     for s in devs_str:
                         if not s in pci_str_list:
                             (s_dom, s_bus, s_slot, s_func) = parse_pci_name(s)

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