[PATCH 09/12] command: Put the 'rendernode' option onto egl-headless graphics cmdline

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

 



Depending on whether QEMU actually supports the option, we need to pick
the first available rendernode first.

Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index dd2b4fa445..63b8f81835 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8295,13 +8295,42 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
 static int
 qemuBuildGraphicsEGLHeadlessCommandLine(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
                                         virCommandPtr cmd,
-                                        virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
-                                        virDomainGraphicsDefPtr graphics ATTRIBUTE_UNUSED)
+                                        virQEMUCapsPtr qemuCaps,
+                                        virDomainGraphicsDefPtr graphics)
 {
+    int ret = -1;
+    virBuffer opt = VIR_BUFFER_INITIALIZER;
+
+    /* Until QEMU 3.1, there wasn't any support for the 'rendernode' option on
+     * the cmdline, so don't bother picking one, the user is responsible for
+     * ensuring the correct permissions on the DRI devices.
+     */
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_EGL_HEADLESS_RENDERNODE)) {
+
+        /* we must populate @def so we actually have something to relabel */
+        graphics->data.egl_headless.rendernode = virHostGetDRMRenderNode();
+        if (!graphics->data.egl_headless.rendernode)
+            return -1;
+    }
+
+    virBufferAddLit(&opt, "egl-headless");
+
+    if (graphics->data.egl_headless.rendernode) {
+        virBufferAddLit(&opt, ",rendernode=");
+        virQEMUBuildBufferEscapeComma(&opt,
+                                      graphics->data.egl_headless.rendernode);
+    }
+
+    if (virBufferCheckError(&opt) < 0)
+        goto cleanup;
+
     virCommandAddArg(cmd, "-display");
-    virCommandAddArg(cmd, "egl-headless");
+    virCommandAddArgBuffer(cmd, &opt);
 
-    return 0;
+    ret = 0;
+ cleanup:
+    virBufferFreeAndReset(&opt);
+    return ret;
 }
 
 
-- 
2.19.1

--
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]

  Powered by Linux