[PATCH 5/6] RFC qemu: add spice opengl support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add Spice graphics gl attribute. qemu 2.6 should have -spice gl=on
argument to enable opengl rendering context. This is necessary
to actually enable virgl rendering.

Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxx>
---
 docs/formatdomain.html.in                       |  6 ++++++
 docs/schemas/domaincommon.rng                   |  5 +++++
 src/conf/domain_conf.c                          | 11 +++++++++++
 src/conf/domain_conf.h                          |  1 +
 src/qemu/qemu_capabilities.c                    |  2 ++
 src/qemu/qemu_capabilities.h                    |  1 +
 src/qemu/qemu_command.c                         | 10 ++++++++++
 tests/qemucapabilitiesdata/caps_2.5.0-1.caps    |  1 +
 tests/qemucapabilitiesdata/caps_2.5.0-1.replies |  4 ++++
 9 files changed, 41 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index df29fa1..d7e1d49 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4979,6 +4979,12 @@ qemu-kvm -net nic,model=? /dev/null
               0.8.8</span>); and <code>usbredir</code>
               (<span class="since">since 0.9.12</span>).
             </p>
+            <p>
+              Spice may provide accelerated server-side rendering with
+              OpenGL. You can enable OpenGL support with
+              <code>gl</code> attribute. It is disabled by default.
+              (<span class="since">since 1.1.22</span>).
+            </p>
             <pre>
   &lt;graphics type='spice' port='-1' tlsPort='-1' autoport='yes'&gt;
     &lt;channel name='main' mode='secure'/&gt;
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 228f062..8f4d2ac 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2711,6 +2711,11 @@
               </choice>
             </attribute>
           </optional>
+          <optional>
+            <attribute name="gl">
+              <ref name="virYesNo"/>
+            </attribute>
+          </optional>
           <interleave>
             <ref name="listenElements"/>
             <zeroOrMore>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 15413dc..c4bdd11 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10918,6 +10918,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
         char *port = virXMLPropString(node, "port");
         char *tlsPort;
         char *autoport;
+        char *gl;
         char *defaultMode;
         int defaultModeVal;
 
@@ -10952,6 +10953,12 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
             VIR_FREE(autoport);
         }
 
+        if ((gl = virXMLPropString(node, "gl")) != NULL) {
+            if (STREQ(gl, "yes"))
+                def->data.spice.gl = true;
+            VIR_FREE(gl);
+        }
+
         def->data.spice.defaultMode = VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY;
 
         if ((defaultMode = virXMLPropString(node, "defaultMode")) != NULL) {
@@ -21196,6 +21203,10 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
         break;
 
     case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
+        if (def->data.spice.gl)
+            virBufferAsprintf(buf, " gl='%s'",
+                              virTristateBoolTypeToString(def->data.spice.gl));
+
         if (def->data.spice.port)
             virBufferAsprintf(buf, " port='%d'",
                               def->data.spice.port);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c26c56d..1a9be96 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1579,6 +1579,7 @@ struct _virDomainGraphicsDef {
             int streaming;
             int copypaste; /* enum virTristateBool */
             int filetransfer; /* enum virTristateBool */
+            int gl; /* enum virTristateBool */
         } spice;
     } data;
     /* nListens, listens, and *port are only useful if type is vnc,
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 29763f9..48ef48e 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -305,6 +305,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "virtio-gpu",
               "virtio-vga",
               "virtio-gpu.virgl",
+              "spice-gl",
     );
 
 
@@ -2596,6 +2597,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
     { "drive", "throttling.bps-total-max", QEMU_CAPS_DRIVE_IOTUNE_MAX},
     { "machine", "aes-key-wrap", QEMU_CAPS_AES_KEY_WRAP },
     { "machine", "dea-key-wrap", QEMU_CAPS_DEA_KEY_WRAP },
+    { "spice", "gl", QEMU_CAPS_SPICE_GL },
 };
 
 static int
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 17eed58..a43bb10 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -331,6 +331,7 @@ typedef enum {
     QEMU_CAPS_DEVICE_VIRTIO_GPU, /* -device virtio-gpu-* */
     QEMU_CAPS_DEVICE_VIRTIO_VGA, /* -device virtio-vga */
     QEMU_CAPS_DEVICE_VIRTIO_GPU_VIRGL, /* -device virtio-gpu-*.virgl */
+    QEMU_CAPS_SPICE_GL, /* -spice gl */
 
     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 e8187b7..0c543b5 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8443,6 +8443,16 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
         }
     }
 
+    if (graphics->data.spice.gl == VIR_TRISTATE_BOOL_YES) {
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_GL)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("This QEMU can't enable spice OpenGL support"));
+            goto error;
+        } else {
+            virBufferAddLit(&opt, ",gl=on");
+        }
+    }
+
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEAMLESS_MIGRATION)) {
         /* If qemu supports seamless migration turn it
          * unconditionally on. If migration destination
diff --git a/tests/qemucapabilitiesdata/caps_2.5.0-1.caps b/tests/qemucapabilitiesdata/caps_2.5.0-1.caps
index 437eba9..67b5a6c 100644
--- a/tests/qemucapabilitiesdata/caps_2.5.0-1.caps
+++ b/tests/qemucapabilitiesdata/caps_2.5.0-1.caps
@@ -166,4 +166,5 @@
     <flag name='virtio-gpu'/>
     <flag name='virtio-vga'/>
     <flag name='virtio-gpu.virgl'/>
+    <flag name='spice-gl'/>
   </qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_2.5.0-1.replies b/tests/qemucapabilitiesdata/caps_2.5.0-1.replies
index d90a74b..5452c0f 100644
--- a/tests/qemucapabilitiesdata/caps_2.5.0-1.replies
+++ b/tests/qemucapabilitiesdata/caps_2.5.0-1.replies
@@ -3120,6 +3120,10 @@
     {
       "parameters": [
         {
+          "name": "gl",
+          "type": "boolean"
+        },
+        {
           "name": "seamless-migration",
           "type": "boolean"
         },
-- 
2.5.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]