|
Pablo Greco |
40546a |
From af9bf10ff9d8a6f0ae9b6d898138144bf7dcd161 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <af9bf10ff9d8a6f0ae9b6d898138144bf7dcd161@dist-git>
|
|
Pablo Greco |
40546a |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Mon, 1 Jul 2019 17:07:18 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] vircgroup: introduce virCgroupV2DetectPlacement
|
|
Pablo Greco |
40546a |
MIME-Version: 1.0
|
|
Pablo Greco |
40546a |
Content-Type: text/plain; charset=UTF-8
|
|
Pablo Greco |
40546a |
Content-Transfer-Encoding: 8bit
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
If the placement was copied from parent or set to absolute path
|
|
Pablo Greco |
40546a |
there is nothing to do, otherwise set the placement based on
|
|
Pablo Greco |
40546a |
process placement from /proc/self/cgroup or /proc/{pid}/cgroup.
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
(cherry picked from commit 1efcf202e777d32600e90f3176e0357053341533)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Message-Id: <7fcc9d25385c40df5531e5b7171338a624d0c4fb.1561993100.git.phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
---
|
|
Pablo Greco |
40546a |
src/util/vircgroupv2.c | 26 ++++++++++++++++++++++++++
|
|
Pablo Greco |
40546a |
1 file changed, 26 insertions(+)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
Pablo Greco |
40546a |
index 19a9ba38f8..fb1aa2de0a 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupv2.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupv2.c
|
|
Pablo Greco |
40546a |
@@ -181,6 +181,31 @@ virCgroupV2DetectMounts(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+static int
|
|
Pablo Greco |
40546a |
+virCgroupV2DetectPlacement(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ const char *path,
|
|
Pablo Greco |
40546a |
+ const char *controllers ATTRIBUTE_UNUSED,
|
|
Pablo Greco |
40546a |
+ const char *selfpath)
|
|
Pablo Greco |
40546a |
+{
|
|
Pablo Greco |
40546a |
+ if (group->unified.placement)
|
|
Pablo Greco |
40546a |
+ return 0;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ /*
|
|
Pablo Greco |
40546a |
+ * selfpath == "/" + path="" -> "/"
|
|
Pablo Greco |
40546a |
+ * selfpath == "/libvirt.service" + path == "" -> "/libvirt.service"
|
|
Pablo Greco |
40546a |
+ * selfpath == "/libvirt.service" + path == "foo" -> "/libvirt.service/foo"
|
|
Pablo Greco |
40546a |
+ */
|
|
Pablo Greco |
40546a |
+ if (virAsprintf(&group->unified.placement,
|
|
Pablo Greco |
40546a |
+ "%s%s%s", selfpath,
|
|
Pablo Greco |
40546a |
+ (STREQ(selfpath, "/") ||
|
|
Pablo Greco |
40546a |
+ STREQ(path, "") ? "" : "/"),
|
|
Pablo Greco |
40546a |
+ path) < 0)
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ return 0;
|
|
Pablo Greco |
40546a |
+}
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
virCgroupBackend virCgroupV2Backend = {
|
|
Pablo Greco |
40546a |
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -189,6 +214,7 @@ virCgroupBackend virCgroupV2Backend = {
|
|
Pablo Greco |
40546a |
.copyMounts = virCgroupV2CopyMounts,
|
|
Pablo Greco |
40546a |
.copyPlacement = virCgroupV2CopyPlacement,
|
|
Pablo Greco |
40546a |
.detectMounts = virCgroupV2DetectMounts,
|
|
Pablo Greco |
40546a |
+ .detectPlacement = virCgroupV2DetectPlacement,
|
|
Pablo Greco |
40546a |
};
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|