[PATCH 09/19] vircgroup: introduce virCgroupV2DeviceRemoveProg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We need to close our FD that we have for BPF program and map in order
to let kernel remove all resources once the cgroup is removed as well.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/util/vircgroupv2.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index aea094a328..839f19c1f6 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -454,6 +454,10 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
 }
 
 
+static int
+virCgroupV2DeviceRemoveProg(virCgroupPtr group);
+
+
 static int
 virCgroupV2Remove(virCgroupPtr group)
 {
@@ -469,6 +473,9 @@ virCgroupV2Remove(virCgroupPtr group)
     if (virCgroupV2PathOfController(group, controller, "", &grppath) < 0)
         return 0;
 
+    if (virCgroupV2DeviceRemoveProg(group) < 0)
+        return -1;
+
     return virCgroupRemoveRecursively(grppath);
 }
 
@@ -1941,6 +1948,25 @@ virCgroupV2DevicePrepareProg(virCgroupPtr group)
 }
 
 
+static int
+virCgroupV2DeviceRemoveProg(virCgroupPtr group)
+{
+    if (virCgroupV2DeviceDetectProg(group) < 0)
+        return -1;
+
+    if (group->unified.devices.progfd <= 0 && group->unified.devices.mapfd <= 0)
+        return 0;
+
+    if (group->unified.devices.mapfd >= 0)
+        VIR_FORCE_CLOSE(group->unified.devices.mapfd);
+
+    if (group->unified.devices.progfd >= 0)
+        VIR_FORCE_CLOSE(group->unified.devices.progfd);
+
+    return 0;
+}
+
+
 virCgroupBackend virCgroupV2Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V2,
 
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux