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

99cbc7
         

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