3e5111
From 48c13aa1bbd505a96af170d9efe0e0540efd5b59 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <48c13aa1bbd505a96af170d9efe0e0540efd5b59@dist-git>
3e5111
From: Pavel Hrdina <phrdina@redhat.com>
3e5111
Date: Thu, 20 Apr 2017 09:16:21 +0200
3e5111
Subject: [PATCH] qemu_domain: use correct default USB controller on ppc64
3e5111
3e5111
The history of USB controller for ppc64 guest is complex and goes
3e5111
back to libvirt 1.3.1 where the fun started.
3e5111
3e5111
Prior Libvirt 1.3.1 if no model for USB controller was specified
3e5111
we've simply passed "-usb" on QEMU command line.
3e5111
3e5111
Since Libvirt 1.3.1 there is a patch (8156493d8db) that fixes this
3e5111
issue by using "-device pci-ohci,..." but it breaks migration with
3e5111
older Libvirts which was agreed that's acceptable.  However this
3e5111
patch didn't reflect this change in the domain XML and the model
3e5111
was still missing.
3e5111
3e5111
Since Libvirt 2.2.0 there is a patch (f55eaccb0c5) that fixes the
3e5111
issue with not setting the USB model into domain XML which we need
3e5111
to know about to not break the migration and since the default
3e5111
model was *pci-ohci* it was used as default in this patch as well.
3e5111
3e5111
This patch tries to take all the previous changes into account and
3e5111
also change the default for newly defined domains that don't specify
3e5111
any model for USB controller.
3e5111
3e5111
The VIR_DOMAIN_DEF_PARSE_ABI_UPDATE is set only if new domain is
3e5111
defined or new device is added into a domain which means that in
3e5111
all other cases we will use the old *pci-ohci* model instead of the
3e5111
better and not broken *nec-usb-xhci* model.
3e5111
3e5111
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1373184
3e5111
3e5111
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
3e5111
(cherry picked from commit 90acbc76ece8b94cfd5e5d2ebb675f7692ce7afd)
3e5111
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_domain.c | 16 ++++++++++++----
3e5111
 1 file changed, 12 insertions(+), 4 deletions(-)
3e5111
3e5111
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
3e5111
index 3150e8760..c43ff3d63 100644
3e5111
--- a/src/qemu/qemu_domain.c
3e5111
+++ b/src/qemu/qemu_domain.c
3e5111
@@ -3110,7 +3110,8 @@ qemuDomainShmemDefPostParse(virDomainShmemDefPtr shm)
3e5111
 static int
3e5111
 qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
3e5111
                                  const virDomainDef *def,
3e5111
-                                 virQEMUCapsPtr qemuCaps)
3e5111
+                                 virQEMUCapsPtr qemuCaps,
3e5111
+                                 unsigned int parseFlags)
3e5111
 {
3e5111
     switch ((virDomainControllerType)cont->type) {
3e5111
     case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
3e5111
@@ -3138,9 +3139,16 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
3e5111
                  * address is found */
3e5111
                 cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE;
3e5111
             } else if (ARCH_IS_PPC64(def->os.arch)) {
3e5111
-                /* Default USB controller for ppc64 is pci-ohci */
3e5111
-                if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI))
3e5111
+                /* To not break migration we need to set default USB controller
3e5111
+                 * for ppc64 to pci-ohci if we cannot change ABI of the VM.
3e5111
+                 * The nec-usb-xhci controller is used as default only for
3e5111
+                 * newly defined domains or devices. */
3e5111
+                if ((parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE) &&
3e5111
+                    virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI)) {
3e5111
+                    cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI;
3e5111
+                } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI)) {
3e5111
                     cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
3e5111
+                }
3e5111
             } else {
3e5111
                 /* Default USB controller for anything else is piix3-uhci */
3e5111
                 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI))
3e5111
@@ -3339,7 +3347,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
3e5111
 
3e5111
     if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER &&
3e5111
         qemuDomainControllerDefPostParse(dev->data.controller, def,
3e5111
-                                         qemuCaps) < 0)
3e5111
+                                         qemuCaps, parseFlags) < 0)
3e5111
         goto cleanup;
3e5111
 
3e5111
     if (dev->type == VIR_DOMAIN_DEVICE_SHMEM &&
3e5111
-- 
3e5111
2.12.2
3e5111