From fff9e25a2b2f8617aebda99e20950ae305f60e52 Mon Sep 17 00:00:00 2001 From: Maciej Wolny Date: Thu, 10 May 2018 11:53:57 +0100 Subject: [PATCH] conf: Add gl property to graphics of type sdl in domain config Support OpenGL accelerated rendering when using SDL graphics in the domain config. Add associated test and documentation. Signed-off-by: Maciej Wolny Reviewed-by: John Ferlan --- docs/formatdomain.html.in | 6 +++ docs/schemas/domaincommon.rng | 8 ++++ src/conf/domain_conf.c | 43 +++++++++++++++++- src/conf/domain_conf.h | 1 + .../video-virtio-gpu-sdl-gl.xml | 38 ++++++++++++++++ .../video-virtio-gpu-sdl-gl.xml | 45 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 7 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.xml create mode 100644 tests/qemuxml2xmloutdata/video-virtio-gpu-sdl-gl.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 63665906ab..fdff0aac97 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -6211,6 +6211,12 @@ qemu-kvm -net nic,model=? /dev/null and an optional fullscreen attribute accepting values yes or no.

+ +

+ You can use a gl with the enable="yes" + property to enable OpenGL support in SDL. Likewise you can + explicitly disable OpenGL support with enable="no". +

vnc
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ff539607cc..71ac3d079c 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3010,6 +3010,14 @@ + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d38a775f21..2a4a2b8521 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13511,11 +13511,18 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def, static int virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def, - xmlNodePtr node) + xmlNodePtr node, + xmlXPathContextPtr ctxt) { + xmlNodePtr save = ctxt->node; + char *enable = NULL; + int enableVal; + xmlNodePtr glNode; char *fullscreen = virXMLPropString(node, "fullscreen"); int ret = -1; + ctxt->node = node; + if (fullscreen != NULL) { if (STREQ(fullscreen, "yes")) { def->data.sdl.fullscreen = true; @@ -13533,9 +13540,29 @@ virDomainGraphicsDefParseXMLSDL(virDomainGraphicsDefPtr def, def->data.sdl.xauth = virXMLPropString(node, "xauth"); def->data.sdl.display = virXMLPropString(node, "display"); + glNode = virXPathNode("./gl", ctxt); + if (glNode) { + enable = virXMLPropString(glNode, "enable"); + if (!enable) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("sdl gl element missing enable")); + goto cleanup; + } + + enableVal = virTristateBoolTypeFromString(enable); + if (enableVal < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown enable value '%s'"), enable); + goto cleanup; + } + def->data.sdl.gl = enableVal; + } + ret = 0; cleanup: VIR_FREE(fullscreen); + VIR_FREE(enable); + ctxt->node = save; return ret; } @@ -13964,7 +13991,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, goto error; break; case VIR_DOMAIN_GRAPHICS_TYPE_SDL: - if (virDomainGraphicsDefParseXMLSDL(def, node) < 0) + if (virDomainGraphicsDefParseXMLSDL(def, node, ctxt) < 0) goto error; break; case VIR_DOMAIN_GRAPHICS_TYPE_RDP: @@ -25736,6 +25763,18 @@ virDomainGraphicsDefFormat(virBufferPtr buf, if (def->data.sdl.fullscreen) virBufferAddLit(buf, " fullscreen='yes'"); + if (!children && def->data.sdl.gl != VIR_TRISTATE_BOOL_ABSENT) { + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + children = true; + } + + if (def->data.sdl.gl != VIR_TRISTATE_BOOL_ABSENT) { + virBufferAsprintf(buf, "data.sdl.gl)); + virBufferAddLit(buf, "/>\n"); + } + break; case VIR_DOMAIN_GRAPHICS_TYPE_RDP: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 07d04fb2f9..28704f9b5f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1599,6 +1599,7 @@ struct _virDomainGraphicsDef { char *display; char *xauth; bool fullscreen; + virTristateBool gl; } sdl; struct { int port; diff --git a/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.xml b/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.xml new file mode 100644 index 0000000000..9dea73fbe4 --- /dev/null +++ b/tests/qemuxml2argvdata/video-virtio-gpu-sdl-gl.xml @@ -0,0 +1,38 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +
+ + + + + + + + + + + + + diff --git a/tests/qemuxml2xmloutdata/video-virtio-gpu-sdl-gl.xml b/tests/qemuxml2xmloutdata/video-virtio-gpu-sdl-gl.xml new file mode 100644 index 0000000000..da03dd5da8 --- /dev/null +++ b/tests/qemuxml2xmloutdata/video-virtio-gpu-sdl-gl.xml @@ -0,0 +1,45 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +
+ + +
+ + +
+ + + + + + + +