diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index b989c8f9a4..905117881e 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5641,7 +5641,8 @@ qemu-kvm -net nic,model=? /dev/null
video device in domain xml is the primary one, but the optional
attribute primary
(since 1.0.2 )
with value 'yes' can be used to mark the primary in cases of multiple
- video device. The non-primary must be type of "qxl".
+ video device. The non-primary must be type of "qxl" or
+ (since 2.4.0 ) "virtio".
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 98fb2e52c7..0c9416f61d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2421,7 +2421,8 @@ qemuDomainDefValidateVideo(const virDomainDef *def)
}
if (!video->primary &&
- video->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
+ video->type != VIR_DOMAIN_VIDEO_TYPE_QXL &&
+ video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("video type '%s' is only valid as primary "
"video device"),
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-secondary.args b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-secondary.args
new file mode 100644
index 0000000000..9d47e87986
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-secondary.args
@@ -0,0 +1,22 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 1024 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-device virtio-gpu-pci,id=video0,bus=pci.0,addr=0x2 \
+-device virtio-gpu-pci,id=video1,bus=pci.0,addr=0x4 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-secondary.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-secondary.xml
new file mode 100644
index 0000000000..61d8eb85d6
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-secondary.xml
@@ -0,0 +1,27 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 1048576
+ 1048576
+ 1
+
+ hvm
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 5adb2fdddb..b9961823f8 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1616,6 +1616,9 @@ mymain(void)
QEMU_CAPS_SPICE,
QEMU_CAPS_SPICE_GL,
QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
+ DO_TEST("video-virtio-gpu-secondary",
+ QEMU_CAPS_DEVICE_VIRTIO_GPU,
+ QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
DO_TEST("video-virtio-vga",
QEMU_CAPS_DEVICE_VIRTIO_GPU,
QEMU_CAPS_DEVICE_VIRTIO_VGA,
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-secondary.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-secondary.xml
new file mode 100644
index 0000000000..2666004546
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-secondary.xml
@@ -0,0 +1,35 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 1048576
+ 1048576
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index a06351d499..62bff8cd7a 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -876,6 +876,7 @@ mymain(void)
DO_TEST("video-qxl-heads", NONE);
DO_TEST("video-qxl-noheads", NONE);
+ DO_TEST("video-virtio-gpu-secondary", NONE);
DO_TEST("intel-iommu",
QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE);