mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
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>
This commit is contained in:
1 parent
3b35911d70
commit
44d374adc0
3 files changed
+11
-5
No files matched your search
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||