ia64/xen-unstable

changeset 18174:c6502ade05f9

xend, pci passthru: Relax the requirement of co-assignment.

Certain PCI or PCIe devices needs to be co-assigned. Currently we
require all the related devices be assigned to the same guest. This
can be relaxed to: part of them can be assgined to the same guest, and
after that, the left ones can't be assigned.

Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jul 28 11:28:45 2008 +0100 (2008-07-28)
parents 6783e2ec60c0
children 13690b68fd46
files tools/python/xen/util/pci.py tools/python/xen/xend/server/pciif.py
line diff
     1.1 --- a/tools/python/xen/util/pci.py	Mon Jul 28 11:27:48 2008 +0100
     1.2 +++ b/tools/python/xen/util/pci.py	Mon Jul 28 11:28:45 2008 +0100
     1.3 @@ -105,7 +105,7 @@ def parse_hex(val):
     1.4          return None
     1.5  
     1.6  def parse_pci_name(pci_name_string):
     1.7 -    # Format: xxxx:xx:xx:x
     1.8 +    # Format: xxxx:xx:xx.x
     1.9      s = pci_name_string
    1.10      s = s.split(':')
    1.11      dom = parse_hex(s[0])
     2.1 --- a/tools/python/xen/xend/server/pciif.py	Mon Jul 28 11:27:48 2008 +0100
     2.2 +++ b/tools/python/xen/xend/server/pciif.py	Mon Jul 28 11:28:45 2008 +0100
     2.3 @@ -378,8 +378,14 @@ class PciController(DevController):
     2.4                  funcs = dev.find_all_the_multi_functions()
     2.5                  for f in funcs:
     2.6                      if not f in pci_str_list:
     2.7 -                        err_msg = 'pci: % must be co-assigned to guest with %s'
     2.8 -                        raise VmError(err_msg % (f, dev.name))
     2.9 +                        (f_dom, f_bus, f_slot, f_func) = parse_pci_name(f)
    2.10 +                        f_pci_str = '0x%x,0x%x,0x%x,0x%x' % \
    2.11 +                            (f_dom, f_bus, f_slot, f_func)
    2.12 +                        # f has been assigned to other guest?
    2.13 +                        if xc.test_assign_device(0, f_pci_str) != 0:
    2.14 +                            err_msg = 'pci: %s must be co-assigned to the' + \
    2.15 +                                ' same guest with %s'
    2.16 +                            raise VmError(err_msg % (f, dev.name))
    2.17              elif dev.dev_type == DEV_TYPE_PCI:
    2.18                  if dev.bus == 0:
    2.19                      if not dev.pci_af_flr:
    2.20 @@ -395,8 +401,14 @@ class PciController(DevController):
    2.21  
    2.22                      for s in devs_str:
    2.23                          if not s in pci_str_list:
    2.24 -                            err_msg = 'pci: %s must be co-assigned to guest with %s'
    2.25 -                            raise VmError(err_msg % (s, dev.name))
    2.26 +                            (s_dom, s_bus, s_slot, s_func) = parse_pci_name(s)
    2.27 +                            s_pci_str = '0x%x,0x%x,0x%x,0x%x' % \
    2.28 +                                (s_dom, s_bus, s_slot, s_func)
    2.29 +                            # s has been assigned to other guest?
    2.30 +                            if xc.test_assign_device(0, s_pci_str) != 0:
    2.31 +                                err_msg = 'pci: %s must be co-assigned to the'+\
    2.32 +                                    ' same guest with %s'
    2.33 +                                raise VmError(err_msg % (s, dev.name))
    2.34  
    2.35          for (domain, bus, slot, func) in pci_dev_list:
    2.36              self.setupOneDevice(domain, bus, slot, func)