Blame SOURCES/libvirt-qemu-Introduce-functions-for-input-device-cgroup-manipulation.patch

c1c534
From 0a7264a2f791329f1c041594dfc17328040b8299 Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <0a7264a2f791329f1c041594dfc17328040b8299@dist-git>
c1c534
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
c1c534
Date: Mon, 27 Nov 2017 14:21:00 +0100
c1c534
Subject: [PATCH] qemu: Introduce functions for input device cgroup
c1c534
 manipulation
c1c534
MIME-Version: 1.0
c1c534
Content-Type: text/plain; charset=UTF-8
c1c534
Content-Transfer-Encoding: 8bit
c1c534
c1c534
Export qemuSetupInputCgroup and introduce qemuTeardownInputCgroup
c1c534
for hotunplug.
c1c534
c1c534
(cherry picked from commit f29612fd353db074a0b963ed53ef9c29c562bb36)
c1c534
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1509866
c1c534
c1c534
Signed-off-by: Ján Tomko <jtomko@redhat.com>
c1c534
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c1c534
---
c1c534
 src/qemu/qemu_cgroup.c | 25 ++++++++++++++++++++++++-
c1c534
 src/qemu/qemu_cgroup.h |  4 ++++
c1c534
 2 files changed, 28 insertions(+), 1 deletion(-)
c1c534
c1c534
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
c1c534
index 0f75e22f98..19252ea239 100644
c1c534
--- a/src/qemu/qemu_cgroup.c
c1c534
+++ b/src/qemu/qemu_cgroup.c
c1c534
@@ -246,7 +246,7 @@ qemuSetupTPMCgroup(virDomainObjPtr vm)
c1c534
 }
c1c534
 
c1c534
 
c1c534
-static int
c1c534
+int
c1c534
 qemuSetupInputCgroup(virDomainObjPtr vm,
c1c534
                      virDomainInputDefPtr dev)
c1c534
 {
c1c534
@@ -269,6 +269,29 @@ qemuSetupInputCgroup(virDomainObjPtr vm,
c1c534
 }
c1c534
 
c1c534
 
c1c534
+int
c1c534
+qemuTeardownInputCgroup(virDomainObjPtr vm,
c1c534
+                        virDomainInputDefPtr dev)
c1c534
+{
c1c534
+    qemuDomainObjPrivatePtr priv = vm->privateData;
c1c534
+    int ret = 0;
c1c534
+
c1c534
+    if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES))
c1c534
+        return 0;
c1c534
+
c1c534
+    switch (dev->type) {
c1c534
+    case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
c1c534
+        VIR_DEBUG("Process path '%s' for input device", dev->source.evdev);
c1c534
+        ret = virCgroupDenyDevicePath(priv->cgroup, dev->source.evdev,
c1c534
+                                      VIR_CGROUP_DEVICE_RWM, false);
c1c534
+        virDomainAuditCgroupPath(vm, priv->cgroup, "deny", dev->source.evdev, "rwm", ret == 0);
c1c534
+        break;
c1c534
+    }
c1c534
+
c1c534
+    return ret;
c1c534
+}
c1c534
+
c1c534
+
c1c534
 int
c1c534
 qemuSetupHostdevCgroup(virDomainObjPtr vm,
c1c534
                        virDomainHostdevDefPtr dev)
c1c534
diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
c1c534
index 3fc1583612..3b8ff6055d 100644
c1c534
--- a/src/qemu/qemu_cgroup.h
c1c534
+++ b/src/qemu/qemu_cgroup.h
c1c534
@@ -37,6 +37,10 @@ int qemuSetupDiskCgroup(virDomainObjPtr vm,
c1c534
                         virDomainDiskDefPtr disk);
c1c534
 int qemuTeardownDiskCgroup(virDomainObjPtr vm,
c1c534
                            virDomainDiskDefPtr disk);
c1c534
+int qemuSetupInputCgroup(virDomainObjPtr vm,
c1c534
+                         virDomainInputDefPtr dev);
c1c534
+int qemuTeardownInputCgroup(virDomainObjPtr vm,
c1c534
+                            virDomainInputDefPtr dev);
c1c534
 int qemuSetupHostdevCgroup(virDomainObjPtr vm,
c1c534
                            virDomainHostdevDefPtr dev)
c1c534
    ATTRIBUTE_RETURN_CHECK;
c1c534
-- 
c1c534
2.15.1
c1c534