diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f1e6781a7a..1003a0d418 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4911,6 +4911,20 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,
/* QEMU accepts bytes for vram_size. */
virBufferAsprintf(&buf, ",vram_size=%u", video->vram * 1024);
}
+ } else if (video->vram &&
+ ((video->type == VIR_DOMAIN_VIDEO_TYPE_VGA &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
+ (video->type == VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_VMWARE_SVGA_VGAMEM)))) {
+
+ if (video->vram < 1024) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ "%s", _("value for 'vram' must be at least 1 MiB "
+ "(1024 KiB)"));
+ goto error;
+ }
+
+ virBufferAsprintf(&buf, ",vgamem_mb=%u", video->vram / 1024);
}
if (qemuBuildDeviceAddressStr(&buf, def, &video->info, qemuCaps) < 0)
@@ -7523,7 +7537,7 @@ qemuBuildShmemDevCmd(virCommandPtr cmd,
}
if (shmem->size < 1024 * 1024) {
virReportError(VIR_ERR_XML_ERROR, "%s",
- _("shmem size must be at least 1 MiB"));
+ _("shmem size must be at least 1 MiB (1024 KiB)"));
goto error;
}
virBufferAsprintf(&buf, ",size=%llum", shmem->size >> 20);
@@ -9255,6 +9269,26 @@ qemuBuildCommandLine(virConnectPtr conn,
dev, vram * 1024);
}
}
+
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
+ def->videos[0]->vram &&
+ ((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VGA &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
+ (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_VMWARE_SVGA_VGAMEM)))) {
+ unsigned int vram = def->videos[0]->vram;
+
+ if (vram < 1024) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ "%s", _("value for 'vgamem' must be at "
+ "least 1 MiB (1024 KiB)"));
+ goto error;
+ }
+
+ virCommandAddArg(cmd, "-global");
+ virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u",
+ dev, vram / 1024);
+ }
}
if (def->nvideos > 1) {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.args b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.args
new file mode 100644
index 0000000000..c9eb53578b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.args
@@ -0,0 +1,6 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-hda /var/lib/libvirt/images/QEMUGuest1 \
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0\
+,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.xml
new file mode 100644
index 0000000000..9fc42af9a9
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.xml
@@ -0,0 +1,29 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 1048576
+ 1048576
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.args b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.args
new file mode 100644
index 0000000000..c9eb53578b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.args
@@ -0,0 +1,6 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-hda /var/lib/libvirt/images/QEMUGuest1 \
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0\
+,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.xml
new file mode 100644
index 0000000000..9fc42af9a9
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device.xml
@@ -0,0 +1,29 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 1048576
+ 1048576
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.args b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.args
new file mode 100644
index 0000000000..a6ac6d8fe3
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.args
@@ -0,0 +1,5 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-hda /var/lib/libvirt/images/QEMUGuest1 -net none -serial none -parallel none \
+-vga qxl
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.xml
new file mode 100644
index 0000000000..9fc42af9a9
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-nodevice.xml
@@ -0,0 +1,29 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 1048576
+ 1048576
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.args b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.args
new file mode 100644
index 0000000000..5fc41bbfa2
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.args
@@ -0,0 +1,8 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-hda /var/lib/libvirt/images/QEMUGuest1 \
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0\
+,addr=0x2 -device qxl,id=video1,ram_size=67108864,vram_size=67108864,bus=pci.0\
+,addr=0x4 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.xml
new file mode 100644
index 0000000000..0868f397a0
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.xml
@@ -0,0 +1,32 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 1048576
+ 1048576
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.args b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.args
new file mode 100644
index 0000000000..208408e5ee
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.args
@@ -0,0 +1,7 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-hda /var/lib/libvirt/images/QEMUGuest1 \
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0\
+,addr=0x2 -device qxl,id=video1,ram_size=67108864,vram_size=67108864,bus=pci.0\
+,addr=0x4 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.xml
new file mode 100644
index 0000000000..0868f397a0
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device.xml
@@ -0,0 +1,32 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 1048576
+ 1048576
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-nodevice.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-nodevice.xml
new file mode 100644
index 0000000000..0868f397a0
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-nodevice.xml
@@ -0,0 +1,32 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 1048576
+ 1048576
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.args b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.args
new file mode 100644
index 0000000000..81e4aec937
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.args
@@ -0,0 +1,6 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-hda /var/lib/libvirt/images/QEMUGuest1 \
+-device VGA,id=video0,vgamem_mb=16,bus=pci.0,addr=0x2 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.xml
new file mode 100644
index 0000000000..9b1ddfc147
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device-vgamem.xml
@@ -0,0 +1,29 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 1048576
+ 1048576
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.args b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.args
new file mode 100644
index 0000000000..f822280108
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.args
@@ -0,0 +1,6 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-hda /var/lib/libvirt/images/QEMUGuest1 \
+-device VGA,id=video0,bus=pci.0,addr=0x2 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.xml
new file mode 100644
index 0000000000..9b1ddfc147
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-device.xml
@@ -0,0 +1,29 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 1048576
+ 1048576
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-nodevice.args b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-nodevice.args
new file mode 100644
index 0000000000..7b5f15149a
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-nodevice.args
@@ -0,0 +1,5 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-hda /var/lib/libvirt/images/QEMUGuest1 -net none -serial none -parallel none \
+-vga std
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-vga-nodevice.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-nodevice.xml
new file mode 100644
index 0000000000..9b1ddfc147
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-vga-nodevice.xml
@@ -0,0 +1,29 @@
+
+ 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 eb02b38a9a..315e1f4140 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1353,6 +1353,22 @@ mymain(void)
QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_QXL_VGA,
QEMU_CAPS_DEVICE_PCI_BRIDGE);
+ DO_TEST("video-vga-nodevice", QEMU_CAPS_VGA);
+ DO_TEST("video-vga-device", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VGA,
+ QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
+ DO_TEST("video-vga-device-vgamem", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VGA,
+ QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_VGAMEM);
+ DO_TEST("video-qxl-nodevice", QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL);
+ DO_TEST("video-qxl-device", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_QXL_VGA,
+ QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
+ DO_TEST("video-qxl-device-vgamem", QEMU_CAPS_DEVICE,
+ QEMU_CAPS_DEVICE_QXL_VGA, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
+ DO_TEST_FAILURE("video-qxl-sec-nodevice", QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL);
+ DO_TEST("video-qxl-sec-device", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_QXL_VGA,
+ QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
+ DO_TEST("video-qxl-sec-device-vgamem", QEMU_CAPS_DEVICE,
+ QEMU_CAPS_DEVICE_QXL_VGA, QEMU_CAPS_DEVICE_QXL,
+ QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_RNG,
QEMU_CAPS_OBJECT_RNG_RANDOM);