qemu 2.5 provides virtio video device. Similarly to other devices,
it can be used with -vga virtio or -device virtio-vga for primary
devices, or -device virtio-gpu for non-vga devices.
Signed-off-by: Marc-André Lureau <marcandre.lureau(a)gmail.com>
---
docs/formatdomain.html.in | 5 +++--
docs/schemas/domaincommon.rng | 1 +
src/conf/domain_conf.c | 3 ++-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 11 +++++++++++
src/qemu/qemu_capabilities.h | 3 +++
src/qemu/qemu_command.c | 19 +++++++++++++++----
tests/qemucapabilitiesdata/caps_2.4.0-1.caps | 3 +++
8 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index e5e0167..df29fa1 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5153,8 +5153,9 @@ qemu-kvm -net nic,model=? /dev/null
<p>
The <code>model</code> element has a mandatory
<code>type</code>
attribute which takes the value "vga", "cirrus",
"vmvga", "xen",
- "vbox", or "qxl" (<span class="since">since
0.8.6</span>) depending
- on the hypervisor features available.
+ "vbox", "qxl" (<span class="since">since
0.8.6</span>) or
+ "virtio" (<span class="since">since
1.2.22</span>)
+ depending on the hypervisor features available.
</p>
<p>
You can provide the amount of video memory in kibibytes (blocks of
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 994face..228f062 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2921,6 +2921,7 @@
<value>vmvga</value>
<value>xen</value>
<value>vbox</value>
+ <value>virtio</value>
</choice>
</attribute>
<group>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0ac7dbf..15413dc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -532,7 +532,8 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
"xen",
"vbox",
"qxl",
- "parallels")
+ "parallels",
+ "virtio")
VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST,
"mouse",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8d43ee6..c26c56d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1374,6 +1374,7 @@ typedef enum {
VIR_DOMAIN_VIDEO_TYPE_VBOX,
VIR_DOMAIN_VIDEO_TYPE_QXL,
VIR_DOMAIN_VIDEO_TYPE_PARALLELS, /* pseudo device for VNC in containers */
+ VIR_DOMAIN_VIDEO_TYPE_VIRTIO,
VIR_DOMAIN_VIDEO_TYPE_LAST
} virDomainVideoType;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 2813212..357980b 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -301,6 +301,9 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"gic-version",
"incoming-defer", /* 200 */
+ "vga-virtio",
+ "virtio-gpu",
+ "virtio-vga",
);
@@ -1117,6 +1120,8 @@ virQEMUCapsComputeCmdFlags(const char *help,
const char *nl = strstr(p, "\n");
if (strstr(p, "|qxl"))
virQEMUCapsSet(qemuCaps, QEMU_CAPS_VGA_QXL);
+ if (strstr(p, "|virtio"))
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_VGA_VIRTIO);
if ((p = strstr(p, "|none")) && p < nl)
virQEMUCapsSet(qemuCaps, QEMU_CAPS_VGA_NONE);
}
@@ -1543,6 +1548,9 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
{ "virtio-net-ccw", QEMU_CAPS_DEVICE_VIRTIO_NET },
{ "virtio-net-s390", QEMU_CAPS_DEVICE_VIRTIO_NET },
{ "virtio-net-device", QEMU_CAPS_DEVICE_VIRTIO_NET },
+ { "virtio-gpu-pci", QEMU_CAPS_DEVICE_VIRTIO_GPU },
+ { "virtio-gpu-device", QEMU_CAPS_DEVICE_VIRTIO_GPU },
+ { "virtio-vga", QEMU_CAPS_DEVICE_VIRTIO_VGA },
};
static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
@@ -2399,6 +2407,9 @@ virQEMUCapsProbeQMPObjects(virQEMUCapsPtr qemuCaps,
/* If qemu supports newer -device qxl it supports -vga qxl as well */
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL))
virQEMUCapsSet(qemuCaps, QEMU_CAPS_VGA_QXL);
+ /* If qemu supports newer -device virtio-gpu-pci it supports -vga virtio as well */
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_GPU))
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_VGA_VIRTIO);
return 0;
}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index e3e40e5..cbe28ae 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -327,6 +327,9 @@ typedef enum {
/* 200 */
QEMU_CAPS_INCOMING_DEFER, /* -incoming defer and migrate_incoming */
+ QEMU_CAPS_VGA_VIRTIO, /* The 'virtio' arg for '-vga' */
+ QEMU_CAPS_DEVICE_VIRTIO_GPU, /* -device virtio-gpu-* */
+ QEMU_CAPS_DEVICE_VIRTIO_VGA, /* -device virtio-vga */
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ef5ef93..787e3bb 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -104,7 +104,8 @@ VIR_ENUM_IMPL(qemuVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
"", /* no arg needed for xen */
"", /* don't support vbox */
"qxl",
- "" /* don't support parallels */);
+ "", /* don't support parallels */
+ "virtio");
VIR_ENUM_DECL(qemuDeviceVideo)
@@ -115,7 +116,8 @@ VIR_ENUM_IMPL(qemuDeviceVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
"", /* no device for xen */
"", /* don't support vbox */
"qxl-vga",
- "" /* don't support parallels */);
+ "", /* don't support parallels */
+ "virtio-vga");
VIR_ENUM_DECL(qemuSoundCodec)
@@ -10496,8 +10498,10 @@ qemuBuildCommandLine(virConnectPtr conn,
(primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMWARE_SVGA)) ||
(primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_QXL &&
- virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL_VGA)))
- ) {
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL_VGA)) ||
+ (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VIRTIO &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_VGA)))
+ ) {
for (i = 0; i < def->nvideos; i++) {
char *str;
virCommandAddArg(cmd, "-device");
@@ -10518,6 +10522,13 @@ qemuBuildCommandLine(virConnectPtr conn,
goto error;
}
+ if ((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VIRTIO) &&
+ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VIRTIO)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("This QEMU does not support virtio graphics
adapters"));
+ goto error;
+ }
+
const char *vgastr = qemuVideoTypeToString(primaryVideoType);
if (!vgastr || STREQ(vgastr, "")) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
diff --git a/tests/qemucapabilitiesdata/caps_2.4.0-1.caps
b/tests/qemucapabilitiesdata/caps_2.4.0-1.caps
index 6694b7d..51480e8 100644
--- a/tests/qemucapabilitiesdata/caps_2.4.0-1.caps
+++ b/tests/qemucapabilitiesdata/caps_2.4.0-1.caps
@@ -162,4 +162,7 @@
<flag name='e1000'/>
<flag name='virtio-net'/>
<flag name='incoming-defer'/>
+ <flag name='vga-virtio'/>
+ <flag name='virtio-vga'/>
+ <flag name='virtio-gpu'/>
</qemuCaps>
--
2.5.0