[PATCH v2 07/53] [ACKED] vircgroup: introduce virCgroupV2DetectPlacement

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

 



If the placement was copied from parent or set to absolute path
there is nothing to do, otherwise set the placement based on
process placement from /proc/self/cgroup or /proc/{pid}/cgroup.

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 f13c5fc669..800fc083f2 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -189,6 +189,31 @@ virCgroupV2DetectMounts(virCgroupPtr group,
 }
 
 
+static int
+virCgroupV2DetectPlacement(virCgroupPtr group,
+                           const char *path,
+                           const char *controllers ATTRIBUTE_UNUSED,
+                           const char *selfpath)
+{
+    if (group->unified.placement)
+        return 0;
+
+    /*
+     * selfpath == "/" + path="" -> "/"
+     * selfpath == "/libvirt.service" + path == "" -> "/libvirt.service"
+     * selfpath == "/libvirt.service" + path == "foo" -> "/libvirt.service/foo"
+     */
+    if (virAsprintf(&group->unified.placement,
+                    "%s%s%s", selfpath,
+                    (STREQ(selfpath, "/") ||
+                     STREQ(path, "") ? "" : "/"),
+                    path) < 0)
+        return -1;
+
+    return 0;
+}
+
+
 virCgroupBackend virCgroupV2Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V2,
 
@@ -197,6 +222,7 @@ virCgroupBackend virCgroupV2Backend = {
     .copyMounts = virCgroupV2CopyMounts,
     .copyPlacement = virCgroupV2CopyPlacement,
     .detectMounts = virCgroupV2DetectMounts,
+    .detectPlacement = virCgroupV2DetectPlacement,
 };
 
 
-- 
2.17.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