]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: add rendernode argument
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 14 Feb 2017 21:04:13 +0000 (01:04 +0400)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 17 Feb 2017 14:47:58 +0000 (15:47 +0100)
Add a new attribute 'rendernode' to <gl> spice element.

Give it to QEMU if qemu supports it (queued for 2.9).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_capabilities.c
src/qemu/qemu_capabilities.h
src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.args
tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.xml
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-spice-gl.xml

index 0a115f5dcda80140c3569db060a0f9c782824162..b69bd4c44c5969f88ef02d864f543bf6cb3afb46 100644 (file)
@@ -5619,7 +5619,7 @@ qemu-kvm -net nic,model=? /dev/null
   &lt;clipboard copypaste='no'/&gt;
   &lt;mouse mode='client'/&gt;
   &lt;filetransfer enable='no'/&gt;
-  &lt;gl enable='yes'/&gt;
+  &lt;gl enable='yes' rendernode='/dev/dri/by-path/pci-0000:00:02.0-render'/&gt;
 &lt;/graphics&gt;</pre>
             <p>
               Spice supports variable compression settings for audio, images and
@@ -5665,6 +5665,11 @@ qemu-kvm -net nic,model=? /dev/null
               the <code>gl</code> element, by setting the <code>enable</code>
               property. (QEMU only, <span class="since">since 1.3.3</span>).
             </p>
+            <p>
+              By default, QEMU will pick the first available GPU DRM render node.
+              You may specify a DRM render node path to use instead. (QEMU only,
+              <span class="since">since 3.1.0</span>).
+            </p>
           </dd>
           <dt><code>rdp</code></dt>
           <dd>
index d715bff29d05d8152572503c5cf44791c6e5688a..c5f101325e0b01a9f7dc3233c894686a716bda59 100644 (file)
                 <attribute name="enable">
                   <ref name="virYesNo"/>
                 </attribute>
+                <optional>
+                  <attribute name="rendernode">
+                    <ref name="absFilePath"/>
+                  </attribute>
+                </optional>
                 <empty/>
               </element>
             </optional>
index 1bc72a4e90214f6aa10aa98e8deebc8235b3d85f..a56ea82ddada0c9c1058889128ecfc7851c0f11e 100644 (file)
@@ -1300,6 +1300,7 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
         break;
 
     case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
+        VIR_FREE(def->data.spice.rendernode);
         VIR_FREE(def->data.spice.keymap);
         virDomainGraphicsAuthDefClear(&def->data.spice.auth);
         break;
@@ -12141,11 +12142,13 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def,
                 def->data.spice.filetransfer = enableVal;
             } else if (xmlStrEqual(cur->name, BAD_CAST "gl")) {
                 char *enable = virXMLPropString(cur, "enable");
+                char *rendernode = virXMLPropString(cur, "rendernode");
                 int enableVal;
 
                 if (!enable) {
                     virReportError(VIR_ERR_XML_ERROR, "%s",
                                    _("spice gl element missing enable"));
+                    VIR_FREE(rendernode);
                     goto error;
                 }
 
@@ -12154,11 +12157,14 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def,
                     virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                    _("unknown enable value '%s'"), enable);
                     VIR_FREE(enable);
+                    VIR_FREE(rendernode);
                     goto error;
                 }
                 VIR_FREE(enable);
 
                 def->data.spice.gl = enableVal;
+                def->data.spice.rendernode = rendernode;
+
             } else if (xmlStrEqual(cur->name, BAD_CAST "mouse")) {
                 char *mode = virXMLPropString(cur, "mode");
                 int modeVal;
@@ -22839,6 +22845,17 @@ virDomainGraphicsListenDefFormatAddr(virBufferPtr buf,
         virBufferAsprintf(buf, " listen='%s'", glisten->address);
 }
 
+static void
+virDomainSpiceGLDefFormat(virBufferPtr buf, virDomainGraphicsDefPtr def)
+{
+    if (def->data.spice.gl == VIR_TRISTATE_BOOL_ABSENT)
+        return;
+
+    virBufferAsprintf(buf, "<gl enable='%s'",
+                      virTristateBoolTypeToString(def->data.spice.gl));
+    virBufferEscapeString(buf, " rendernode='%s'", def->data.spice.rendernode);
+    virBufferAddLit(buf, "/>\n");
+}
 
 static int
 virDomainGraphicsDefFormat(virBufferPtr buf,
@@ -23082,9 +23099,8 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
         if (def->data.spice.filetransfer)
             virBufferAsprintf(buf, "<filetransfer enable='%s'/>\n",
                               virTristateBoolTypeToString(def->data.spice.filetransfer));
-        if (def->data.spice.gl)
-            virBufferAsprintf(buf, "<gl enable='%s'/>\n",
-                              virTristateBoolTypeToString(def->data.spice.gl));
+
+        virDomainSpiceGLDefFormat(buf, def);
     }
 
     if (children) {
index dd79206f69f41da837aea2a79079a7caa9b436b0..7e1afa47516bd7e45c6d2cc5b72978add53b6bef 100644 (file)
@@ -1544,6 +1544,7 @@ struct _virDomainGraphicsDef {
             virTristateBool copypaste;
             virTristateBool filetransfer;
             virTristateBool gl;
+            char *rendernode;
         } spice;
     } data;
     /* nListens, listens, and *port are only useful if type is vnc,
index 399e3144762b33a595f1440b96a5b24b8fdf7ade..e851eec7a7a4bbc9084cb537db94b4e55e78658f 100644 (file)
@@ -357,6 +357,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
 
               "query-cpu-model-expansion", /* 245 */
               "virtio-net.host_mtu",
+              "spice-rendernode",
     );
 
 
@@ -2950,6 +2951,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
     { "spice", "unix", QEMU_CAPS_SPICE_UNIX },
     { "drive", "throttling.bps-total-max-length", QEMU_CAPS_DRIVE_IOTUNE_MAX_LENGTH },
     { "drive", "throttling.group", QEMU_CAPS_DRIVE_IOTUNE_GROUP },
+    { "spice", "rendernode", QEMU_CAPS_SPICE_RENDERNODE },
 };
 
 static int
index 95bb67d4481295a82211c357bca5f89c4f0edad7..0f998c473ffa0db9d08bb3e89b245d20ebd789e4 100644 (file)
@@ -393,6 +393,7 @@ typedef enum {
     /* 245 */
     QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION, /* qmp query-cpu-model-expansion */
     QEMU_CAPS_VIRTIO_NET_HOST_MTU, /* virtio-net-*.host_mtu */
+    QEMU_CAPS_SPICE_RENDERNODE, /* -spice rendernode */
 
     QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
index c00a47a91a9c91cff42d7f02df207f393ad8cacc..f4bcfd467faad18f3f83f2c2f84977315e46a0fc 100644 (file)
@@ -7920,6 +7920,16 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
          * TristateSwitch helper */
         virBufferAsprintf(&opt, "gl=%s,",
                           virTristateSwitchTypeToString(graphics->data.spice.gl));
+
+        if (graphics->data.spice.rendernode) {
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_RENDERNODE)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("This QEMU doesn't support spice OpenGL rendernode"));
+                goto error;
+            }
+
+            virBufferAsprintf(&opt, "rendernode=%s,", graphics->data.spice.rendernode);
+        }
     }
 
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEAMLESS_MIGRATION)) {
index f1ebb62e44f89621d3de407aaad7ef3d114cbbd8..84439cddcdb2279a1f07bdfc605272d8f5f17ec4 100644 (file)
@@ -19,6 +19,6 @@ QEMU_AUDIO_DRV=spice \
 -drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,\
 id=drive-ide0-0-0,cache=none \
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--spice port=0,gl=on \
+-spice port=0,gl=on,rendernode=/dev/dri/foo \
 -device virtio-gpu-pci,id=video0,virgl=on,bus=pci.0,addr=0x2 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
index b9c7c8af008297a7b099c3d7a5a0be10945e1fe0..fd2580635c4405309db3fa62869305acd5f224a3 100644 (file)
@@ -26,7 +26,7 @@
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
     <graphics type='spice' autoport='no'>
-      <gl enable='yes'/>
+      <gl enable='yes' rendernode='/dev/dri/foo'/>
     </graphics>
     <video>
       <model type='virtio' heads='1'>
index faa99c64cc614fe3ea4e6f242e387ca80f727672..f55b04b05742df327c58aabb78fab829be58392d 100644 (file)
@@ -1725,6 +1725,7 @@ mymain(void)
             QEMU_CAPS_VIRTIO_GPU_VIRGL,
             QEMU_CAPS_SPICE,
             QEMU_CAPS_SPICE_GL,
+            QEMU_CAPS_SPICE_RENDERNODE,
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
     DO_TEST("video-virtio-gpu-secondary",
             QEMU_CAPS_DEVICE_VIRTIO_GPU,
index 9fb533ad90d8230c3016ea8774ab362ab69b43c0..2ce838fab447f21f75942e33e103d11e9d88be41 100644 (file)
@@ -31,7 +31,7 @@
     <input type='keyboard' bus='ps2'/>
     <graphics type='spice'>
       <listen type='none'/>
-      <gl enable='yes'/>
+      <gl enable='yes' rendernode='/dev/dri/foo'/>
     </graphics>
     <video>
       <model type='virtio' heads='1' primary='yes'>