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

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