]> xenbits.xensource.com Git - xen.git/commitdiff
xend: pci: improve the assignability checking
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 2 Jun 2009 10:50:16 +0000 (11:50 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 2 Jun 2009 10:50:16 +0000 (11:50 +0100)
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@intel.com>
tools/python/xen/util/pci.py
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xend/server/pciif.py

index c88ad25bec7723efe8e53987f6c254afe9b1514e..6542a0ccd9685dabf043d51b57aceb32f5f502de 100644 (file)
@@ -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):
index 9d821d02fae037d4280ddfc86cf1423a15250f60..aa6c9186541c4634560f01c5c67bad68e9c562fb 100644 (file)
@@ -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) 
index cccdc9d4f23a9dbd8378ef1660683fcfba95a166..bce355a16a28aad71d858f541086e0613b228dda 100644 (file)
@@ -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)