[libvirt] [PATCH 11/19] vircgroup: introduce virCgroupV2DeviceGetKey

Pavel Hrdina phrdina at redhat.com
Wed Jan 2 14:08:43 UTC 2019


Device rules are stored in BPF map that is a hash type, this function
will create a key based on major and minor id of device.

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 src/util/vircgroupv2.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 30f8da22ac..198d2ea03e 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -1993,6 +1993,14 @@ virCgroupV2DeviceGetPerms(int perms,
 }
 
 
+static __u64
+virCgroupV2DeviceGetKey(int major,
+                        int minor)
+{
+    return (__u64)major << 32 | ((__u64)minor & 0x00000000ffffffff);
+}
+
+
 virCgroupBackend virCgroupV2Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V2,
 
-- 
2.20.1




More information about the libvir-list mailing list