- Today it is not possible to hotplug a PCI in Power Systems without an
USB xhci controller existing in the VM. This commit checks if there
is such controller in the VM, displaying an error message if not.
Signed-off-by: Jose Ricardo Ziviani <joserz(a)linux.vnet.ibm.com>
---
src/kimchi/model/vmhostdevs.py | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/kimchi/model/vmhostdevs.py b/src/kimchi/model/vmhostdevs.py
index ea75fce..12226ca 100644
--- a/src/kimchi/model/vmhostdevs.py
+++ b/src/kimchi/model/vmhostdevs.py
@@ -171,6 +171,28 @@ class VMHostDevsModel(object):
if rc != 0:
kimchi_log.warning("Unable to turn on sebool virt_use_sysfs")
+ def have_xhci_usb_controller(self, vmid):
+ dom = VMModel.get_vm(vmid, self.conn)
+
+ root = objectify.fromstring(dom.XMLDesc(0))
+
+ try:
+ controllers = root.devices.controller
+
+ except AttributeError:
+ return False
+
+ for controller in controllers:
+
+ if 'model' not in controller.attrib:
+ continue
+
+ if controller.attrib['type'] == 'usb' and \
+ controller.attrib['model'] == 'nec-xhci':
+ return True
+
+ return False
+
def _attach_pci_device(self, vmid, dev_info):
self._validate_pci_passthrough_env()
@@ -180,11 +202,17 @@ class VMHostDevsModel(object):
driver = ('vfio' if DOM_STATE_MAP[dom.info()[0]] == "shutoff"
and
self.caps.kernel_vfio else 'kvm')
- # on powerkvm systems it must be vfio driver.
distro, _, _ = platform.linux_distribution()
if distro == 'IBM_PowerKVM':
+ # on powerkvm systems, the driver must be vfio.
driver = 'vfio'
+ # powerkvm requires a xhci usb controller in order to support
+ # pci hotplug.
+ if DOM_STATE_MAP[dom.info()[0]] != "shutoff" and \
+ not self.have_xhci_usb_controller(vmid):
+ raise InvalidOperation("KCHVMHDEV0006E", {'vmid':
vmid})
+
# Attach all PCI devices in the same IOMMU group
dev_model = DeviceModel(conn=self.conn)
devs_model = DevicesModel(conn=self.conn)
--
1.9.1