render / rpms / libvirt

Forked from rpms/libvirt 11 months ago
Clone
9119d9
From 76499cca14e0a71564408618fdd148c6d194606e Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <76499cca14e0a71564408618fdd148c6d194606e@dist-git>
9119d9
From: Pavel Hrdina <phrdina@redhat.com>
9119d9
Date: Tue, 25 Nov 2014 10:53:02 +0100
9119d9
Subject: [PATCH] qemu-command: use vram attribute for all video devices
9119d9
9119d9
So far we didn't have any option to set video memory size for qemu video
9119d9
devices. There was only the vram (ram for QXL) attribute but it was valid
9119d9
only for the QXL video device.
9119d9
9119d9
To provide this feature to users QEMU has a dedicated device attribute
9119d9
called 'vgamem_mb' to set the video memory size. We will use the 'vram'
9119d9
attribute for setting video memory size for other QEMU video devices.
9119d9
9119d9
For the cirrus device we will ignore the vram value because it has
9119d9
hardcoded video size in QEMU.
9119d9
9119d9
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1076098
9119d9
9119d9
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9119d9
(cherry picked from commit 24c6ca860e2cf25aa28b33e19c318296b291e42c)
9119d9
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/qemu/qemu_command.c                            | 36 +++++++++++++++++++++-
9119d9
 .../qemuxml2argv-video-qxl-device-vgamem.args      |  6 ++++
9119d9
 .../qemuxml2argv-video-qxl-device-vgamem.xml       | 29 +++++++++++++++++
9119d9
 .../qemuxml2argv-video-qxl-device.args             |  6 ++++
9119d9
 .../qemuxml2argv-video-qxl-device.xml              | 29 +++++++++++++++++
9119d9
 .../qemuxml2argv-video-qxl-nodevice.args           |  5 +++
9119d9
 .../qemuxml2argv-video-qxl-nodevice.xml            | 29 +++++++++++++++++
9119d9
 .../qemuxml2argv-video-qxl-sec-device-vgamem.args  |  8 +++++
9119d9
 .../qemuxml2argv-video-qxl-sec-device-vgamem.xml   | 32 +++++++++++++++++++
9119d9
 .../qemuxml2argv-video-qxl-sec-device.args         |  7 +++++
9119d9
 .../qemuxml2argv-video-qxl-sec-device.xml          | 32 +++++++++++++++++++
9119d9
 .../qemuxml2argv-video-qxl-sec-nodevice.xml        | 32 +++++++++++++++++++
9119d9
 .../qemuxml2argv-video-vga-device-vgamem.args      |  6 ++++
9119d9
 .../qemuxml2argv-video-vga-device-vgamem.xml       | 29 +++++++++++++++++
9119d9
 .../qemuxml2argv-video-vga-device.args             |  6 ++++
9119d9
 .../qemuxml2argv-video-vga-device.xml              | 29 +++++++++++++++++
9119d9
 .../qemuxml2argv-video-vga-nodevice.args           |  5 +++
9119d9
 .../qemuxml2argv-video-vga-nodevice.xml            | 29 +++++++++++++++++
9119d9
 tests/qemuxml2argvtest.c                           | 16 ++++++++++
9119d9
 19 files changed, 370 insertions(+), 1 deletion(-)
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.args
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.xml
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.args
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.xml
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.args
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.xml
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.args
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.xml
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.args
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.xml
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-nodevice.xml
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.args
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.xml
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.args
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.xml
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-vga-nodevice.args
9119d9
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-vga-nodevice.xml
9119d9
9119d9
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
9119d9
index c75d3b0..e44f114 100644
9119d9
--- a/src/qemu/qemu_command.c
9119d9
+++ b/src/qemu/qemu_command.c
9119d9
@@ -4853,6 +4853,20 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,
9119d9
             /* QEMU accepts bytes for vram_size. */
9119d9
             virBufferAsprintf(&buf, ",vram_size=%u", video->vram * 1024);
9119d9
         }
9119d9
+    } else if (video->vram &&
9119d9
+        ((video->type == VIR_DOMAIN_VIDEO_TYPE_VGA &&
9119d9
+          virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
9119d9
+         (video->type == VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
9119d9
+          virQEMUCapsGet(qemuCaps, QEMU_CAPS_VMWARE_SVGA_VGAMEM)))) {
9119d9
+
9119d9
+        if (video->vram < 1024) {
9119d9
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
9119d9
+                           "%s", _("value for 'vram' must be at least 1 MiB "
9119d9
+                                   "(1024 KiB)"));
9119d9
+            goto error;
9119d9
+        }
9119d9
+
9119d9
+        virBufferAsprintf(&buf, ",vgamem_mb=%u", video->vram / 1024);
9119d9
     }
9119d9
 
9119d9
     if (qemuBuildDeviceAddressStr(&buf, def, &video->info, qemuCaps) < 0)
9119d9
@@ -7417,7 +7431,7 @@ qemuBuildShmemDevCmd(virCommandPtr cmd,
9119d9
         }
9119d9
         if (shmem->size < 1024 * 1024) {
9119d9
             virReportError(VIR_ERR_XML_ERROR, "%s",
9119d9
-                           _("shmem size must be at least 1 MiB"));
9119d9
+                           _("shmem size must be at least 1 MiB (1024 KiB)"));
9119d9
             goto error;
9119d9
         }
9119d9
         virBufferAsprintf(&buf, ",size=%llum", shmem->size >> 20);
9119d9
@@ -9150,6 +9164,26 @@ qemuBuildCommandLine(virConnectPtr conn,
9119d9
                                                dev, vram * 1024);
9119d9
                     }
9119d9
                 }
9119d9
+
9119d9
+                if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
9119d9
+                    def->videos[0]->vram &&
9119d9
+                    ((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VGA &&
9119d9
+                      virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
9119d9
+                     (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
9119d9
+                      virQEMUCapsGet(qemuCaps, QEMU_CAPS_VMWARE_SVGA_VGAMEM)))) {
9119d9
+                    unsigned int vram = def->videos[0]->vram;
9119d9
+
9119d9
+                    if (vram < 1024) {
9119d9
+                        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
9119d9
+                                       "%s", _("value for 'vgamem' must be at "
9119d9
+                                               "least 1 MiB (1024 KiB)"));
9119d9
+                        goto error;
9119d9
+                    }
9119d9
+
9119d9
+                    virCommandAddArg(cmd, "-global");
9119d9
+                    virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u",
9119d9
+                                           dev, vram / 1024);
9119d9
+                }
9119d9
             }
9119d9
 
9119d9
             if (def->nvideos > 1) {
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.args b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.args
9119d9
new file mode 100644
9119d9
index 0000000..c9eb535
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.args
9119d9
@@ -0,0 +1,6 @@
9119d9
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
9119d9
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic -nodefaults \
9119d9
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
9119d9
+-hda /var/lib/libvirt/images/QEMUGuest1 \
9119d9
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0\
9119d9
+,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.xml
9119d9
new file mode 100644
9119d9
index 0000000..9fc42af
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.xml
9119d9
@@ -0,0 +1,29 @@
9119d9
+<domain type='qemu'>
9119d9
+  <name>QEMUGuest1</name>
9119d9
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9119d9
+  <memory unit='KiB'>1048576</memory>
9119d9
+  <currentMemory unit='KiB'>1048576</currentMemory>
9119d9
+  <vcpu>1</vcpu>
9119d9
+  <os>
9119d9
+    <type arch='i686' machine='pc'>hvm</type>
9119d9
+    <boot dev='hd'/>
9119d9
+  </os>
9119d9
+  <clock offset='utc'/>
9119d9
+  <on_poweroff>destroy</on_poweroff>
9119d9
+  <on_reboot>restart</on_reboot>
9119d9
+  <on_crash>destroy</on_crash>
9119d9
+  <devices>
9119d9
+    <emulator>/usr/bin/qemu</emulator>
9119d9
+    <disk type='file' device='disk'>
9119d9
+      <driver name='qemu' type='qcow2' cache='none'/>
9119d9
+      <source file='/var/lib/libvirt/images/QEMUGuest1'/>
9119d9
+      <target dev='hda' bus='ide'/>
9119d9
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9119d9
+    </disk>
9119d9
+    <controller type='ide' index='0'/>
9119d9
+    <video>
9119d9
+      <model type='qxl' heads='1'/>
9119d9
+    </video>
9119d9
+    <memballoon model='virtio'/>
9119d9
+  </devices>
9119d9
+</domain>
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.args b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.args
9119d9
new file mode 100644
9119d9
index 0000000..c9eb535
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.args
9119d9
@@ -0,0 +1,6 @@
9119d9
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
9119d9
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic -nodefaults \
9119d9
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
9119d9
+-hda /var/lib/libvirt/images/QEMUGuest1 \
9119d9
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0\
9119d9
+,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.xml
9119d9
new file mode 100644
9119d9
index 0000000..9fc42af
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.xml
9119d9
@@ -0,0 +1,29 @@
9119d9
+<domain type='qemu'>
9119d9
+  <name>QEMUGuest1</name>
9119d9
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9119d9
+  <memory unit='KiB'>1048576</memory>
9119d9
+  <currentMemory unit='KiB'>1048576</currentMemory>
9119d9
+  <vcpu>1</vcpu>
9119d9
+  <os>
9119d9
+    <type arch='i686' machine='pc'>hvm</type>
9119d9
+    <boot dev='hd'/>
9119d9
+  </os>
9119d9
+  <clock offset='utc'/>
9119d9
+  <on_poweroff>destroy</on_poweroff>
9119d9
+  <on_reboot>restart</on_reboot>
9119d9
+  <on_crash>destroy</on_crash>
9119d9
+  <devices>
9119d9
+    <emulator>/usr/bin/qemu</emulator>
9119d9
+    <disk type='file' device='disk'>
9119d9
+      <driver name='qemu' type='qcow2' cache='none'/>
9119d9
+      <source file='/var/lib/libvirt/images/QEMUGuest1'/>
9119d9
+      <target dev='hda' bus='ide'/>
9119d9
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9119d9
+    </disk>
9119d9
+    <controller type='ide' index='0'/>
9119d9
+    <video>
9119d9
+      <model type='qxl' heads='1'/>
9119d9
+    </video>
9119d9
+    <memballoon model='virtio'/>
9119d9
+  </devices>
9119d9
+</domain>
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.args b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.args
9119d9
new file mode 100644
9119d9
index 0000000..a6ac6d8
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.args
9119d9
@@ -0,0 +1,5 @@
9119d9
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
9119d9
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic \
9119d9
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
9119d9
+-hda /var/lib/libvirt/images/QEMUGuest1 -net none -serial none -parallel none \
9119d9
+-vga qxl
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.xml
9119d9
new file mode 100644
9119d9
index 0000000..9fc42af
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.xml
9119d9
@@ -0,0 +1,29 @@
9119d9
+<domain type='qemu'>
9119d9
+  <name>QEMUGuest1</name>
9119d9
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9119d9
+  <memory unit='KiB'>1048576</memory>
9119d9
+  <currentMemory unit='KiB'>1048576</currentMemory>
9119d9
+  <vcpu>1</vcpu>
9119d9
+  <os>
9119d9
+    <type arch='i686' machine='pc'>hvm</type>
9119d9
+    <boot dev='hd'/>
9119d9
+  </os>
9119d9
+  <clock offset='utc'/>
9119d9
+  <on_poweroff>destroy</on_poweroff>
9119d9
+  <on_reboot>restart</on_reboot>
9119d9
+  <on_crash>destroy</on_crash>
9119d9
+  <devices>
9119d9
+    <emulator>/usr/bin/qemu</emulator>
9119d9
+    <disk type='file' device='disk'>
9119d9
+      <driver name='qemu' type='qcow2' cache='none'/>
9119d9
+      <source file='/var/lib/libvirt/images/QEMUGuest1'/>
9119d9
+      <target dev='hda' bus='ide'/>
9119d9
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9119d9
+    </disk>
9119d9
+    <controller type='ide' index='0'/>
9119d9
+    <video>
9119d9
+      <model type='qxl' heads='1'/>
9119d9
+    </video>
9119d9
+    <memballoon model='virtio'/>
9119d9
+  </devices>
9119d9
+</domain>
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.args b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.args
9119d9
new file mode 100644
9119d9
index 0000000..5fc41bb
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.args
9119d9
@@ -0,0 +1,8 @@
9119d9
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
9119d9
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic -nodefaults \
9119d9
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
9119d9
+-hda /var/lib/libvirt/images/QEMUGuest1 \
9119d9
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0\
9119d9
+,addr=0x2 -device qxl,id=video1,ram_size=67108864,vram_size=67108864,bus=pci.0\
9119d9
+,addr=0x4 \
9119d9
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.xml
9119d9
new file mode 100644
9119d9
index 0000000..0868f39
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.xml
9119d9
@@ -0,0 +1,32 @@
9119d9
+<domain type='qemu'>
9119d9
+  <name>QEMUGuest1</name>
9119d9
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9119d9
+  <memory unit='KiB'>1048576</memory>
9119d9
+  <currentMemory unit='KiB'>1048576</currentMemory>
9119d9
+  <vcpu>1</vcpu>
9119d9
+  <os>
9119d9
+    <type arch='i686' machine='pc'>hvm</type>
9119d9
+    <boot dev='hd'/>
9119d9
+  </os>
9119d9
+  <clock offset='utc'/>
9119d9
+  <on_poweroff>destroy</on_poweroff>
9119d9
+  <on_reboot>restart</on_reboot>
9119d9
+  <on_crash>destroy</on_crash>
9119d9
+  <devices>
9119d9
+    <emulator>/usr/bin/qemu</emulator>
9119d9
+    <disk type='file' device='disk'>
9119d9
+      <driver name='qemu' type='qcow2' cache='none'/>
9119d9
+      <source file='/var/lib/libvirt/images/QEMUGuest1'/>
9119d9
+      <target dev='hda' bus='ide'/>
9119d9
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9119d9
+    </disk>
9119d9
+    <controller type='ide' index='0'/>
9119d9
+    <video>
9119d9
+      <model type='qxl' heads='1'/>
9119d9
+    </video>
9119d9
+    <video>
9119d9
+      <model type='qxl' heads='1'/>
9119d9
+    </video>
9119d9
+    <memballoon model='virtio'/>
9119d9
+  </devices>
9119d9
+</domain>
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.args b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.args
9119d9
new file mode 100644
9119d9
index 0000000..208408e
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.args
9119d9
@@ -0,0 +1,7 @@
9119d9
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
9119d9
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic -nodefaults \
9119d9
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
9119d9
+-hda /var/lib/libvirt/images/QEMUGuest1 \
9119d9
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0\
9119d9
+,addr=0x2 -device qxl,id=video1,ram_size=67108864,vram_size=67108864,bus=pci.0\
9119d9
+,addr=0x4 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.xml
9119d9
new file mode 100644
9119d9
index 0000000..0868f39
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.xml
9119d9
@@ -0,0 +1,32 @@
9119d9
+<domain type='qemu'>
9119d9
+  <name>QEMUGuest1</name>
9119d9
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9119d9
+  <memory unit='KiB'>1048576</memory>
9119d9
+  <currentMemory unit='KiB'>1048576</currentMemory>
9119d9
+  <vcpu>1</vcpu>
9119d9
+  <os>
9119d9
+    <type arch='i686' machine='pc'>hvm</type>
9119d9
+    <boot dev='hd'/>
9119d9
+  </os>
9119d9
+  <clock offset='utc'/>
9119d9
+  <on_poweroff>destroy</on_poweroff>
9119d9
+  <on_reboot>restart</on_reboot>
9119d9
+  <on_crash>destroy</on_crash>
9119d9
+  <devices>
9119d9
+    <emulator>/usr/bin/qemu</emulator>
9119d9
+    <disk type='file' device='disk'>
9119d9
+      <driver name='qemu' type='qcow2' cache='none'/>
9119d9
+      <source file='/var/lib/libvirt/images/QEMUGuest1'/>
9119d9
+      <target dev='hda' bus='ide'/>
9119d9
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9119d9
+    </disk>
9119d9
+    <controller type='ide' index='0'/>
9119d9
+    <video>
9119d9
+      <model type='qxl' heads='1'/>
9119d9
+    </video>
9119d9
+    <video>
9119d9
+      <model type='qxl' heads='1'/>
9119d9
+    </video>
9119d9
+    <memballoon model='virtio'/>
9119d9
+  </devices>
9119d9
+</domain>
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-nodevice.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-nodevice.xml
9119d9
new file mode 100644
9119d9
index 0000000..0868f39
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-nodevice.xml
9119d9
@@ -0,0 +1,32 @@
9119d9
+<domain type='qemu'>
9119d9
+  <name>QEMUGuest1</name>
9119d9
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9119d9
+  <memory unit='KiB'>1048576</memory>
9119d9
+  <currentMemory unit='KiB'>1048576</currentMemory>
9119d9
+  <vcpu>1</vcpu>
9119d9
+  <os>
9119d9
+    <type arch='i686' machine='pc'>hvm</type>
9119d9
+    <boot dev='hd'/>
9119d9
+  </os>
9119d9
+  <clock offset='utc'/>
9119d9
+  <on_poweroff>destroy</on_poweroff>
9119d9
+  <on_reboot>restart</on_reboot>
9119d9
+  <on_crash>destroy</on_crash>
9119d9
+  <devices>
9119d9
+    <emulator>/usr/bin/qemu</emulator>
9119d9
+    <disk type='file' device='disk'>
9119d9
+      <driver name='qemu' type='qcow2' cache='none'/>
9119d9
+      <source file='/var/lib/libvirt/images/QEMUGuest1'/>
9119d9
+      <target dev='hda' bus='ide'/>
9119d9
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9119d9
+    </disk>
9119d9
+    <controller type='ide' index='0'/>
9119d9
+    <video>
9119d9
+      <model type='qxl' heads='1'/>
9119d9
+    </video>
9119d9
+    <video>
9119d9
+      <model type='qxl' heads='1'/>
9119d9
+    </video>
9119d9
+    <memballoon model='virtio'/>
9119d9
+  </devices>
9119d9
+</domain>
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.args b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.args
9119d9
new file mode 100644
9119d9
index 0000000..81e4aec
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.args
9119d9
@@ -0,0 +1,6 @@
9119d9
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
9119d9
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic -nodefaults \
9119d9
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
9119d9
+-hda /var/lib/libvirt/images/QEMUGuest1 \
9119d9
+-device VGA,id=video0,vgamem_mb=16,bus=pci.0,addr=0x2 \
9119d9
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.xml
9119d9
new file mode 100644
9119d9
index 0000000..9b1ddfc
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.xml
9119d9
@@ -0,0 +1,29 @@
9119d9
+<domain type='qemu'>
9119d9
+  <name>QEMUGuest1</name>
9119d9
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9119d9
+  <memory unit='KiB'>1048576</memory>
9119d9
+  <currentMemory unit='KiB'>1048576</currentMemory>
9119d9
+  <vcpu>1</vcpu>
9119d9
+  <os>
9119d9
+    <type arch='i686' machine='pc'>hvm</type>
9119d9
+    <boot dev='hd'/>
9119d9
+  </os>
9119d9
+  <clock offset='utc'/>
9119d9
+  <on_poweroff>destroy</on_poweroff>
9119d9
+  <on_reboot>restart</on_reboot>
9119d9
+  <on_crash>destroy</on_crash>
9119d9
+  <devices>
9119d9
+    <emulator>/usr/bin/qemu</emulator>
9119d9
+    <disk type='file' device='disk'>
9119d9
+      <driver name='qemu' type='qcow2' cache='none'/>
9119d9
+      <source file='/var/lib/libvirt/images/QEMUGuest1'/>
9119d9
+      <target dev='hda' bus='ide'/>
9119d9
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9119d9
+    </disk>
9119d9
+    <controller type='ide' index='0'/>
9119d9
+    <video>
9119d9
+      <model type='vga' vram='16384' heads='1'/>
9119d9
+    </video>
9119d9
+    <memballoon model='virtio'/>
9119d9
+  </devices>
9119d9
+</domain>
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.args b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.args
9119d9
new file mode 100644
9119d9
index 0000000..f822280
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.args
9119d9
@@ -0,0 +1,6 @@
9119d9
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
9119d9
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic -nodefaults \
9119d9
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
9119d9
+-hda /var/lib/libvirt/images/QEMUGuest1 \
9119d9
+-device VGA,id=video0,bus=pci.0,addr=0x2 \
9119d9
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.xml
9119d9
new file mode 100644
9119d9
index 0000000..9b1ddfc
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.xml
9119d9
@@ -0,0 +1,29 @@
9119d9
+<domain type='qemu'>
9119d9
+  <name>QEMUGuest1</name>
9119d9
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9119d9
+  <memory unit='KiB'>1048576</memory>
9119d9
+  <currentMemory unit='KiB'>1048576</currentMemory>
9119d9
+  <vcpu>1</vcpu>
9119d9
+  <os>
9119d9
+    <type arch='i686' machine='pc'>hvm</type>
9119d9
+    <boot dev='hd'/>
9119d9
+  </os>
9119d9
+  <clock offset='utc'/>
9119d9
+  <on_poweroff>destroy</on_poweroff>
9119d9
+  <on_reboot>restart</on_reboot>
9119d9
+  <on_crash>destroy</on_crash>
9119d9
+  <devices>
9119d9
+    <emulator>/usr/bin/qemu</emulator>
9119d9
+    <disk type='file' device='disk'>
9119d9
+      <driver name='qemu' type='qcow2' cache='none'/>
9119d9
+      <source file='/var/lib/libvirt/images/QEMUGuest1'/>
9119d9
+      <target dev='hda' bus='ide'/>
9119d9
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9119d9
+    </disk>
9119d9
+    <controller type='ide' index='0'/>
9119d9
+    <video>
9119d9
+      <model type='vga' vram='16384' heads='1'/>
9119d9
+    </video>
9119d9
+    <memballoon model='virtio'/>
9119d9
+  </devices>
9119d9
+</domain>
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-nodevice.args b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-nodevice.args
9119d9
new file mode 100644
9119d9
index 0000000..7b5f151
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-nodevice.args
9119d9
@@ -0,0 +1,5 @@
9119d9
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
9119d9
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic \
9119d9
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
9119d9
+-hda /var/lib/libvirt/images/QEMUGuest1 -net none -serial none -parallel none \
9119d9
+-vga std
9119d9
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-nodevice.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-nodevice.xml
9119d9
new file mode 100644
9119d9
index 0000000..9b1ddfc
9119d9
--- /dev/null
9119d9
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-nodevice.xml
9119d9
@@ -0,0 +1,29 @@
9119d9
+<domain type='qemu'>
9119d9
+  <name>QEMUGuest1</name>
9119d9
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
9119d9
+  <memory unit='KiB'>1048576</memory>
9119d9
+  <currentMemory unit='KiB'>1048576</currentMemory>
9119d9
+  <vcpu>1</vcpu>
9119d9
+  <os>
9119d9
+    <type arch='i686' machine='pc'>hvm</type>
9119d9
+    <boot dev='hd'/>
9119d9
+  </os>
9119d9
+  <clock offset='utc'/>
9119d9
+  <on_poweroff>destroy</on_poweroff>
9119d9
+  <on_reboot>restart</on_reboot>
9119d9
+  <on_crash>destroy</on_crash>
9119d9
+  <devices>
9119d9
+    <emulator>/usr/bin/qemu</emulator>
9119d9
+    <disk type='file' device='disk'>
9119d9
+      <driver name='qemu' type='qcow2' cache='none'/>
9119d9
+      <source file='/var/lib/libvirt/images/QEMUGuest1'/>
9119d9
+      <target dev='hda' bus='ide'/>
9119d9
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
9119d9
+    </disk>
9119d9
+    <controller type='ide' index='0'/>
9119d9
+    <video>
9119d9
+      <model type='vga' vram='16384' heads='1'/>
9119d9
+    </video>
9119d9
+    <memballoon model='virtio'/>
9119d9
+  </devices>
9119d9
+</domain>
9119d9
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
9119d9
index 97af90a..24e9740 100644
9119d9
--- a/tests/qemuxml2argvtest.c
9119d9
+++ b/tests/qemuxml2argvtest.c
9119d9
@@ -1322,6 +1322,22 @@ mymain(void)
9119d9
             QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
9119d9
             QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_QXL_VGA,
9119d9
             QEMU_CAPS_DEVICE_PCI_BRIDGE);
9119d9
+    DO_TEST("video-vga-nodevice", QEMU_CAPS_VGA);
9119d9
+    DO_TEST("video-vga-device", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VGA,
9119d9
+            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
9119d9
+    DO_TEST("video-vga-device-vgamem", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VGA,
9119d9
+            QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_VGAMEM);
9119d9
+    DO_TEST("video-qxl-nodevice", QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL);
9119d9
+    DO_TEST("video-qxl-device", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_QXL_VGA,
9119d9
+            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
9119d9
+    DO_TEST("video-qxl-device-vgamem", QEMU_CAPS_DEVICE,
9119d9
+            QEMU_CAPS_DEVICE_QXL_VGA, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
9119d9
+    DO_TEST_FAILURE("video-qxl-sec-nodevice", QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL);
9119d9
+    DO_TEST("video-qxl-sec-device", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_QXL_VGA,
9119d9
+            QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
9119d9
+    DO_TEST("video-qxl-sec-device-vgamem", QEMU_CAPS_DEVICE,
9119d9
+            QEMU_CAPS_DEVICE_QXL_VGA, QEMU_CAPS_DEVICE_QXL,
9119d9
+            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
9119d9
 
9119d9
     DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_RNG,
9119d9
             QEMU_CAPS_OBJECT_RNG_RANDOM);
9119d9
-- 
9119d9
2.1.3
9119d9