This adds the virt-aa-helper support for gl enabled graphics devices to
generate rules for the needed rendernode paths.

Example in domain xml:
<graphics type='spice'>
  <gl enable='yes' rendernode='/dev/dri/bar'/>
</graphics>

results in:
  "/dev/dri" r,
  "/dev/dri/bar" rw,

Special cases are:
- multiple devices with rendernodes -> all are added
- non explicit rendernodes -> follow recently added virHostGetDRMRenderNode
- rendernode without opengl (in egl-headless for example) -> still add
  the node

Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1757085

Signed-off-by: Christian Ehrhardt <christian.ehrha...@canonical.com>
---
 src/security/virt-aa-helper.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 64a425671d..327a8a0202 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -938,7 +938,7 @@ get_files(vahControl * ctl)
     size_t i;
     char *uuid;
     char uuidstr[VIR_UUID_STRING_BUFLEN];
-    bool needsVfio = false, needsvhost = false;
+    bool needsVfio = false, needsvhost = false, needDefaultRenderNode = false;
 
     /* verify uuid is same as what we were given on the command line */
     virUUIDFormat(ctl->def->uuid, uuidstr);
@@ -1062,6 +1062,10 @@ get_files(vahControl * ctl)
     for (i = 0; i < ctl->def->ngraphics; i++) {
         virDomainGraphicsDefPtr graphics = ctl->def->graphics[i];
         size_t n;
+        const char *rendernode = virDomainGraphicsGetRenderNode(graphics);
+
+        if (rendernode)
+            vah_add_file(&buf, rendernode, "rw");
 
         for (n = 0; n < graphics->nListens; n++) {
             virDomainGraphicsListenDef listenObj = graphics->listens[n];
@@ -1071,6 +1075,20 @@ get_files(vahControl * ctl)
                 vah_add_file(&buf, listenObj.socket, "rw"))
                 goto cleanup;
         }
+
+        if (graphics->data.spice.gl == VIR_TRISTATE_BOOL_YES) {
+            if (!rendernode)
+                needDefaultRenderNode = true;
+        }
+    }
+
+    if (virDomainGraphicsDefHasOpenGL(ctl->def))
+        vah_add_file(&buf, "/dev/dri", "r");
+
+    if (needDefaultRenderNode) {
+        const char *rendernode = virHostGetDRMRenderNode();
+        if (rendernode)
+            vah_add_file(&buf, virHostGetDRMRenderNode(), "rw");
     }
 
     if (ctl->def->ngraphics == 1 &&
-- 
2.17.1

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

Reply via email to