]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vircgroup: introduce virCgroupV2CopyPlacement
authorPavel Hrdina <phrdina@redhat.com>
Tue, 25 Sep 2018 12:34:01 +0000 (14:34 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Fri, 5 Oct 2018 13:53:29 +0000 (15:53 +0200)
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/util/vircgroupv2.c

index cc98c509bddbd8e95c24cdd2027843e5227ee705..5999eb119f7fac0dd6ed54b2c33068150bf8e03f 100644 (file)
@@ -139,12 +139,39 @@ virCgroupV2CopyMounts(virCgroupPtr group,
 }
 
 
+static int
+virCgroupV2CopyPlacement(virCgroupPtr group,
+                         const char *path,
+                         virCgroupPtr parent)
+{
+    if (path[0] == '/') {
+        if (VIR_STRDUP(group->unified.placement, path) < 0)
+            return -1;
+    } else {
+        /*
+         * parent == "/" + path="" => "/"
+         * parent == "/libvirt.service" + path == "" => "/libvirt.service"
+         * parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo"
+         */
+        if (virAsprintf(&group->unified.placement, "%s%s%s",
+                        parent->unified.placement,
+                        (STREQ(parent->unified.placement, "/") ||
+                         STREQ(path, "") ? "" : "/"),
+                        path) < 0)
+            return -1;
+    }
+
+    return 0;
+}
+
+
 virCgroupBackend virCgroupV2Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V2,
 
     .available = virCgroupV2Available,
     .validateMachineGroup = virCgroupV2ValidateMachineGroup,
     .copyMounts = virCgroupV2CopyMounts,
+    .copyPlacement = virCgroupV2CopyPlacement,
 };