ia64/xen-unstable

changeset 19698:f72d26c00002

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@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jun 02 11:50:16 2009 +0100 (2009-06-02)
parents 42fe00c6f8b4
children 18c8270da77c
files tools/python/xen/util/pci.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/pciif.py
line diff
     1.1 --- a/tools/python/xen/util/pci.py	Tue Jun 02 11:49:34 2009 +0100
     1.2 +++ b/tools/python/xen/util/pci.py	Tue Jun 02 11:50:16 2009 +0100
     1.3 @@ -372,7 +372,7 @@ class PciDeviceAssignmentError(Exception
     1.4      def __init__(self,msg):
     1.5          self.message = msg
     1.6      def __str__(self):
     1.7 -        return 'pci: impproper device assignment spcified: ' + \
     1.8 +        return 'pci: improper device assignment specified: ' + \
     1.9              self.message
    1.10  
    1.11  class PciDeviceVslotMissing(Exception):
    1.12 @@ -582,10 +582,10 @@ class PciDevice:
    1.13  
    1.14      def find_all_the_multi_functions(self):
    1.15          sysfs_mnt = find_sysfs_mnt()
    1.16 -        pci_names = os.popen('ls ' + sysfs_mnt + SYSFS_PCI_DEVS_PATH).read()
    1.17 -        p = self.name
    1.18 -        p = p[0 : p.rfind('.')] + '.[0-7]'
    1.19 -        funcs = re.findall(p, pci_names)
    1.20 +        parent = PCI_DEV_FORMAT_STR % self.find_parent()
    1.21 +        pci_names = os.popen('ls ' + sysfs_mnt + SYSFS_PCI_DEVS_PATH + '/' + \
    1.22 +            parent + '/').read()
    1.23 +        funcs = re.findall(PCI_DEV_REG_EXPRESS_STR, pci_names)
    1.24          return funcs
    1.25  
    1.26      def find_coassigned_devices(self):
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Jun 02 11:49:34 2009 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Jun 02 11:50:16 2009 +0100
     2.3 @@ -708,6 +708,7 @@ class XendDomainInfo:
     2.4          # co-assignment devices hasn't been assigned, or has been assigned to
     2.5          # domN.
     2.6          coassignment_list = pci_device.find_coassigned_devices()
     2.7 +        pci_device.devs_check_driver(coassignment_list)
     2.8          assigned_pci_device_str_list = self._get_assigned_pci_devices()
     2.9          for pci_str in coassignment_list:
    2.10              (domain, bus, dev, func) = parse_pci_name(pci_str) 
     3.1 --- a/tools/python/xen/xend/server/pciif.py	Tue Jun 02 11:49:34 2009 +0100
     3.2 +++ b/tools/python/xen/xend/server/pciif.py	Tue Jun 02 11:50:16 2009 +0100
     3.3 @@ -379,6 +379,9 @@ class PciController(DevController):
     3.4              pci_str_list = pci_str_list + [pci_str]
     3.5              pci_dev_list = pci_dev_list + [(domain, bus, slot, func)]
     3.6  
     3.7 +        if len(pci_str_list) != len(set(pci_str_list)):
     3.8 +            raise VmError('pci: duplicate devices specified in guest config?')
     3.9 +
    3.10          for (domain, bus, slot, func) in pci_dev_list:
    3.11              try:
    3.12                  dev = PciDevice(domain, bus, slot, func)
    3.13 @@ -395,6 +398,7 @@ class PciController(DevController):
    3.14                      log.warn(err_msg % dev.name)
    3.15                  else:
    3.16                      funcs = dev.find_all_the_multi_functions()
    3.17 +                    dev.devs_check_driver(funcs)
    3.18                      for f in funcs:
    3.19                          if not f in pci_str_list:
    3.20                              (f_dom, f_bus, f_slot, f_func) = parse_pci_name(f)
    3.21 @@ -422,6 +426,7 @@ class PciController(DevController):
    3.22                      # Remove the element 0 which is a bridge
    3.23                      del devs_str[0]
    3.24  
    3.25 +                    dev.devs_check_driver(devs_str)
    3.26                      for s in devs_str:
    3.27                          if not s in pci_str_list:
    3.28                              (s_dom, s_bus, s_slot, s_func) = parse_pci_name(s)