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(a)linux.vnet.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.vnet.ibm.com>
---
docs/formatdomain.html.in | 2 ++
src/qemu/qemu_command.c | 14 +++++++---
tests/qemuxml2argvdata/input-virtio-ccw.args | 26 +++++++++++++++++++
tests/qemuxml2argvdata/input-virtio-ccw.xml | 29 +++++++++++++++++++++
tests/qemuxml2argvtest.c | 8 ++++++
tests/qemuxml2xmloutdata/input-virtio-ccw.xml | 37 +++++++++++++++++++++++++++
tests/qemuxml2xmltest.c | 8 ++++++
7 files changed, 121 insertions(+), 3 deletions(-)
create mode 100644 tests/qemuxml2argvdata/input-virtio-ccw.args
create mode 100644 tests/qemuxml2argvdata/input-virtio-ccw.xml
create mode 100644 tests/qemuxml2xmloutdata/input-virtio-ccw.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0908709..08dc74b 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -6048,6 +6048,8 @@ qemu-kvm -net nic,model=? /dev/null
sub-element <code><address></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
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5882637..c95d5eb 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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
index 0000000..6ee318c
--- /dev/null
+++ b/tests/qemuxml2argvdata/input-virtio-ccw.args
@@ -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
index 0000000..a971662
--- /dev/null
+++ b/tests/qemuxml2argvdata/input-virtio-ccw.xml
@@ -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>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d9ae3ee..728854c 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -3014,6 +3014,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
index 0000000..20aed31
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/input-virtio-ccw.xml
@@ -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>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 5b014ca..0f56029 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -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. */
--
2.7.4