Blame SOURCES/libvirt-qemu-use-qemu-xhci-USB-controller-by-default-for-ppc64-and-aarch64.patch

3e5111
From 5af922119074c1a74db6bebb272b6b9758c89c63 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <5af922119074c1a74db6bebb272b6b9758c89c63@dist-git>
3e5111
From: Pavel Hrdina <phrdina@redhat.com>
3e5111
Date: Fri, 28 Apr 2017 11:59:51 +0200
3e5111
Subject: [PATCH] qemu: use qemu-xhci USB controller by default for ppc64 and
3e5111
 aarch64
3e5111
3e5111
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1438682
3e5111
3e5111
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
3e5111
Acked-by: Andrea Bolognani <abologna@redhat.com>
3e5111
(cherry picked from commit 568887a32f9985b95d998dd0d675255ea985013f)
3e5111
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_domain.c                                | 11 ++++++++---
3e5111
 ...qemuxml2argv-aarch64-usb-controller-qemu-xhci.args | 19 +++++++++++++++++++
3e5111
 .../qemuxml2argv-aarch64-usb-controller-qemu-xhci.xml | 16 ++++++++++++++++
3e5111
 .../qemuxml2argv-ppc64-usb-controller-qemu-xhci.args  | 19 +++++++++++++++++++
3e5111
 .../qemuxml2argv-ppc64-usb-controller-qemu-xhci.xml   |  1 +
3e5111
 tests/qemuxml2argvtest.c                              |  9 +++++++++
3e5111
 6 files changed, 72 insertions(+), 3 deletions(-)
3e5111
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.args
3e5111
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.xml
3e5111
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.args
3e5111
 create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.xml
3e5111
3e5111
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
3e5111
index 4d7de60cb..2790d7e74 100644
3e5111
--- a/src/qemu/qemu_domain.c
3e5111
+++ b/src/qemu/qemu_domain.c
3e5111
@@ -3237,9 +3237,12 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
3e5111
             } else if (ARCH_IS_PPC64(def->os.arch)) {
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
+                 * The nec-usb-xhci or qemu-xhci controller is used as default
3e5111
+                 * only for newly defined domains or devices. */
3e5111
                 if ((parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE) &&
3e5111
+                    virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI)) {
3e5111
+                    cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
3e5111
+                } else 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
@@ -3249,7 +3252,9 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
3e5111
                     cont->model = -1;
3e5111
                 }
3e5111
             } else if (def->os.arch == VIR_ARCH_AARCH64) {
3e5111
-                if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI))
3e5111
+                if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI))
3e5111
+                    cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
3e5111
+                else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI))
3e5111
                     cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI;
3e5111
             }
3e5111
         }
3e5111
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.args
3e5111
new file mode 100644
3e5111
index 000000000..0aa27f7ab
3e5111
--- /dev/null
3e5111
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.args
3e5111
@@ -0,0 +1,19 @@
3e5111
+LC_ALL=C \
3e5111
+PATH=/bin \
3e5111
+HOME=/home/test \
3e5111
+USER=test \
3e5111
+LOGNAME=test \
3e5111
+QEMU_AUDIO_DRV=none \
3e5111
+/usr/bin/qemu-system-aarch64 \
3e5111
+-name QEMUGuest1 \
3e5111
+-S \
3e5111
+-M virt \
3e5111
+-m 214 \
3e5111
+-smp 1,sockets=1,cores=1,threads=1 \
3e5111
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
3e5111
+-nographic \
3e5111
+-nodefaults \
3e5111
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
3e5111
+-no-acpi \
3e5111
+-boot c \
3e5111
+-device qemu-xhci,id=usb,bus=pcie.0,addr=0x1
3e5111
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.xml
3e5111
new file mode 100644
3e5111
index 000000000..1b7320f43
3e5111
--- /dev/null
3e5111
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-usb-controller-qemu-xhci.xml
3e5111
@@ -0,0 +1,16 @@
3e5111
+<domain type='qemu'>
3e5111
+  <name>QEMUGuest1</name>
3e5111
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
3e5111
+  <memory unit='KiB'>219100</memory>
3e5111
+  <vcpu placement='static'>1</vcpu>
3e5111
+  <os>
3e5111
+    <type arch='aarch64' machine='virt'>hvm</type>
3e5111
+  </os>
3e5111
+  <devices>
3e5111
+    <emulator>/usr/bin/qemu-system-aarch64</emulator>
3e5111
+    <controller type='usb' index='0'>
3e5111
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
3e5111
+    </controller>
3e5111
+    <memballoon model='none'/>
3e5111
+  </devices>
3e5111
+</domain>
3e5111
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.args b/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.args
3e5111
new file mode 100644
3e5111
index 000000000..b34e480dd
3e5111
--- /dev/null
3e5111
+++ b/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.args
3e5111
@@ -0,0 +1,19 @@
3e5111
+LC_ALL=C \
3e5111
+PATH=/bin \
3e5111
+HOME=/home/test \
3e5111
+USER=test \
3e5111
+LOGNAME=test \
3e5111
+QEMU_AUDIO_DRV=none \
3e5111
+/usr/libexec/qemu-system-ppc64 \
3e5111
+-name QEMUGuest1 \
3e5111
+-S \
3e5111
+-M pseries \
3e5111
+-m 256 \
3e5111
+-smp 1,sockets=1,cores=1,threads=1 \
3e5111
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
3e5111
+-nographic \
3e5111
+-nodefaults \
3e5111
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
3e5111
+-boot c \
3e5111
+-device qemu-xhci,id=usb,bus=pci.0,addr=0x1 \
3e5111
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
3e5111
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.xml b/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.xml
3e5111
new file mode 120000
3e5111
index 000000000..831d9d4f1
3e5111
--- /dev/null
3e5111
+++ b/tests/qemuxml2argvdata/qemuxml2argv-ppc64-usb-controller-qemu-xhci.xml
3e5111
@@ -0,0 +1 @@
3e5111
+qemuxml2argv-ppc64-usb-controller.xml
3e5111
\ No newline at end of file
3e5111
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
3e5111
index 317f17e74..406fbfea4 100644
3e5111
--- a/tests/qemuxml2argvtest.c
3e5111
+++ b/tests/qemuxml2argvtest.c
3e5111
@@ -2480,6 +2480,15 @@ mymain(void)
3e5111
             QEMU_CAPS_PCI_OHCI);
3e5111
     DO_TEST("ppc64-usb-controller-legacy",
3e5111
             QEMU_CAPS_PIIX3_USB_UHCI);
3e5111
+    DO_TEST_FULL("ppc64-usb-controller-qemu-xhci", NULL, -1, 0,
3e5111
+                 VIR_DOMAIN_DEF_PARSE_ABI_UPDATE, GIC_NONE,
3e5111
+                 QEMU_CAPS_NEC_USB_XHCI,
3e5111
+                 QEMU_CAPS_DEVICE_QEMU_XHCI);
3e5111
+
3e5111
+    DO_TEST("aarch64-usb-controller-qemu-xhci",
3e5111
+            QEMU_CAPS_OBJECT_GPEX,
3e5111
+            QEMU_CAPS_NEC_USB_XHCI,
3e5111
+            QEMU_CAPS_DEVICE_QEMU_XHCI);
3e5111
 
3e5111
     DO_TEST("aarch64-usb-controller-nec-xhci",
3e5111
             QEMU_CAPS_OBJECT_GPEX,
3e5111
-- 
3e5111
2.12.2
3e5111