render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
404507
From 6c6f469f08a2fd5d61d91bf0488ade5ef0033f2d Mon Sep 17 00:00:00 2001
404507
Message-Id: <6c6f469f08a2fd5d61d91bf0488ade5ef0033f2d@dist-git>
404507
From: Andrea Bolognani <abologna@redhat.com>
404507
Date: Wed, 29 Nov 2017 16:23:13 +0100
404507
Subject: [PATCH] qemu: Support usb-serial and pci-serial on pSeries
404507
404507
The existing implementation set the address type for all serial
404507
devices to spapr-vio, which made it impossible to use other devices
404507
such as usb-serial and pci-serial; moreover, some decisions were
404507
made based on the address type rather than the device type.
404507
404507
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1512934
404507
404507
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
404507
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
404507
(cherry picked from commit b342e94399eee7fd519234a12ca3ea04f6564154)
404507
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
404507
---
404507
 src/qemu/qemu_command.c                            |  9 ------
404507
 src/qemu/qemu_domain_address.c                     |  3 +-
404507
 .../qemuxml2argv-pseries-serial-pci.args           | 22 +++++++++++++++
404507
 .../qemuxml2argv-pseries-serial-pci.xml            | 18 ++++++++++++
404507
 .../qemuxml2argv-pseries-serial-usb.args           | 23 ++++++++++++++++
404507
 .../qemuxml2argv-pseries-serial-usb.xml            | 21 ++++++++++++++
404507
 tests/qemuxml2argvtest.c                           |  7 +++++
404507
 .../qemuxml2xmlout-pseries-serial-pci.xml          | 31 +++++++++++++++++++++
404507
 .../qemuxml2xmlout-pseries-serial-usb.xml          | 32 ++++++++++++++++++++++
404507
 tests/qemuxml2xmltest.c                            |  7 +++++
404507
 10 files changed, 163 insertions(+), 10 deletions(-)
404507
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args
404507
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml
404507
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args
404507
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml
404507
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml
404507
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml
404507
404507
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
404507
index 91083dc73d..056dafea39 100644
404507
--- a/src/qemu/qemu_command.c
404507
+++ b/src/qemu/qemu_command.c
404507
@@ -9260,15 +9260,6 @@ static bool
404507
 qemuChrIsPlatformDevice(const virDomainDef *def,
404507
                         virDomainChrDefPtr chr)
404507
 {
404507
-    if ((def->os.arch == VIR_ARCH_PPC) || ARCH_IS_PPC64(def->os.arch)) {
404507
-        if (!qemuDomainIsPSeries(def))
404507
-            return true;
404507
-        /* only pseries need -device spapr-vty with -chardev */
404507
-        if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
404507
-            chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO)
404507
-            return true;
404507
-    }
404507
-
404507
     if (def->os.arch == VIR_ARCH_ARMV7L || def->os.arch == VIR_ARCH_AARCH64) {
404507
         /* TARGET_TYPE_ISA here really means 'the default platform device' */
404507
         if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
404507
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
404507
index 2319e503eb..f62bb2f97e 100644
404507
--- a/src/qemu/qemu_domain_address.c
404507
+++ b/src/qemu/qemu_domain_address.c
404507
@@ -246,8 +246,9 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
404507
 
404507
     for (i = 0; i < def->nserials; i++) {
404507
         if (def->serials[i]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
404507
-            qemuDomainIsPSeries(def))
404507
+            def->serials[i]->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO) {
404507
             def->serials[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
404507
+        }
404507
         if (qemuDomainAssignSpaprVIOAddress(def, &def->serials[i]->info,
404507
                                             VIO_ADDR_SERIAL) < 0)
404507
             goto cleanup;
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args
404507
new file mode 100644
404507
index 0000000000..eb2a9bf0e0
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args
404507
@@ -0,0 +1,22 @@
404507
+LC_ALL=C \
404507
+PATH=/bin \
404507
+HOME=/home/test \
404507
+USER=test \
404507
+LOGNAME=test \
404507
+QEMU_AUDIO_DRV=none \
404507
+/usr/bin/qemu-system-ppc64 \
404507
+-name guest \
404507
+-S \
404507
+-M pseries \
404507
+-m 512 \
404507
+-smp 1,sockets=1,cores=1,threads=1 \
404507
+-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
404507
+-nographic \
404507
+-nodefconfig \
404507
+-nodefaults \
404507
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
404507
+server,nowait \
404507
+-mon chardev=charmonitor,id=monitor,mode=readline \
404507
+-boot c \
404507
+-chardev pty,id=charserial0 \
404507
+-device pci-serial,chardev=charserial0,id=serial0,bus=pci.0,addr=0x1
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml
404507
new file mode 100644
404507
index 0000000000..2c2534b4c2
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml
404507
@@ -0,0 +1,18 @@
404507
+<domain type='qemu'>
404507
+  <name>guest</name>
404507
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
404507
+  <memory unit='KiB'>524288</memory>
404507
+  <vcpu placement='static'>1</vcpu>
404507
+  <os>
404507
+    <type arch='ppc64' machine='pseries'>hvm</type>
404507
+  </os>
404507
+  <devices>
404507
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
404507
+    <controller type='usb' model='none'/>
404507
+    
404507
+    <serial type='pty'>
404507
+      <target type='pci-serial'/>
404507
+    </serial>
404507
+    <memballoon model='none'/>
404507
+  </devices>
404507
+</domain>
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args
404507
new file mode 100644
404507
index 0000000000..0403985dc4
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args
404507
@@ -0,0 +1,23 @@
404507
+LC_ALL=C \
404507
+PATH=/bin \
404507
+HOME=/home/test \
404507
+USER=test \
404507
+LOGNAME=test \
404507
+QEMU_AUDIO_DRV=none \
404507
+/usr/bin/qemu-system-ppc64 \
404507
+-name guest \
404507
+-S \
404507
+-M pseries \
404507
+-m 512 \
404507
+-smp 1,sockets=1,cores=1,threads=1 \
404507
+-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
404507
+-nographic \
404507
+-nodefconfig \
404507
+-nodefaults \
404507
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
404507
+server,nowait \
404507
+-mon chardev=charmonitor,id=monitor,mode=readline \
404507
+-boot c \
404507
+-device qemu-xhci,id=usb,bus=pci.0,addr=0x1 \
404507
+-chardev pty,id=charserial0 \
404507
+-device usb-serial,chardev=charserial0,id=serial0,bus=usb.0,port=1
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml
404507
new file mode 100644
404507
index 0000000000..734c90c66f
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml
404507
@@ -0,0 +1,21 @@
404507
+<domain type='qemu'>
404507
+  <name>guest</name>
404507
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
404507
+  <memory unit='KiB'>524288</memory>
404507
+  <vcpu placement='static'>1</vcpu>
404507
+  <os>
404507
+    <type arch='ppc64' machine='pseries'>hvm</type>
404507
+  </os>
404507
+  <devices>
404507
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
404507
+    <controller type='usb' model='qemu-xhci'/>
404507
+    
404507
+         in the file generated by qemuxml2xmltest due to limitations in the
404507
+         test suite, but it will be there when actually running libvirt;
404507
+         moreover, the USB address will be present in the .args file -->
404507
+    <serial type='pty'>
404507
+      <target type='usb-serial'/>
404507
+    </serial>
404507
+    <memballoon model='none'/>
404507
+  </devices>
404507
+</domain>
404507
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
404507
index 4b63dd141d..2b3bbd1b8b 100644
404507
--- a/tests/qemuxml2argvtest.c
404507
+++ b/tests/qemuxml2argvtest.c
404507
@@ -1884,6 +1884,13 @@ mymain(void)
404507
     DO_TEST("pseries-serial-compat",
404507
             QEMU_CAPS_NODEFCONFIG,
404507
             QEMU_CAPS_DEVICE_SPAPR_VTY);
404507
+    DO_TEST("pseries-serial-pci",
404507
+            QEMU_CAPS_NODEFCONFIG,
404507
+            QEMU_CAPS_DEVICE_PCI_SERIAL);
404507
+    DO_TEST("pseries-serial-usb",
404507
+            QEMU_CAPS_NODEFCONFIG,
404507
+            QEMU_CAPS_DEVICE_QEMU_XHCI,
404507
+            QEMU_CAPS_DEVICE_USB_SERIAL);
404507
     DO_TEST("pseries-console-native",
404507
             QEMU_CAPS_NODEFCONFIG,
404507
             QEMU_CAPS_DEVICE_SPAPR_VTY);
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml
404507
new file mode 100644
404507
index 0000000000..cba7ea96bb
404507
--- /dev/null
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml
404507
@@ -0,0 +1,31 @@
404507
+<domain type='qemu'>
404507
+  <name>guest</name>
404507
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
404507
+  <memory unit='KiB'>524288</memory>
404507
+  <currentMemory unit='KiB'>524288</currentMemory>
404507
+  <vcpu placement='static'>1</vcpu>
404507
+  <os>
404507
+    <type arch='ppc64' machine='pseries'>hvm</type>
404507
+    <boot dev='hd'/>
404507
+  </os>
404507
+  <clock offset='utc'/>
404507
+  <on_poweroff>destroy</on_poweroff>
404507
+  <on_reboot>restart</on_reboot>
404507
+  <on_crash>destroy</on_crash>
404507
+  <devices>
404507
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
404507
+    <controller type='usb' index='0' model='none'/>
404507
+    <controller type='pci' index='0' model='pci-root'>
404507
+      <model name='spapr-pci-host-bridge'/>
404507
+      <target index='0'/>
404507
+    </controller>
404507
+    <serial type='pty'>
404507
+      <target type='pci-serial' port='0'>
404507
+        <model name='pci-serial'/>
404507
+      </target>
404507
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
404507
+    </serial>
404507
+    <memballoon model='none'/>
404507
+    <panic model='pseries'/>
404507
+  </devices>
404507
+</domain>
404507
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml
404507
new file mode 100644
404507
index 0000000000..34f651308d
404507
--- /dev/null
404507
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml
404507
@@ -0,0 +1,32 @@
404507
+<domain type='qemu'>
404507
+  <name>guest</name>
404507
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
404507
+  <memory unit='KiB'>524288</memory>
404507
+  <currentMemory unit='KiB'>524288</currentMemory>
404507
+  <vcpu placement='static'>1</vcpu>
404507
+  <os>
404507
+    <type arch='ppc64' machine='pseries'>hvm</type>
404507
+    <boot dev='hd'/>
404507
+  </os>
404507
+  <clock offset='utc'/>
404507
+  <on_poweroff>destroy</on_poweroff>
404507
+  <on_reboot>restart</on_reboot>
404507
+  <on_crash>destroy</on_crash>
404507
+  <devices>
404507
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
404507
+    <controller type='usb' index='0' model='qemu-xhci'>
404507
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
404507
+    </controller>
404507
+    <controller type='pci' index='0' model='pci-root'>
404507
+      <model name='spapr-pci-host-bridge'/>
404507
+      <target index='0'/>
404507
+    </controller>
404507
+    <serial type='pty'>
404507
+      <target type='usb-serial' port='0'>
404507
+        <model name='usb-serial'/>
404507
+      </target>
404507
+    </serial>
404507
+    <memballoon model='none'/>
404507
+    <panic model='pseries'/>
404507
+  </devices>
404507
+</domain>
404507
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
404507
index ad429ead4d..f76bd5a68d 100644
404507
--- a/tests/qemuxml2xmltest.c
404507
+++ b/tests/qemuxml2xmltest.c
404507
@@ -775,6 +775,13 @@ mymain(void)
404507
     DO_TEST("pseries-serial-compat",
404507
             QEMU_CAPS_NODEFCONFIG,
404507
             QEMU_CAPS_DEVICE_SPAPR_VTY);
404507
+    DO_TEST("pseries-serial-pci",
404507
+            QEMU_CAPS_NODEFCONFIG,
404507
+            QEMU_CAPS_DEVICE_PCI_SERIAL);
404507
+    DO_TEST("pseries-serial-usb",
404507
+            QEMU_CAPS_NODEFCONFIG,
404507
+            QEMU_CAPS_DEVICE_QEMU_XHCI,
404507
+            QEMU_CAPS_DEVICE_USB_SERIAL);
404507
     DO_TEST("pseries-console-native",
404507
             QEMU_CAPS_NODEFCONFIG,
404507
             QEMU_CAPS_DEVICE_SPAPR_VTY);
404507
-- 
404507
2.15.1
404507