render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
c313de
From 1cabfada0f1a83ae78b6a7dbb9128512369fd6f4 Mon Sep 17 00:00:00 2001
c313de
Message-Id: <1cabfada0f1a83ae78b6a7dbb9128512369fd6f4@dist-git>
c313de
From: Pavel Hrdina <phrdina@redhat.com>
c313de
Date: Mon, 1 Jul 2019 17:07:16 +0200
c313de
Subject: [PATCH] vircgroup: introduce virCgroupV2CopyPlacement
c313de
MIME-Version: 1.0
c313de
Content-Type: text/plain; charset=UTF-8
c313de
Content-Transfer-Encoding: 8bit
c313de
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
(cherry picked from commit 7a86201dd6e8cc7e418ea0891aeb44bacd08a10d)
c313de
c313de
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
c313de
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
Message-Id: <70993f08246ff3782d9b4a5bdf9187a0c1b57882.1561993100.git.phrdina@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
---
c313de
 src/util/vircgroupv2.c | 27 +++++++++++++++++++++++++++
c313de
 1 file changed, 27 insertions(+)
c313de
c313de
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
c313de
index 5d3c80b309..ed87b35db7 100644
c313de
--- a/src/util/vircgroupv2.c
c313de
+++ b/src/util/vircgroupv2.c
c313de
@@ -140,12 +140,39 @@ virCgroupV2CopyMounts(virCgroupPtr group,
c313de
 }
c313de
 
c313de
 
c313de
+static int
c313de
+virCgroupV2CopyPlacement(virCgroupPtr group,
c313de
+                         const char *path,
c313de
+                         virCgroupPtr parent)
c313de
+{
c313de
+    if (path[0] == '/') {
c313de
+        if (VIR_STRDUP(group->unified.placement, path) < 0)
c313de
+            return -1;
c313de
+    } else {
c313de
+        /*
c313de
+         * parent == "/" + path="" => "/"
c313de
+         * parent == "/libvirt.service" + path == "" => "/libvirt.service"
c313de
+         * parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo"
c313de
+         */
c313de
+        if (virAsprintf(&group->unified.placement, "%s%s%s",
c313de
+                        parent->unified.placement,
c313de
+                        (STREQ(parent->unified.placement, "/") ||
c313de
+                         STREQ(path, "") ? "" : "/"),
c313de
+                        path) < 0)
c313de
+            return -1;
c313de
+    }
c313de
+
c313de
+    return 0;
c313de
+}
c313de
+
c313de
+
c313de
 virCgroupBackend virCgroupV2Backend = {
c313de
     .type = VIR_CGROUP_BACKEND_TYPE_V2,
c313de
 
c313de
     .available = virCgroupV2Available,
c313de
     .validateMachineGroup = virCgroupV2ValidateMachineGroup,
c313de
     .copyMounts = virCgroupV2CopyMounts,
c313de
+    .copyPlacement = virCgroupV2CopyPlacement,
c313de
 };
c313de
 
c313de
 
c313de
-- 
c313de
2.22.0
c313de