]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Add support for virtio input ccw devices
authorFarhan Ali <alifm@linux.vnet.ibm.com>
Fri, 23 Mar 2018 17:22:42 +0000 (13:22 -0400)
committerJán Tomko <jtomko@redhat.com>
Fri, 23 Mar 2018 18:40:20 +0000 (19:40 +0100)
QEMU on S390 (since v2.11) can support virtio input ccw devices.
So build the qemu command line for ccw devices.

Also add test cases for virtio-{keyboard, mouse, tablet}-ccw.

Signed-off-by: Farhan Ali <alifm@linux.vnet.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
docs/formatdomain.html.in
src/qemu/qemu_command.c
tests/qemuxml2argvdata/input-virtio-ccw.args [new file with mode: 0644]
tests/qemuxml2argvdata/input-virtio-ccw.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/input-virtio-ccw.xml [new file with mode: 0644]
tests/qemuxml2xmltest.c

index 0908709813f011e5942fba23d8eb9b4690c429ae..08dc74b6b9c99c750f1c09c885f4ce25b18f74cc 100644 (file)
@@ -6048,6 +6048,8 @@ qemu-kvm -net nic,model=? /dev/null
       sub-element <code>&lt;address&gt;</code> which can tie the
       device to a particular PCI
       slot, <a href="#elementsAddress">documented above</a>.
+      On S390, <code>address</code> can be used to provide a CCW address for
+      an input device (<span class="since">since 4.2.0</span>).
 
       For type <code>passthrough</code>, the mandatory sub-element <code>source</code>
       must have an <code>evdev</code> attribute containing the absolute path to the
index 314f175deff63ea595cbca46262647d295c8a585..89fd08b6429a06361d58409b45717319a90baa6f 100644 (file)
@@ -3955,6 +3955,8 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def,
 
     if (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
         suffix = "-pci";
+    } else if (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
+        suffix = "-ccw";
     } else if (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO) {
         suffix = "-device";
     } else {
@@ -3966,7 +3968,9 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def,
 
     switch ((virDomainInputType) dev->type) {
     case VIR_DOMAIN_INPUT_TYPE_MOUSE:
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_MOUSE)) {
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_MOUSE) ||
+            (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
+             !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW))) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("virtio-mouse is not supported by this QEMU binary"));
             goto error;
@@ -3974,7 +3978,9 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def,
         virBufferAsprintf(&buf, "virtio-mouse%s,id=%s", suffix, dev->info.alias);
         break;
     case VIR_DOMAIN_INPUT_TYPE_TABLET:
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_TABLET)) {
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_TABLET) ||
+            (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
+             !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW))) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("virtio-tablet is not supported by this QEMU binary"));
             goto error;
@@ -3982,7 +3988,9 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def,
         virBufferAsprintf(&buf, "virtio-tablet%s,id=%s", suffix, dev->info.alias);
         break;
     case VIR_DOMAIN_INPUT_TYPE_KBD:
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_KEYBOARD)) {
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_KEYBOARD) ||
+            (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
+             !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_KEYBOARD_CCW))) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("virtio-keyboard is not supported by this QEMU binary"));
             goto error;
diff --git a/tests/qemuxml2argvdata/input-virtio-ccw.args b/tests/qemuxml2argvdata/input-virtio-ccw.args
new file mode 100644 (file)
index 0000000..6ee318c
--- /dev/null
@@ -0,0 +1,26 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-s390x \
+-name QEMUGuest1 \
+-S \
+-M s390-ccw-virtio \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1803 \
+-nographic \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline \
+-boot c \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
+-device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
+id=virtio-disk0 \
+-device virtio-keyboard-ccw,id=input0,devno=fe.0.0002 \
+-device virtio-mouse-ccw,id=input1,devno=fe.0.0003 \
+-device virtio-tablet-ccw,id=input2,devno=fe.0.0004 \
+-device virtio-balloon-ccw,id=balloon0,devno=fe.0.0001
diff --git a/tests/qemuxml2argvdata/input-virtio-ccw.xml b/tests/qemuxml2argvdata/input-virtio-ccw.xml
new file mode 100644 (file)
index 0000000..a971662
--- /dev/null
@@ -0,0 +1,29 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1803</uuid>
+  <memory>219136</memory>
+  <currentMemory>219136</currentMemory>
+  <vcpu>1</vcpu>
+  <os>
+    <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+  </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-s390x</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='virtio'/>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0'/>
+    </disk>
+    <memballoon model='virtio'>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x1'/>
+    </memballoon>
+    <input type='keyboard' bus='virtio'/>
+    <input type='mouse' bus='virtio'/>
+    <input type='tablet' bus='virtio'/>
+    <panic model='s390'/>
+  </devices>
+</domain>
index e86939d8b37f605e04a2ec130ae63746d2afdcf3..308d71f725473323789444f8d60cff58b1a6c9a8 100644 (file)
@@ -3015,6 +3015,14 @@ mymain(void)
             QEMU_CAPS_VNC,
             QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW);
 
+    DO_TEST("input-virtio-ccw", QEMU_CAPS_VIRTIO_CCW,
+            QEMU_CAPS_VIRTIO_KEYBOARD,
+            QEMU_CAPS_VIRTIO_MOUSE,
+            QEMU_CAPS_VIRTIO_TABLET,
+            QEMU_CAPS_DEVICE_VIRTIO_KEYBOARD_CCW,
+            QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW,
+            QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW);
+
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
         virFileDeleteTree(fakerootdir);
 
diff --git a/tests/qemuxml2xmloutdata/input-virtio-ccw.xml b/tests/qemuxml2xmloutdata/input-virtio-ccw.xml
new file mode 100644 (file)
index 0000000..20aed31
--- /dev/null
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1803</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='s390x' machine='s390-ccw-virtio'>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-s390x</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='virtio'/>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+    </disk>
+    <input type='keyboard' bus='virtio'>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0002'/>
+    </input>
+    <input type='mouse' bus='virtio'>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0003'/>
+    </input>
+    <input type='tablet' bus='virtio'>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0004'/>
+    </input>
+    <memballoon model='virtio'>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
+    </memballoon>
+    <panic model='s390'/>
+  </devices>
+</domain>
index 5b014ca60b9168aba2d5f46675ae2f3d56ac4831..0f560290a0e364e80997e1b3992c2adb69958160 100644 (file)
@@ -1230,6 +1230,14 @@ mymain(void)
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
 
     DO_TEST("user-aliases", NONE);
+    DO_TEST("input-virtio-ccw",
+            QEMU_CAPS_VIRTIO_CCW,
+            QEMU_CAPS_VIRTIO_KEYBOARD,
+            QEMU_CAPS_VIRTIO_MOUSE,
+            QEMU_CAPS_VIRTIO_TABLET,
+            QEMU_CAPS_DEVICE_VIRTIO_KEYBOARD_CCW,
+            QEMU_CAPS_DEVICE_VIRTIO_MOUSE_CCW,
+            QEMU_CAPS_DEVICE_VIRTIO_TABLET_CCW);
 
     /* Test disks with format probing enabled for legacy reasons.
      * New tests should not go in this section. */