xend: allow pv_ops kernel driver pci-stub to hide devices for assignment

pciback is used by VT-d to hide device for assigment. But in pv-ops
dom0, pciback is not supported yet. Fortunately, pci-stub module is
used to hide device in Linux for KVM VT-d device assignment and it's
included in pv-ops dom0. So can use pci-stub to hide devices for
assignment.

Device must be hidden before assignment. Control panel has checks if
devices can be assigned or not, and can list assignable devices via
reading devices owned by pciback. This patch changes the checks, and
also list assignable devices which are owned by pci-stub. Use pci-stub
to hide devices, and use this patch to pass checkes in control panel,
device assignemnt with VT-d works on Xen with pv-ops dom0.

Signed-off-by: Weidong Han <weidong.han@intel.com>
This commit is contained in:
Keir Fraser committed 2009-07-06 11:48:44 +01:00
1 parent 26bfb945fc
commit 51dd9a1427
4 files changed
+29 -27

No files matched your search

+15 -3
View File
@@ -33,6 +33,7 @@ SYSFS_PCI_DEV_SUBVENDOR_PATH = '/subsystem_vendor'
SYSFS_PCI_DEV_SUBDEVICE_PATH = '/subsystem_device'
SYSFS_PCI_DEV_CLASS_PATH = '/class'
SYSFS_PCIBACK_PATH = '/bus/pci/drivers/pciback/'
SYSFS_PCISTUB_PATH = '/bus/pci/drivers/pci-stub/'
LSPCI_CMD = 'lspci'
@@ -450,7 +451,10 @@ def restore_pci_conf_space(pci_cfg_list):
os.write(fd, dw)
os.close(fd)
def find_all_devices_owned_by_pciback():
def find_all_assignable_devices():
''' devices owned by pcibak or pci-stub can be directly assigned to
guest with IOMMU (VT-d or AMD IOMMU), find all these devices.
'''
sysfs_mnt = find_sysfs_mnt()
pciback_path = sysfs_mnt + SYSFS_PCIBACK_PATH
pci_names = os.popen('ls ' + pciback_path).read()
@@ -459,6 +463,14 @@ def find_all_devices_owned_by_pciback():
for pci in pci_list:
dev = PciDevice(parse_pci_name(pci))
dev_list = dev_list + [dev]
pcistub_path = sysfs_mnt + SYSFS_PCISTUB_PATH
pci_names = os.popen('ls ' + pcistub_path).read()
pci_list = extract_the_exact_pci_names(pci_names)
for pci in pci_list:
dev = PciDevice(parse_pci_name(pci))
dev_list = dev_list + [dev]
return dev_list
def transform_list(target, src):
@@ -921,10 +933,10 @@ class PciDevice:
return
for pci_dev in devs:
dev = PciDevice(parse_pci_name(pci_dev))
if dev.driver == 'pciback':
if dev.driver == 'pciback' or dev.driver == 'pci-stub':
continue
err_msg = 'pci: %s must be co-assigned to the same guest with %s' + \
', but it is not owned by pciback.'
', but it is not owned by pciback or pci-stub.'
raise PciDeviceAssignmentError(err_msg % (pci_dev, self.name))
def do_FLR(self):
+1 -1
View File
@@ -716,7 +716,7 @@ class XendDomainInfo:
except Exception, e:
raise VmError("pci: failed to locate device and "+
"parse it's resources - "+str(e))
if pci_device.driver!='pciback':
if pci_device.driver!='pciback' and pci_device.driver!='pci-stub':
raise VmError(("pci: PCI Backend does not own device "+ \
"%s\n"+ \
"See the pciback.hide kernel "+ \
+1 -1
View File
@@ -835,7 +835,7 @@ class XendNode:
def pciinfo(self):
# Each element of dev_list is a PciDevice
dev_list = PciUtil.find_all_devices_owned_by_pciback()
dev_list = PciUtil.find_all_assignable_devices()
# Each element of devs_list is a list of PciDevice
devs_list = PciUtil.check_FLR_capability(dev_list)
+12 -22
View File
@@ -224,7 +224,7 @@ class PciController(DevController):
return sxpr
def CheckSiblingDevices(self, domid, dev):
""" Check if all sibling devices of dev are owned by pciback
""" Check if all sibling devices of dev are owned by pciback or pci-stub
"""
if not self.vm.info.is_hvm():
return
@@ -245,12 +245,9 @@ class PciController(DevController):
#no dom0 drivers bound to sdev
continue
if sdev.driver!='pciback':
raise VmError(("pci: PCI Backend does not own\n "+ \
"sibling device %s of device %s\n"+ \
"See the pciback.hide kernel "+ \
"command-line parameter or\n"+ \
"bind your slot/device to the PCI backend using sysfs" \
if sdev.driver!='pciback' and sdev.driver!='pci-stub':
raise VmError(("pci: PCI Backend and pci-stub don't\n "+ \
"own sibling device %s of device %s\n"\
)%(sdev.name, dev.name))
return
@@ -265,13 +262,9 @@ class PciController(DevController):
raise VmError("pci: failed to locate device and "+
"parse it's resources - "+str(e))
if dev.driver!='pciback':
raise VmError(("pci: PCI Backend does not own device "+ \
"%s\n"+ \
"See the pciback.hide kernel "+ \
"command-line parameter or\n"+ \
"bind your slot/device to the PCI backend using sysfs" \
)%(dev.name))
if dev.driver!='pciback' and dev.driver!='pci-stub':
raise VmError(("pci: PCI Backend and pci-stub don't own "+ \
"device %s\n") %(dev.name))
if dev.has_non_page_aligned_bar and arch.type != "ia64":
raise VmError("pci: %s: non-page-aligned MMIO BAR found." % dev.name)
@@ -285,7 +278,8 @@ class PciController(DevController):
# if arch.type != "ia64":
# dev.do_FLR()
PCIQuirk(dev)
if dev.driver == 'pciback':
PCIQuirk(dev)
if not self.vm.info.is_hvm():
# Setup IOMMU device assignment
@@ -437,13 +431,9 @@ class PciController(DevController):
raise VmError("pci: failed to locate device and "+
"parse it's resources - "+str(e))
if dev.driver!='pciback':
raise VmError(("pci: PCI Backend does not own device "+ \
"%s\n"+ \
"See the pciback.hide kernel "+ \
"command-line parameter or\n"+ \
"bind your slot/device to the PCI backend using sysfs" \
)%(dev.name))
if dev.driver!='pciback' and dev.driver!='pci-stub':
raise VmError(("pci: PCI Backend and pci-stub don't own device "+ \
"%s\n") %(dev.name))
# Need to do FLR here before deassign device in order to terminate
# DMA transaction, etc
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.