Let us test the following functionalities of vfio-ccw in libvirt
1. Generation of QEMU command line from domain xml file
2. Generation of dump xml from domain xml file
3. Checks duplicate/invalid addresses for vfio-ccw devices.
Signed-off-by: Shalini Chellathurai Saroja <shalini(a)linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk(a)linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay(a)linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi(a)linux.vnet.ibm.com>
---
...tdev-subsys-mdev-vfio-ccw-duplicate-address.xml | 29 ++++++++++++++++++++++
...ostdev-subsys-mdev-vfio-ccw-invalid-address.xml | 23 +++++++++++++++++
.../hostdev-subsys-mdev-vfio-ccw.args | 23 +++++++++++++++++
.../hostdev-subsys-mdev-vfio-ccw.xml | 22 ++++++++++++++++
tests/qemuxml2argvtest.c | 16 ++++++++++++
.../hostdev-subsys-mdev-vfio-ccw.xml | 28 +++++++++++++++++++++
tests/qemuxml2xmltest.c | 5 ++++
7 files changed, 146 insertions(+)
create mode 100644
tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-duplicate-address.xml
create mode 100644
tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-invalid-address.xml
create mode 100644 tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.args
create mode 100644 tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.xml
create mode 100644 tests/qemuxml2xmloutdata/hostdev-subsys-mdev-vfio-ccw.xml
diff --git a/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-duplicate-address.xml
b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-duplicate-address.xml
new file mode 100644
index 0000000000..4b95fe277c
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-duplicate-address.xml
@@ -0,0 +1,29 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>524288</memory>
+ <currentMemory unit='KiB'>524288</currentMemory>
+ <vcpu placement='static'>2</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>
+ <hostdev mode='subsystem' type='mdev'
model='vfio-ccw'>
+ <source>
+ <address uuid='90c6c135-ad44-41d0-b1b7-bae47de48627'/>
+ </source>
+ <address type='ccw' cssid='0xfe' ssid='0x0'
devno='0x0001'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='mdev'
model='vfio-ccw'>
+ <source>
+ <address uuid='71b411af-5491-4100-b03e-0705e0b2eb27'/>
+ </source>
+ <address type='ccw' cssid='0xfe' ssid='0x0'
devno='0x0001'/>
+ </hostdev>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-invalid-address.xml
b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-invalid-address.xml
new file mode 100644
index 0000000000..680090e2b0
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw-invalid-address.xml
@@ -0,0 +1,23 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>524288</memory>
+ <currentMemory unit='KiB'>524288</currentMemory>
+ <vcpu placement='static'>2</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>
+ <hostdev mode='subsystem' type='mdev'
model='vfio-ccw'>
+ <source>
+ <address uuid='90c6c135-ad44-41d0-b1b7-bae47de48627'/>
+ </source>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x03' function='0x0'/>
+ </hostdev>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.args
b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.args
new file mode 100644
index 0000000000..a359f40e2e
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.args
@@ -0,0 +1,23 @@
+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 512 \
+-smp 2,sockets=2,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-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 \
+-device vfio-ccw,id=hostdev0,\
+sysfsdev=/sys/bus/mdev/devices/90c6c135-ad44-41d0-b1b7-bae47de48627,\
+devno=fe.0.0000 \
+-device virtio-balloon-ccw,id=balloon0,devno=fe.0.0001
diff --git a/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.xml
b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.xml
new file mode 100644
index 0000000000..96f30f5e9c
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ccw.xml
@@ -0,0 +1,22 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>524288</memory>
+ <currentMemory unit='KiB'>524288</currentMemory>
+ <vcpu placement='static'>2</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>
+ <hostdev mode='subsystem' type='mdev'
model='vfio-ccw'>
+ <source>
+ <address uuid='90c6c135-ad44-41d0-b1b7-bae47de48627'/>
+ </source>
+ </hostdev>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index de5bf6fe5a..64ab04817a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1659,6 +1659,22 @@ mymain(void)
DO_TEST("pci-rom",
QEMU_CAPS_NODEFCONFIG);
+ DO_TEST("hostdev-subsys-mdev-vfio-ccw",
+ QEMU_CAPS_CCW,
+ QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
+ QEMU_CAPS_DEVICE_VFIO_CCW);
+ DO_TEST_FAILURE("hostdev-subsys-mdev-vfio-ccw",
+ QEMU_CAPS_CCW,
+ QEMU_CAPS_CCW_CSSID_UNRESTRICTED);
+ DO_TEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ccw-duplicate-address",
+ QEMU_CAPS_CCW,
+ QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
+ QEMU_CAPS_DEVICE_VFIO_CCW);
+ DO_TEST_PARSE_ERROR("hostdev-subsys-mdev-vfio-ccw-invalid-address",
+ QEMU_CAPS_CCW,
+ QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
+ QEMU_CAPS_DEVICE_VFIO_CCW);
+
DO_TEST_FULL("restore-v2", "exec:cat", 7, 0, 0, GIC_NONE, NONE);
DO_TEST_FULL("restore-v2-fd", "stdio", 7, 0, 0, GIC_NONE, NONE);
DO_TEST_FULL("restore-v2-fd", "fd:7", 7, 0, 0, GIC_NONE, NONE);
diff --git a/tests/qemuxml2xmloutdata/hostdev-subsys-mdev-vfio-ccw.xml
b/tests/qemuxml2xmloutdata/hostdev-subsys-mdev-vfio-ccw.xml
new file mode 100644
index 0000000000..a14ab05caa
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/hostdev-subsys-mdev-vfio-ccw.xml
@@ -0,0 +1,28 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>524288</memory>
+ <currentMemory unit='KiB'>524288</currentMemory>
+ <vcpu placement='static'>2</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>
+ <hostdev mode='subsystem' type='mdev' managed='no'
model='vfio-ccw'>
+ <source>
+ <address uuid='90c6c135-ad44-41d0-b1b7-bae47de48627'/>
+ </source>
+ <address type='ccw' cssid='0xfe' ssid='0x0'
devno='0x0000'/>
+ </hostdev>
+ <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 4901eb286e..84982fb6a3 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1024,6 +1024,11 @@ mymain(void)
QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
QEMU_CAPS_DEVICE_SCSI_GENERIC);
+ DO_TEST("hostdev-subsys-mdev-vfio-ccw",
+ QEMU_CAPS_CCW,
+ QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
+ QEMU_CAPS_DEVICE_VFIO_CCW);
+
DO_TEST("s390-defaultconsole",
QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
DO_TEST("s390-panic",
--
2.13.4