Reviewed-by: Daniel Barboza <dhbarboza82(a)gmail.com>
On 07/08/2015 02:42 PM, Jose Ricardo Ziviani wrote:
- 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 | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/src/kimchi/model/vmhostdevs.py b/src/kimchi/model/vmhostdevs.py
index ea75fce..186e542 100644
--- a/src/kimchi/model/vmhostdevs.py
+++ b/src/kimchi/model/vmhostdevs.py
@@ -171,6 +171,26 @@ class VMHostDevsModel(object):
if rc != 0:
kimchi_log.warning("Unable to turn on sebool
virt_use_sysfs")
+ def _have_xhci_usb_controller(self, xmlstr):
+ root = objectify.fromstring(xmlstr)
+
+ 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 +200,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(dom.XMLDesc(0)):
+ 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)