diff mbox series

[v2,04/16] qemu-cgroup: allow accel rendernode access

Message ID ace46a98bf77f43901616e321ebb99e88f08c6b1.1566576129.git.crobinso@redhat.com
State Accepted
Commit fe3b7206876bba747a9edc064c2afc4773da6859
Headers show
Series Add vhost-user-gpu support | expand

Commit Message

Cole Robinson Aug. 23, 2019, 4:21 p.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
 src/qemu/qemu_cgroup.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Ján Tomko Aug. 27, 2019, 7:39 a.m. UTC | #1
On Fri, Aug 23, 2019 at 12:21:48PM -0400, Cole Robinson wrote:
>From: Marc-André Lureau <marcandre.lureau@redhat.com>

>

>Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

>Signed-off-by: Cole Robinson <crobinso@redhat.com>

>---

> src/qemu/qemu_cgroup.c | 24 ++++++++++++++++++++++++

> 1 file changed, 24 insertions(+)

>


Reviewed-by: Ján Tomko <jtomko@redhat.com>


Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index ecd96efb0a..eb6f993d8e 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -503,6 +503,25 @@  qemuSetupGraphicsCgroup(virDomainObjPtr vm,
 }
 
 
+static int
+qemuSetupVideoAccelCgroup(virDomainObjPtr vm,
+                          virDomainVideoAccelDefPtr def)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    int ret;
+
+    if (!def->rendernode ||
+        !virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES))
+        return 0;
+
+    ret = virCgroupAllowDevicePath(priv->cgroup, def->rendernode,
+                                   VIR_CGROUP_DEVICE_RW, false);
+    virDomainAuditCgroupPath(vm, priv->cgroup, "allow", def->rendernode,
+                             "rw", ret);
+    return ret;
+}
+
+
 static int
 qemuSetupBlkioCgroup(virDomainObjPtr vm)
 {
@@ -803,6 +822,11 @@  qemuSetupDevicesCgroup(virDomainObjPtr vm)
             goto cleanup;
     }
 
+    for (i = 0; i < vm->def->nvideos; i++) {
+        if (qemuSetupVideoAccelCgroup(vm, vm->def->videos[i]->accel) < 0)
+            goto cleanup;
+    }
+
     for (i = 0; i < vm->def->ninputs; i++) {
         if (qemuSetupInputCgroup(vm, vm->def->inputs[i]) < 0)
             goto cleanup;