]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Support usb-serial and pci-serial on pSeries
authorAndrea Bolognani <abologna@redhat.com>
Fri, 10 Nov 2017 16:57:53 +0000 (17:57 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Tue, 28 Nov 2017 14:46:33 +0000 (15:46 +0100)
The existing implementation set the address type for all serial
devices to spapr-vio, which made it impossible to use other devices
such as usb-serial and pci-serial; moreover, some decisions were
made based on the address type rather than the device type.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1512934

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_domain_address.c
tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml [new file with mode: 0644]
tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml [new file with mode: 0644]
tests/qemuxml2xmltest.c

index fecf5ce5f2c86be28729abaa6575eee4fd4cb7bb..9a620dcdc20372737fa686b6b4ccac4db271b0f3 100644 (file)
@@ -9264,15 +9264,6 @@ static bool
 qemuChrIsPlatformDevice(const virDomainDef *def,
                         virDomainChrDefPtr chr)
 {
-    if ((def->os.arch == VIR_ARCH_PPC) || ARCH_IS_PPC64(def->os.arch)) {
-        if (!qemuDomainIsPSeries(def))
-            return true;
-        /* only pseries need -device spapr-vty with -chardev */
-        if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
-            chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO)
-            return true;
-    }
-
     if (def->os.arch == VIR_ARCH_ARMV7L || def->os.arch == VIR_ARCH_AARCH64) {
         /* TARGET_TYPE_ISA here really means 'the default platform device' */
         if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
index 2319e503eb481d5187ff8cc243405a8e630211e7..f62bb2f97e2e6d16f8c348bf1bd8a3d25ab16725 100644 (file)
@@ -246,8 +246,9 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
 
     for (i = 0; i < def->nserials; i++) {
         if (def->serials[i]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
-            qemuDomainIsPSeries(def))
+            def->serials[i]->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO) {
             def->serials[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
+        }
         if (qemuDomainAssignSpaprVIOAddress(def, &def->serials[i]->info,
                                             VIO_ADDR_SERIAL) < 0)
             goto cleanup;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.args
new file mode 100644 (file)
index 0000000..eb2a9bf
--- /dev/null
@@ -0,0 +1,22 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-ppc64 \
+-name guest \
+-S \
+-M pseries \
+-m 512 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
+-nographic \
+-nodefconfig \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline \
+-boot c \
+-chardev pty,id=charserial0 \
+-device pci-serial,chardev=charserial0,id=serial0,bus=pci.0,addr=0x1
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-pci.xml
new file mode 100644 (file)
index 0000000..2c2534b
--- /dev/null
@@ -0,0 +1,18 @@
+<domain type='qemu'>
+  <name>guest</name>
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
+  <memory unit='KiB'>524288</memory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='ppc64' machine='pseries'>hvm</type>
+  </os>
+  <devices>
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
+    <controller type='usb' model='none'/>
+    <!-- This will be assigned a PCI address -->
+    <serial type='pty'>
+      <target type='pci-serial'/>
+    </serial>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.args
new file mode 100644 (file)
index 0000000..0403985
--- /dev/null
@@ -0,0 +1,23 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-ppc64 \
+-name guest \
+-S \
+-M pseries \
+-m 512 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
+-nographic \
+-nodefconfig \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-guest/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline \
+-boot c \
+-device qemu-xhci,id=usb,bus=pci.0,addr=0x1 \
+-chardev pty,id=charserial0 \
+-device usb-serial,chardev=charserial0,id=serial0,bus=usb.0,port=1
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-serial-usb.xml
new file mode 100644 (file)
index 0000000..734c90c
--- /dev/null
@@ -0,0 +1,21 @@
+<domain type='qemu'>
+  <name>guest</name>
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
+  <memory unit='KiB'>524288</memory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='ppc64' machine='pseries'>hvm</type>
+  </os>
+  <devices>
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
+    <controller type='usb' model='qemu-xhci'/>
+    <!-- This should be assigned a USB address. You'll not be able to find it
+         in the file generated by qemuxml2xmltest due to limitations in the
+         test suite, but it will be there when actually running libvirt;
+         moreover, the USB address will be present in the .args file -->
+    <serial type='pty'>
+      <target type='usb-serial'/>
+    </serial>
+    <memballoon model='none'/>
+  </devices>
+</domain>
index 5827a47e55576bbcd4c90403ee7787a4d3c63ae1..0ba23d07039b60504ff90a08cc45347118e685cf 100644 (file)
@@ -1886,6 +1886,13 @@ mymain(void)
     DO_TEST("pseries-serial-compat",
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_VTY);
+    DO_TEST("pseries-serial-pci",
+            QEMU_CAPS_NODEFCONFIG,
+            QEMU_CAPS_DEVICE_PCI_SERIAL);
+    DO_TEST("pseries-serial-usb",
+            QEMU_CAPS_NODEFCONFIG,
+            QEMU_CAPS_DEVICE_QEMU_XHCI,
+            QEMU_CAPS_DEVICE_USB_SERIAL);
     DO_TEST("pseries-console-native",
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_VTY);
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-pci.xml
new file mode 100644 (file)
index 0000000..cba7ea9
--- /dev/null
@@ -0,0 +1,31 @@
+<domain type='qemu'>
+  <name>guest</name>
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
+  <memory unit='KiB'>524288</memory>
+  <currentMemory unit='KiB'>524288</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='ppc64' machine='pseries'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
+    <controller type='usb' index='0' model='none'/>
+    <controller type='pci' index='0' model='pci-root'>
+      <model name='spapr-pci-host-bridge'/>
+      <target index='0'/>
+    </controller>
+    <serial type='pty'>
+      <target type='pci-serial' port='0'>
+        <model name='pci-serial'/>
+      </target>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </serial>
+    <memballoon model='none'/>
+    <panic model='pseries'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-serial-usb.xml
new file mode 100644 (file)
index 0000000..34f6513
--- /dev/null
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+  <name>guest</name>
+  <uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
+  <memory unit='KiB'>524288</memory>
+  <currentMemory unit='KiB'>524288</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='ppc64' machine='pseries'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
+    <controller type='usb' index='0' model='qemu-xhci'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'>
+      <model name='spapr-pci-host-bridge'/>
+      <target index='0'/>
+    </controller>
+    <serial type='pty'>
+      <target type='usb-serial' port='0'>
+        <model name='usb-serial'/>
+      </target>
+    </serial>
+    <memballoon model='none'/>
+    <panic model='pseries'/>
+  </devices>
+</domain>
index 4318ae5036d8eb1dd9bea50e07613b03153f2e9a..45cb739cd2b607ab717429258709132c1a9694e8 100644 (file)
@@ -777,6 +777,13 @@ mymain(void)
     DO_TEST("pseries-serial-compat",
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_VTY);
+    DO_TEST("pseries-serial-pci",
+            QEMU_CAPS_NODEFCONFIG,
+            QEMU_CAPS_DEVICE_PCI_SERIAL);
+    DO_TEST("pseries-serial-usb",
+            QEMU_CAPS_NODEFCONFIG,
+            QEMU_CAPS_DEVICE_QEMU_XHCI,
+            QEMU_CAPS_DEVICE_USB_SERIAL);
     DO_TEST("pseries-console-native",
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_VTY);