]> xenbits.xensource.com Git - libvirt.git/commitdiff
vircgroup: introduce virCgroupV2DevicesGetKey
authorPavel Hrdina <phrdina@redhat.com>
Mon, 24 Jun 2019 12:46:53 +0000 (14:46 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Fri, 15 Nov 2019 11:58:38 +0000 (12:58 +0100)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/libvirt_private.syms
src/util/vircgroupv2devices.c
src/util/vircgroupv2devices.h

index 88b0a3869672d9c5a58f8193b156c9cc4908e731..76de9e8d3e9e20dd4002078e376b29ab39a26e7e 100644 (file)
@@ -1721,6 +1721,7 @@ virCgroupV2DevicesAttachProg;
 virCgroupV2DevicesAvailable;
 virCgroupV2DevicesCreateProg;
 virCgroupV2DevicesDetectProg;
+virCgroupV2DevicesGetKey;
 virCgroupV2DevicesGetPerms;
 virCgroupV2DevicesPrepareProg;
 virCgroupV2DevicesRemoveProg;
index 43ae14d2a516ab6ad4056caa2a7a5b7479bfa018..6b4ea3142f087aafd5317b6328eb615b5f94e834 100644 (file)
@@ -647,3 +647,11 @@ virCgroupV2DevicesGetPerms(int perms G_GNUC_UNUSED,
     return 0;
 }
 #endif /* !HAVE_DECL_BPF_CGROUP_DEVICE */
+
+
+uint64_t
+virCgroupV2DevicesGetKey(int major,
+                         int minor)
+{
+    return (uint64_t)major << 32 | ((uint64_t)minor & 0x00000000ffffffff);
+}
index e00da25c1e3b03c5ae3873731528e4ba502ee57f..593ed35203cdb849bf7a5dfd0805a5e03fc5c882 100644 (file)
@@ -45,3 +45,7 @@ virCgroupV2DevicesRemoveProg(virCgroupPtr group);
 uint32_t
 virCgroupV2DevicesGetPerms(int perms,
                            char type);
+
+uint64_t
+virCgroupV2DevicesGetKey(int major,
+                         int minor);