|
|
c480ed |
From 4a95be40b1a56cc0eb6d6f56161d536f22380804 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <4a95be40b1a56cc0eb6d6f56161d536f22380804@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:07:26 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: introduce virCgroupV2Remove
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 4fe4847438c8ff042d6d39718b26023199e67c8a)
|
|
|
c480ed |
|
|
|
c480ed |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Message-Id: <a7464dfade07325cf93291200356e33235020a2e.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroupv2.c | 20 ++++++++++++++++++++
|
|
|
c480ed |
1 file changed, 20 insertions(+)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
|
c480ed |
index cf8bd01317..b5fad47ca0 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv2.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv2.c
|
|
|
c480ed |
@@ -413,6 +413,25 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV2Remove(virCgroupPtr group)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) grppath = NULL;
|
|
|
c480ed |
+ int controller;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ /* Don't delete the root group, if we accidentally
|
|
|
c480ed |
+ ended up in it for some reason */
|
|
|
c480ed |
+ if (STREQ(group->unified.placement, "/"))
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ controller = virCgroupV2GetAnyController(group);
|
|
|
c480ed |
+ if (virCgroupV2PathOfController(group, controller, "", &grppath) < 0)
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return virCgroupRemoveRecursively(grppath);
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
virCgroupBackend virCgroupV2Backend = {
|
|
|
c480ed |
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
|
|
c480ed |
|
|
|
c480ed |
@@ -429,6 +448,7 @@ virCgroupBackend virCgroupV2Backend = {
|
|
|
c480ed |
.getAnyController = virCgroupV2GetAnyController,
|
|
|
c480ed |
.pathOfController = virCgroupV2PathOfController,
|
|
|
c480ed |
.makeGroup = virCgroupV2MakeGroup,
|
|
|
c480ed |
+ .remove = virCgroupV2Remove,
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|