diff --git a/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ap-boot-fail.xml b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ap-boot-fail.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3f9bb64b8b6e6305a5c6e869cb07ae867907c604
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ap-boot-fail.xml
@@ -0,0 +1,23 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 524288
+ 524288
+ 2
+
+ hvm
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-s390x
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ap.s390x-latest.args b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ap.s390x-latest.args
new file mode 100644
index 0000000000000000000000000000000000000000..4aedc266ac392651f035d0a31779dec91c880dc0
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ap.s390x-latest.args
@@ -0,0 +1,33 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-s390x \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,\
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
+-machine s390-ccw-virtio,accel=tcg,usb=off,dump-guest-core=off \
+-m 512 \
+-overcommit mem-lock=off \
+-smp 2,sockets=2,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-device vfio-ap,id=hostdev0,\
+sysfsdev=/sys/bus/mdev/devices/90c6c135-ad44-41d0-b1b7-bae47de48627 \
+-device virtio-balloon-ccw,id=balloon0,devno=fe.0.0000 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
+resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ap.xml b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ap.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e7370b5838084ba13a5a02729864cf1962d03a48
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-subsys-mdev-vfio-ap.xml
@@ -0,0 +1,22 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 524288
+ 524288
+ 2
+
+ hvm
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-s390x
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index e9f45775e5de5ccc408b285e0c685c1c932094eb..3d89404a4947c5aa75fe51f74e16684e4e93e4ed 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1637,6 +1637,11 @@ mymain(void)
QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
QEMU_CAPS_DEVICE_VFIO_CCW);
+ DO_TEST_CAPS_ARCH_LATEST("hostdev-subsys-mdev-vfio-ap",
+ "s390x");
+ DO_TEST_CAPS_ARCH_LATEST_FAILURE("hostdev-subsys-mdev-vfio-ap-boot-fail",
+ "s390x");
+
DO_TEST_FULL("restore-v2",
ARG_MIGRATE_FROM, "exec:cat",
ARG_MIGRATE_FD, 7,
diff --git a/tests/qemuxml2xmloutdata/hostdev-subsys-mdev-vfio-ap.xml b/tests/qemuxml2xmloutdata/hostdev-subsys-mdev-vfio-ap.xml
new file mode 100644
index 0000000000000000000000000000000000000000..afaa9c3e43b1dea7abf6e4685bd1b1dc63f678f6
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/hostdev-subsys-mdev-vfio-ap.xml
@@ -0,0 +1,27 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 524288
+ 524288
+ 2
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-s390x
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 0ea4ae0342a172bbebbf17753f516875e639319a..93ead52d9a4931a636461e7342f29d46f3d0ca5d 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -959,6 +959,10 @@ mymain(void)
QEMU_CAPS_CCW,
QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
QEMU_CAPS_DEVICE_VFIO_CCW);
+ DO_TEST("hostdev-subsys-mdev-vfio-ap",
+ QEMU_CAPS_CCW,
+ QEMU_CAPS_CCW_CSSID_UNRESTRICTED,
+ QEMU_CAPS_DEVICE_VFIO_AP);
DO_TEST("s390-defaultconsole",
QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);