Skip to contentSkip to conversation

Introduce 'rendernode' option for egl-headless display type

PATCH Superseded Erik Skultety 3 participants 9 messages Nov 15, 2018 – Nov 16, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Introduce 'rendernode' option for egl-headless display type

Since QEMU always picks the default DRI device, libvirt doesn't know which one to put into the mount namespace and relabel it accordingly, hence hitting permission issues, unless admin tweaks the default permissions of the DRI devices.

https://bugzilla.redhat.com/show_bug.cgi?id=1648236

Erik Skultety (3):
qapi: Add "rendernode" display option for egl-headless
ui: Allow specifying 'rendernode' display option for egl-headless
help: Provide help for egl-headless

 qapi/ui.json      | 16 +++++++++++++++-
 qemu-options.hx   |  6 +++++-
 ui/egl-headless.c |  2 +-
 3 files changed, 21 insertions(+), 3 deletions(-)

--
2.19.1

#1 lore raw

PATCH 1/3 qapi: Add "rendernode" display option for egl-headless

Unlike SPICE, egl-headless doesn't offer a way of specifying the DRM node used for OpenGL, hence QEMU always selecting the first one that is available. Thus, add rendernode option to QAPI.

---
 qapi/ui.json | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
qapi/ui.json +15 -1
index bf9e157d5a..7ecc6eb67e 100644
@@ -1037,6 +1037,19 @@
   'data'    : { '*grab-on-hover' : 'bool',
                 '*zoom-to-fit'   : 'bool'  } }
 
+##
+# @DisplayEGLHeadless:
+#
+# EGL headless display options.
+#
+# @rendernode: Which DRM render node should be used.
+#
+# Since: 3.2
+#
+##
+{ 'struct'  : 'DisplayEGLHeadless',
+  'data'    : { '*rendernode' : 'str' } }
+
  ##
  # @DisplayGLMode:
  #
@@ -1086,4 +1099,5 @@
                 '*window-close'  : 'bool',
                 '*gl'            : 'DisplayGLMode' },
   'discriminator' : 'type',
-  'data'    : { 'gtk'            : 'DisplayGTK' } }
+  'data'    : { 'gtk'            : 'DisplayGTK',
+                'egl-headless'   : 'DisplayEGLHeadless'} }
Signature · 1 line
2.19.1
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] qapi: Add "rendernode" display option for egl-headless

Quoted 15 lines · Erik Skultety

Unlike SPICE, egl-headless doesn't offer a way of specifying the DRM node used for OpenGL, hence QEMU always selecting the first one that is available. Thus, add rendernode option to QAPI.

---
  qapi/ui.json | 16 +++++++++++++++-
  1 file changed, 15 insertions(+), 1 deletion(-)
qapi/ui.json +0 -0
index bf9e157d5a..7ecc6eb67e 100644
@@ -1037,6 +1037,19 @@
    'data'    : { '*grab-on-hover' : 'bool',

qapi/ui.json line 1047

Quoted 10 lines
qapi/ui.json +8 -0
                  '*zoom-to-fit'   : 'bool'  } }
 
+##
+# @DisplayEGLHeadless:
+#
+# EGL headless display options.
+#
+# @rendernode: Which DRM render node should be used.
+#
+# Since: 3.2

Either 3.1 or 4.0, depending on whether this is okay this late after soft freeze. Worth mentioning that rendernode defaults to the first available node?

Quoted 16 lines
qapi/ui.json +7 -1
+#
+##
+{ 'struct'  : 'DisplayEGLHeadless',
+  'data'    : { '*rendernode' : 'str' } }
+
   ##
   # @DisplayGLMode:
   #
@@ -1086,4 +1099,5 @@
                  '*window-close'  : 'bool',
                  '*gl'            : 'DisplayGLMode' },
    'discriminator' : 'type',
-  'data'    : { 'gtk'            : 'DisplayGTK' } }
+  'data'    : { 'gtk'            : 'DisplayGTK',
+                'egl-headless'   : 'DisplayEGLHeadless'} }
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#3 lore raw

PATCH 2/3 ui: Allow specifying 'rendernode' display option for egl-headless

In reply to Erik Skultety

As libvirt can't predict which rendernode QEMU would pick, it won't adjust the permissions on the device, hence QEMU getting "Permission denied" when opening the DRI device. Therefore, enable 'rendernode' option for egl-headless display type.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1648236

---
 ui/egl-headless.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ui/egl-headless.c +1 -1
index 42a41310b0..4cf3bbc0e4 100644
@@ -176,7 +176,7 @@ static void egl_headless_init(DisplayState *ds, DisplayOptions *opts)
     egl_dpy *edpy;
     int idx;
 
-    if (egl_rendernode_init(NULL, mode) < 0) {
+    if (egl_rendernode_init(opts->u.egl_headless.rendernode, mode) < 0) {
         error_report("egl: render node init failed");
         exit(1);
     }
Signature · 1 line
2.19.1
#4 lore raw

PATCH 3/3 help: Provide help for egl-headless

In reply to Erik Skultety

EGL headless has been missing from QEMU's help or man page, we should mention that such a thing exists, especially since projects like libvirt might rely on that. This patch also adds the newly introduced option for egl-headless 'rendernode'.

---
 qemu-options.hx | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
qemu-options.hx +5 -1
index ee379b32e3..f7df472f43 100644
@@ -1216,7 +1216,8 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
     "-display gtk[,grab_on_hover=on|off][,gl=on|off]|\n"
     "-display vnc=<display>[,<optargs>]\n"
     "-display curses\n"
-    "-display none"
+    "-display none\n"
+    "-display egl-headless[,rendernode=<file>]"
     "                select display type\n"
     "The default display is equivalent to\n"
 #if defined(CONFIG_GTK)
@@ -1258,6 +1259,9 @@ menus and other UI elements to configure and control the VM during
 runtime.
 @item vnc
 Start a VNC server on display <arg>
+@item egl-headless
+Offload all OpenGL operations to a local DRI device. For any graphical display,
+this display needs to be paired with either VNC or SPICE displays.
 @end table
 ETEXI
 
Signature · 1 line
2.19.1
#5 lore raw
In reply to Erik Skultety
Quoted 6 lines · Erik Skultety

Since QEMU always picks the default DRI device, libvirt doesn't know which one to put into the mount namespace and relabel it accordingly, hence hitting permission issues, unless admin tweaks the default permissions of the DRI devices.

https://bugzilla.redhat.com/show_bug.cgi?id=1648236

This is borderline between fixing a bug that gets in the way of libvirt (and thus useful for 3.1) and a feature (thus for 4.0, since we won't have a 3.2 release). I'll let Gerd decide.

Quoted 16 lines

Erik Skultety (3):
qapi: Add "rendernode" display option for egl-headless
ui: Allow specifying 'rendernode' display option for egl-headless
help: Provide help for egl-headless

  qapi/ui.json      | 16 +++++++++++++++-
  qemu-options.hx   |  6 +++++-
  ui/egl-headless.c |  2 +-
  3 files changed, 21 insertions(+), 3 deletions(-)

--
2.19.1

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#6 lore raw
Quoted 11 lines · Eric Blake
Quoted 6 lines · Erik Skultety

Since QEMU always picks the default DRI device, libvirt doesn't know which one to put into the mount namespace and relabel it accordingly, hence hitting permission issues, unless admin tweaks the default permissions of the DRI devices.

https://bugzilla.redhat.com/show_bug.cgi?id=1648236

This is borderline between fixing a bug that gets in the way of libvirt (and thus useful for 3.1) and a feature (thus for 4.0, since we won't have a 3.2 release). I'll let Gerd decide.

It's simple enough and we are early in the -rc cycle still, I think it would be okay for 3.1.

cheers,
Gerd

#7 lore raw
Quoted 7 lines · Gerd Hoffmann
Quoted 6 lines · Eric Blake
Quoted 5 lines · Erik Skultety

Since QEMU always picks the default DRI device, libvirt doesn't know which one to put into the mount namespace and relabel it accordingly, hence hitting permission issues, unless admin tweaks the default permissions of the DRI devices.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

https://bugzilla.redhat.com/show_bug.cgi?id=1648236

This is borderline between fixing a bug that gets in the way of libvirt (and thus useful for 3.1) and a feature (thus for 4.0, since we won't have a 3.2 release). I'll let Gerd decide.

It's simple enough and we are early in the -rc cycle still, I think it would be okay for 3.1.

As far as upstream's concerned, I'm okay with both because libvirt has to add another version specific capability enum for this anyway. It's been broken since libvirt 4.6.0 where I added egl-headless graphics type. Luckily, even though it's far from optimal, a working solution exists, just change the permissions on the device.

Thanks,
Erik

#8 lore raw
Quoted 9 lines · Erik Skultety
Quoted 2 lines · Gerd Hoffmann

It's simple enough and we are early in the -rc cycle still, I think it would be okay for 3.1.

As far as upstream's concerned, I'm okay with both because libvirt has to add another version specific capability enum for this anyway. It's been broken since libvirt 4.6.0 where I added egl-headless graphics type. Luckily, even though it's far from optimal, a working solution exists, just change the permissions on the device.

I'm fine either way too. So just pick a version, update the doc comments and repost.

thanks,
Gerd