51d9a2
From 437293e3e1ac3fc43aca6d0ceb436f937a08d5e4 Mon Sep 17 00:00:00 2001
51d9a2
Message-Id: <437293e3e1ac3fc43aca6d0ceb436f937a08d5e4@dist-git>
51d9a2
From: Erik Skultety <eskultet@redhat.com>
51d9a2
Date: Thu, 19 Jul 2018 15:04:05 +0200
51d9a2
Subject: [PATCH] conf: Introduce new video type 'none'
51d9a2
MIME-Version: 1.0
51d9a2
Content-Type: text/plain; charset=UTF-8
51d9a2
Content-Transfer-Encoding: 8bit
51d9a2
51d9a2
Historically, we've always enabled an emulated video device every time we
51d9a2
see that graphics should be supported with a guest. With the appearance
51d9a2
of mediated devices which can support QEMU's vfio-display capability,
51d9a2
users might want to use such a device as the only video device.
51d9a2
Therefore introduce a new, effectively a 'disable', type for video
51d9a2
device.
51d9a2
51d9a2
Reviewed-by: Ján Tomko <jtomko@redhat.com>
51d9a2
Signed-off-by: Erik Skultety <eskultet@redhat.com>
51d9a2
(cherry picked from commit d48813e81af798e3027edcc2f41be2630111ba65)
51d9a2
51d9a2
https://bugzilla.redhat.com/show_bug.cgi?id=1475770
51d9a2
Signed-off-by: Erik Skultety <eskultet@redhat.com>
51d9a2
Reviewed-by: Ján Tomko <jtomko@redhat.com>
51d9a2
---
51d9a2
 docs/formatdomain.html.in                     | 13 +++-
51d9a2
 docs/schemas/domaincommon.rng                 |  1 +
51d9a2
 src/conf/domain_conf.c                        | 61 +++++++++++++------
51d9a2
 src/conf/domain_conf.h                        |  1 +
51d9a2
 src/qemu/qemu_command.c                       | 12 +++-
51d9a2
 src/qemu/qemu_domain.c                        |  2 +
51d9a2
 src/qemu/qemu_domain_address.c                |  7 ++-
51d9a2
 tests/domaincapsschemadata/full.xml           |  1 +
51d9a2
 .../video-invalid-multiple-devices.xml        | 33 ++++++++++
51d9a2
 tests/qemuxml2argvdata/video-none-device.args | 27 ++++++++
51d9a2
 tests/qemuxml2argvdata/video-none-device.xml  | 39 ++++++++++++
51d9a2
 tests/qemuxml2argvtest.c                      |  4 +-
51d9a2
 .../qemuxml2xmloutdata/video-none-device.xml  | 42 +++++++++++++
51d9a2
 tests/qemuxml2xmltest.c                       |  1 +
51d9a2
 14 files changed, 220 insertions(+), 24 deletions(-)
51d9a2
 create mode 100644 tests/qemuxml2argvdata/video-invalid-multiple-devices.xml
51d9a2
 create mode 100644 tests/qemuxml2argvdata/video-none-device.args
51d9a2
 create mode 100644 tests/qemuxml2argvdata/video-none-device.xml
51d9a2
 create mode 100644 tests/qemuxml2xmloutdata/video-none-device.xml
51d9a2
51d9a2
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
51d9a2
index 0e8f0a125f..42acf7a828 100644
51d9a2
--- a/docs/formatdomain.html.in
51d9a2
+++ b/docs/formatdomain.html.in
51d9a2
@@ -6666,9 +6666,18 @@ qemu-kvm -net nic,model=? /dev/null
51d9a2
           The model element has a mandatory type
51d9a2
           attribute which takes the value "vga", "cirrus", "vmvga", "xen",
51d9a2
           "vbox", "qxl" (since 0.8.6),
51d9a2
-          "virtio" (since 1.3.0)
51d9a2
-          or "gop" (since 3.2.0)
51d9a2
+          "virtio" (since 1.3.0),
51d9a2
+          "gop" (since 3.2.0), or
51d9a2
+          "none" (since 4.6.0)
51d9a2
           depending on the hypervisor features available.
51d9a2
+          The purpose of the type none is to instruct libvirt not
51d9a2
+          to add a default video device in the guest (see the paragraph above).
51d9a2
+          This legacy behaviour can be inconvenient in cases where GPU mediated
51d9a2
+          devices are meant to be the only rendering device within a guest and
51d9a2
+          so specifying another video device along with type
51d9a2
+          none.
51d9a2
+          Refer to Host device assignment to see
51d9a2
+          how to add a mediated device into a guest.
51d9a2
         

51d9a2
         

51d9a2
           You can provide the amount of video memory in kibibytes (blocks of
51d9a2
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
51d9a2
index be8430ab22..ac04af51a1 100644
51d9a2
--- a/docs/schemas/domaincommon.rng
51d9a2
+++ b/docs/schemas/domaincommon.rng
51d9a2
@@ -3454,6 +3454,7 @@
51d9a2
                 <value>vbox</value>
51d9a2
                 <value>virtio</value>
51d9a2
                 <value>gop</value>
51d9a2
+                <value>none</value>
51d9a2
               </choice>
51d9a2
             </attribute>
51d9a2
             <group>
51d9a2
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
51d9a2
index 830c298158..23288aa01b 100644
51d9a2
--- a/src/conf/domain_conf.c
51d9a2
+++ b/src/conf/domain_conf.c
51d9a2
@@ -590,7 +590,8 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
51d9a2
               "qxl",
51d9a2
               "parallels",
51d9a2
               "virtio",
51d9a2
-              "gop")
51d9a2
+              "gop",
51d9a2
+              "none")
51d9a2
 
51d9a2
 VIR_ENUM_IMPL(virDomainVideoVGAConf, VIR_DOMAIN_VIDEO_VGACONF_LAST,
51d9a2
               "io",
51d9a2
@@ -5106,22 +5107,30 @@ virDomainDefPostParseVideo(virDomainDefPtr def,
51d9a2
     if (def->nvideos == 0)
51d9a2
         return 0;
51d9a2
 
51d9a2
-    virDomainDeviceDef device = {
51d9a2
-        .type = VIR_DOMAIN_DEVICE_VIDEO,
51d9a2
-        .data.video = def->videos[0],
51d9a2
-    };
51d9a2
+    if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_NONE) {
51d9a2
+        /* we don't want to format any values we automatically fill in for
51d9a2
+         * videos into the XML, so clear them
51d9a2
+         */
51d9a2
+        virDomainVideoDefClear(def->videos[0]);
51d9a2
+        def->videos[0]->type = VIR_DOMAIN_VIDEO_TYPE_NONE;
51d9a2
+    } else {
51d9a2
+        virDomainDeviceDef device = {
51d9a2
+            .type = VIR_DOMAIN_DEVICE_VIDEO,
51d9a2
+            .data.video = def->videos[0],
51d9a2
+        };
51d9a2
 
51d9a2
-    /* Mark the first video as primary. If the user specified
51d9a2
-     * primary="yes", the parser already inserted the device at
51d9a2
-     * def->videos[0]
51d9a2
-     */
51d9a2
-    def->videos[0]->primary = true;
51d9a2
+        /* Mark the first video as primary. If the user specified
51d9a2
+         * primary="yes", the parser already inserted the device at
51d9a2
+         * def->videos[0]
51d9a2
+         */
51d9a2
+        def->videos[0]->primary = true;
51d9a2
 
51d9a2
-    /* videos[0] might have been added in AddImplicitDevices, after we've
51d9a2
-     * done the per-device post-parse */
51d9a2
-    if (virDomainDefPostParseDeviceIterator(def, &device,
51d9a2
-                                            NULL, opaque) < 0)
51d9a2
-        return -1;
51d9a2
+        /* videos[0] might have been added in AddImplicitDevices, after we've
51d9a2
+         * done the per-device post-parse */
51d9a2
+        if (virDomainDefPostParseDeviceIterator(def, &device,
51d9a2
+                                                NULL, opaque) < 0)
51d9a2
+            return -1;
51d9a2
+    }
51d9a2
 
51d9a2
     return 0;
51d9a2
 }
51d9a2
@@ -5670,13 +5679,30 @@ virDomainHostdevDefValidate(const virDomainHostdevDef *hostdev)
51d9a2
 
51d9a2
 
51d9a2
 static int
51d9a2
-virDomainVideoDefValidate(const virDomainVideoDef *video)
51d9a2
+virDomainVideoDefValidate(const virDomainVideoDef *video,
51d9a2
+                          const virDomainDef *def)
51d9a2
 {
51d9a2
+    size_t i;
51d9a2
+
51d9a2
     if (video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) {
51d9a2
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
51d9a2
                        _("missing video model and cannot determine default"));
51d9a2
         return -1;
51d9a2
     }
51d9a2
+
51d9a2
+    /* it doesn't make sense to pair video device type 'none' with any other
51d9a2
+     * types, there can be only a single video device in such case
51d9a2
+     */
51d9a2
+    for (i = 0; i < def->nvideos; i++) {
51d9a2
+        if (def->videos[i]->type == VIR_DOMAIN_VIDEO_TYPE_NONE &&
51d9a2
+            def->nvideos > 1) {
51d9a2
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
51d9a2
+                           _("a '%s' video type must be the only video device "
51d9a2
+                             "defined for the domain"));
51d9a2
+            return -1;
51d9a2
+        }
51d9a2
+    }
51d9a2
+
51d9a2
     return 0;
51d9a2
 }
51d9a2
 
51d9a2
@@ -5738,7 +5764,7 @@ virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev,
51d9a2
         return virDomainHostdevDefValidate(dev->data.hostdev);
51d9a2
 
51d9a2
     case VIR_DOMAIN_DEVICE_VIDEO:
51d9a2
-        return virDomainVideoDefValidate(dev->data.video);
51d9a2
+        return virDomainVideoDefValidate(dev->data.video, def);
51d9a2
 
51d9a2
     case VIR_DOMAIN_DEVICE_MEMORY:
51d9a2
         return virDomainMemoryDefValidate(dev->data.memory);
51d9a2
@@ -15048,6 +15074,7 @@ virDomainVideoDefaultRAM(const virDomainDef *def,
51d9a2
     case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
51d9a2
     case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
51d9a2
     case VIR_DOMAIN_VIDEO_TYPE_GOP:
51d9a2
+    case VIR_DOMAIN_VIDEO_TYPE_NONE:
51d9a2
     case VIR_DOMAIN_VIDEO_TYPE_LAST:
51d9a2
     default:
51d9a2
         return 0;
51d9a2
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
51d9a2
index 8ca9558ceb..5e2f21dea3 100644
51d9a2
--- a/src/conf/domain_conf.h
51d9a2
+++ b/src/conf/domain_conf.h
51d9a2
@@ -1424,6 +1424,7 @@ typedef enum {
51d9a2
     VIR_DOMAIN_VIDEO_TYPE_PARALLELS, /* pseudo device for VNC in containers */
51d9a2
     VIR_DOMAIN_VIDEO_TYPE_VIRTIO,
51d9a2
     VIR_DOMAIN_VIDEO_TYPE_GOP,
51d9a2
+    VIR_DOMAIN_VIDEO_TYPE_NONE,
51d9a2
 
51d9a2
     VIR_DOMAIN_VIDEO_TYPE_LAST
51d9a2
 } virDomainVideoType;
51d9a2
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
51d9a2
index 1fce45134f..954265feb0 100644
51d9a2
--- a/src/qemu/qemu_command.c
51d9a2
+++ b/src/qemu/qemu_command.c
51d9a2
@@ -105,7 +105,8 @@ VIR_ENUM_IMPL(qemuVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
51d9a2
               "qxl",
51d9a2
               "", /* don't support parallels */
51d9a2
               "", /* no need for virtio */
51d9a2
-              "" /* don't support gop */);
51d9a2
+              "" /* don't support gop */,
51d9a2
+              "" /* 'none' doesn't make sense here */);
51d9a2
 
51d9a2
 VIR_ENUM_DECL(qemuDeviceVideo)
51d9a2
 
51d9a2
@@ -119,7 +120,8 @@ VIR_ENUM_IMPL(qemuDeviceVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
51d9a2
               "qxl-vga",
51d9a2
               "", /* don't support parallels */
51d9a2
               "virtio-vga",
51d9a2
-              "" /* don't support gop */);
51d9a2
+              "" /* don't support gop */,
51d9a2
+              "" /* 'none' doesn't make sense here */);
51d9a2
 
51d9a2
 VIR_ENUM_DECL(qemuDeviceVideoSecondary)
51d9a2
 
51d9a2
@@ -133,7 +135,8 @@ VIR_ENUM_IMPL(qemuDeviceVideoSecondary, VIR_DOMAIN_VIDEO_TYPE_LAST,
51d9a2
               "qxl",
51d9a2
               "", /* don't support parallels */
51d9a2
               "virtio-gpu",
51d9a2
-              "" /* don't support gop */);
51d9a2
+              "" /* don't support gop */,
51d9a2
+              "" /* 'none' doesn't make sense here */);
51d9a2
 
51d9a2
 VIR_ENUM_DECL(qemuSoundCodec)
51d9a2
 
51d9a2
@@ -4421,6 +4424,9 @@ qemuBuildVideoCommandLine(virCommandPtr cmd,
51d9a2
         char *str = NULL;
51d9a2
         virDomainVideoDefPtr video = def->videos[i];
51d9a2
 
51d9a2
+        if (video->type == VIR_DOMAIN_VIDEO_TYPE_NONE)
51d9a2
+            continue;
51d9a2
+
51d9a2
         if (video->primary) {
51d9a2
             if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY)) {
51d9a2
 
51d9a2
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
51d9a2
index 5337f1ce55..508846116b 100644
51d9a2
--- a/src/qemu/qemu_domain.c
51d9a2
+++ b/src/qemu/qemu_domain.c
51d9a2
@@ -4528,6 +4528,8 @@ static int
51d9a2
 qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video)
51d9a2
 {
51d9a2
     switch ((virDomainVideoType) video->type) {
51d9a2
+    case VIR_DOMAIN_VIDEO_TYPE_NONE:
51d9a2
+        return 0;
51d9a2
     case VIR_DOMAIN_VIDEO_TYPE_XEN:
51d9a2
     case VIR_DOMAIN_VIDEO_TYPE_VBOX:
51d9a2
     case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
51d9a2
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
51d9a2
index ab2ac022f1..e6996934b8 100644
51d9a2
--- a/src/qemu/qemu_domain_address.c
51d9a2
+++ b/src/qemu/qemu_domain_address.c
51d9a2
@@ -821,6 +821,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
51d9a2
 
51d9a2
         case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
51d9a2
         case VIR_DOMAIN_VIDEO_TYPE_GOP:
51d9a2
+        case VIR_DOMAIN_VIDEO_TYPE_NONE:
51d9a2
         case VIR_DOMAIN_VIDEO_TYPE_LAST:
51d9a2
             return 0;
51d9a2
         }
51d9a2
@@ -1532,7 +1533,8 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
51d9a2
             goto cleanup;
51d9a2
     }
51d9a2
 
51d9a2
-    if (def->nvideos > 0) {
51d9a2
+    if (def->nvideos > 0 &&
51d9a2
+        def->videos[0]->type != VIR_DOMAIN_VIDEO_TYPE_NONE) {
51d9a2
         /* Because the PIIX3 integrated IDE/USB controllers are
51d9a2
          * already at slot 1, when qemu looks for the first free slot
51d9a2
          * to place the VGA controller (which is always the first
51d9a2
@@ -1540,6 +1542,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
51d9a2
          * at slot 2.
51d9a2
          */
51d9a2
         virDomainVideoDefPtr primaryVideo = def->videos[0];
51d9a2
+
51d9a2
         if (virDeviceInfoPCIAddressWanted(&primaryVideo->info)) {
51d9a2
             memset(&tmp_addr, 0, sizeof(tmp_addr));
51d9a2
             tmp_addr.slot = 2;
51d9a2
@@ -2105,6 +2108,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
51d9a2
 
51d9a2
     /* Video devices */
51d9a2
     for (i = 0; i < def->nvideos; i++) {
51d9a2
+        if (def->videos[i]->type == VIR_DOMAIN_VIDEO_TYPE_NONE)
51d9a2
+            continue;
51d9a2
 
51d9a2
         if (!virDeviceInfoPCIAddressWanted(&def->videos[i]->info))
51d9a2
             continue;
51d9a2
diff --git a/tests/domaincapsschemadata/full.xml b/tests/domaincapsschemadata/full.xml
51d9a2
index 154c4a6fe9..eafba1ae5b 100644
51d9a2
--- a/tests/domaincapsschemadata/full.xml
51d9a2
+++ b/tests/domaincapsschemadata/full.xml
51d9a2
@@ -74,6 +74,7 @@
51d9a2
         <value>parallels</value>
51d9a2
         <value>virtio</value>
51d9a2
         <value>gop</value>
51d9a2
+        <value>none</value>
51d9a2
       </enum>
51d9a2
     </video>
51d9a2
     <hostdev supported='yes'>
51d9a2
diff --git a/tests/qemuxml2argvdata/video-invalid-multiple-devices.xml b/tests/qemuxml2argvdata/video-invalid-multiple-devices.xml
51d9a2
new file mode 100644
51d9a2
index 0000000000..3f105efaae
51d9a2
--- /dev/null
51d9a2
+++ b/tests/qemuxml2argvdata/video-invalid-multiple-devices.xml
51d9a2
@@ -0,0 +1,33 @@
51d9a2
+<domain type='qemu'>
51d9a2
+  <name>QEMUGuest1</name>
51d9a2
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
51d9a2
+  <memory unit='KiB'>219100</memory>
51d9a2
+  <currentMemory unit='KiB'>219100</currentMemory>
51d9a2
+  <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
51d9a2
+  <os>
51d9a2
+    <type arch='i686' machine='pc'>hvm</type>
51d9a2
+    <boot dev='hd'/>
51d9a2
+  </os>
51d9a2
+  <clock offset='utc'/>
51d9a2
+  <on_poweroff>destroy</on_poweroff>
51d9a2
+  <on_reboot>restart</on_reboot>
51d9a2
+  <on_crash>destroy</on_crash>
51d9a2
+  <devices>
51d9a2
+    <emulator>/usr/bin/qemu-system-i686</emulator>
51d9a2
+    <disk type='block' device='disk'>
51d9a2
+      <source dev='/dev/HostVG/QEMUGuest1'/>
51d9a2
+      <target dev='hda' bus='ide'/>
51d9a2
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
51d9a2
+    </disk>
51d9a2
+    <controller type='usb' index='0'/>
51d9a2
+    <controller type='ide' index='0'/>
51d9a2
+    <controller type='pci' index='0' model='pci-root'/>
51d9a2
+    <video>
51d9a2
+      <model type='qxl'/>
51d9a2
+    </video>
51d9a2
+    <video>
51d9a2
+      <model type='none'/>
51d9a2
+    </video>
51d9a2
+    <memballoon model='virtio'/>
51d9a2
+  </devices>
51d9a2
+</domain>
51d9a2
diff --git a/tests/qemuxml2argvdata/video-none-device.args b/tests/qemuxml2argvdata/video-none-device.args
51d9a2
new file mode 100644
51d9a2
index 0000000000..1b03c0cb97
51d9a2
--- /dev/null
51d9a2
+++ b/tests/qemuxml2argvdata/video-none-device.args
51d9a2
@@ -0,0 +1,27 @@
51d9a2
+LC_ALL=C \
51d9a2
+PATH=/bin \
51d9a2
+HOME=/home/test \
51d9a2
+USER=test \
51d9a2
+LOGNAME=test \
51d9a2
+QEMU_AUDIO_DRV=none \
51d9a2
+/usr/bin/qemu-system-i686 \
51d9a2
+-name QEMUGuest1 \
51d9a2
+-S \
51d9a2
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
51d9a2
+-m 214 \
51d9a2
+-smp 1,sockets=1,cores=1,threads=1 \
51d9a2
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
51d9a2
+-no-user-config \
51d9a2
+-nodefaults \
51d9a2
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
51d9a2
+server,nowait \
51d9a2
+-mon chardev=charmonitor,id=monitor,mode=control \
51d9a2
+-rtc base=utc \
51d9a2
+-no-shutdown \
51d9a2
+-no-acpi \
51d9a2
+-boot c \
51d9a2
+-usb \
51d9a2
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
51d9a2
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
51d9a2
+-vnc 127.0.0.1:0 \
51d9a2
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
51d9a2
diff --git a/tests/qemuxml2argvdata/video-none-device.xml b/tests/qemuxml2argvdata/video-none-device.xml
51d9a2
new file mode 100644
51d9a2
index 0000000000..4b591562b7
51d9a2
--- /dev/null
51d9a2
+++ b/tests/qemuxml2argvdata/video-none-device.xml
51d9a2
@@ -0,0 +1,39 @@
51d9a2
+<domain type='qemu'>
51d9a2
+  <name>QEMUGuest1</name>
51d9a2
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
51d9a2
+  <memory unit='KiB'>219136</memory>
51d9a2
+  <currentMemory unit='KiB'>219136</currentMemory>
51d9a2
+  <vcpu placement='static'>1</vcpu>
51d9a2
+  <os>
51d9a2
+    <type arch='i686' machine='pc'>hvm</type>
51d9a2
+    <boot dev='hd'/>
51d9a2
+  </os>
51d9a2
+  <clock offset='utc'/>
51d9a2
+  <on_poweroff>destroy</on_poweroff>
51d9a2
+  <on_reboot>restart</on_reboot>
51d9a2
+  <on_crash>destroy</on_crash>
51d9a2
+  <devices>
51d9a2
+    <emulator>/usr/bin/qemu-system-i686</emulator>
51d9a2
+    <disk type='block' device='disk'>
51d9a2
+      <source dev='/dev/HostVG/QEMUGuest1'/>
51d9a2
+      <target dev='hda' bus='ide'/>
51d9a2
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
51d9a2
+    </disk>
51d9a2
+    <controller type='usb' index='0'>
51d9a2
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
51d9a2
+    </controller>
51d9a2
+    <controller type='ide' index='0'>
51d9a2
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
51d9a2
+    </controller>
51d9a2
+    <controller type='pci' index='0' model='pci-root'/>
51d9a2
+    <input type='mouse' bus='ps2'/>
51d9a2
+    <input type='keyboard' bus='ps2'/>
51d9a2
+    <graphics type='vnc'/>
51d9a2
+    <video>
51d9a2
+      <model type='none'/>
51d9a2
+    </video>
51d9a2
+    <memballoon model='virtio'>
51d9a2
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
51d9a2
+    </memballoon>
51d9a2
+  </devices>
51d9a2
+</domain>
51d9a2
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
51d9a2
index 9237a4fb89..3cff4ffb5e 100644
51d9a2
--- a/tests/qemuxml2argvtest.c
51d9a2
+++ b/tests/qemuxml2argvtest.c
51d9a2
@@ -1998,7 +1998,9 @@ mymain(void)
51d9a2
             QEMU_CAPS_DEVICE_VIRTIO_VGA,
51d9a2
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
51d9a2
             QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS);
51d9a2
-    DO_TEST_PARSE_ERROR("video-invalid", NONE);
51d9a2
+    DO_TEST("video-none-device",
51d9a2
+            QEMU_CAPS_VNC);
51d9a2
+    DO_TEST_PARSE_ERROR("video-invalid-multiple-devices", NONE);
51d9a2
 
51d9a2
     DO_TEST("virtio-rng-default",
51d9a2
             QEMU_CAPS_DEVICE_VIRTIO_RNG,
51d9a2
diff --git a/tests/qemuxml2xmloutdata/video-none-device.xml b/tests/qemuxml2xmloutdata/video-none-device.xml
51d9a2
new file mode 100644
51d9a2
index 0000000000..6e76b394fe
51d9a2
--- /dev/null
51d9a2
+++ b/tests/qemuxml2xmloutdata/video-none-device.xml
51d9a2
@@ -0,0 +1,42 @@
51d9a2
+<domain type='qemu'>
51d9a2
+  <name>QEMUGuest1</name>
51d9a2
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
51d9a2
+  <memory unit='KiB'>219136</memory>
51d9a2
+  <currentMemory unit='KiB'>219136</currentMemory>
51d9a2
+  <vcpu placement='static'>1</vcpu>
51d9a2
+  <os>
51d9a2
+    <type arch='i686' machine='pc'>hvm</type>
51d9a2
+    <boot dev='hd'/>
51d9a2
+  </os>
51d9a2
+  <clock offset='utc'/>
51d9a2
+  <on_poweroff>destroy</on_poweroff>
51d9a2
+  <on_reboot>restart</on_reboot>
51d9a2
+  <on_crash>destroy</on_crash>
51d9a2
+  <devices>
51d9a2
+    <emulator>/usr/bin/qemu-system-i686</emulator>
51d9a2
+    <disk type='block' device='disk'>
51d9a2
+      <driver name='qemu' type='raw'/>
51d9a2
+      <source dev='/dev/HostVG/QEMUGuest1'/>
51d9a2
+      <target dev='hda' bus='ide'/>
51d9a2
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
51d9a2
+    </disk>
51d9a2
+    <controller type='usb' index='0'>
51d9a2
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
51d9a2
+    </controller>
51d9a2
+    <controller type='ide' index='0'>
51d9a2
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
51d9a2
+    </controller>
51d9a2
+    <controller type='pci' index='0' model='pci-root'/>
51d9a2
+    <input type='mouse' bus='ps2'/>
51d9a2
+    <input type='keyboard' bus='ps2'/>
51d9a2
+    <graphics type='vnc' port='-1' autoport='yes'>
51d9a2
+      <listen type='address'/>
51d9a2
+    </graphics>
51d9a2
+    <video>
51d9a2
+      <model type='none'/>
51d9a2
+    </video>
51d9a2
+    <memballoon model='virtio'>
51d9a2
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
51d9a2
+    </memballoon>
51d9a2
+  </devices>
51d9a2
+</domain>
51d9a2
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
51d9a2
index e418e67f6c..e35644d479 100644
51d9a2
--- a/tests/qemuxml2xmltest.c
51d9a2
+++ b/tests/qemuxml2xmltest.c
51d9a2
@@ -1145,6 +1145,7 @@ mymain(void)
51d9a2
             QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS,
51d9a2
             QEMU_CAPS_VNC,
51d9a2
             QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW);
51d9a2
+    DO_TEST("video-none-device", NONE);
51d9a2
 
51d9a2
     DO_TEST("intel-iommu",
51d9a2
             QEMU_CAPS_DEVICE_INTEL_IOMMU);
51d9a2
-- 
51d9a2
2.18.0
51d9a2