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

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 249c379d7d..dcfc735a84 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -421,6 +421,25 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
 }
 
 
+static int
+virCgroupV2Remove(virCgroupPtr group)
+{
+    VIR_AUTOFREE(char *) grppath = NULL;
+    int controller;
+
+    /* Don't delete the root group, if we accidentally
+       ended up in it for some reason */
+    if (STREQ(group->unified.placement, "/"))
+        return 0;
+
+    controller = virCgroupV2GetAnyController(group);
+    if (virCgroupV2PathOfController(group, controller, "", &grppath) < 0)
+        return 0;
+
+    return virCgroupRemoveRecursively(grppath);
+}
+
+
 virCgroupBackend virCgroupV2Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V2,
 
@@ -437,6 +456,7 @@ virCgroupBackend virCgroupV2Backend = {
     .getAnyController = virCgroupV2GetAnyController,
     .pathOfController = virCgroupV2PathOfController,
     .makeGroup = virCgroupV2MakeGroup,
+    .remove = virCgroupV2Remove,
 };
 
 
-- 
2.17.1

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

Reply via email to