|
|
c480ed |
From 1cabfada0f1a83ae78b6a7dbb9128512369fd6f4 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <1cabfada0f1a83ae78b6a7dbb9128512369fd6f4@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:07:16 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: introduce virCgroupV2CopyPlacement
|
|
|
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 7a86201dd6e8cc7e418ea0891aeb44bacd08a10d)
|
|
|
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: <70993f08246ff3782d9b4a5bdf9187a0c1b57882.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroupv2.c | 27 +++++++++++++++++++++++++++
|
|
|
c480ed |
1 file changed, 27 insertions(+)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
|
c480ed |
index 5d3c80b309..ed87b35db7 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv2.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv2.c
|
|
|
c480ed |
@@ -140,12 +140,39 @@ virCgroupV2CopyMounts(virCgroupPtr group,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV2CopyPlacement(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ virCgroupPtr parent)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ if (path[0] == '/') {
|
|
|
c480ed |
+ if (VIR_STRDUP(group->unified.placement, path) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ } else {
|
|
|
c480ed |
+ /*
|
|
|
c480ed |
+ * parent == "/" + path="" => "/"
|
|
|
c480ed |
+ * parent == "/libvirt.service" + path == "" => "/libvirt.service"
|
|
|
c480ed |
+ * parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo"
|
|
|
c480ed |
+ */
|
|
|
c480ed |
+ if (virAsprintf(&group->unified.placement, "%s%s%s",
|
|
|
c480ed |
+ parent->unified.placement,
|
|
|
c480ed |
+ (STREQ(parent->unified.placement, "/") ||
|
|
|
c480ed |
+ STREQ(path, "") ? "" : "/"),
|
|
|
c480ed |
+ path) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
virCgroupBackend virCgroupV2Backend = {
|
|
|
c480ed |
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
|
|
c480ed |
|
|
|
c480ed |
.available = virCgroupV2Available,
|
|
|
c480ed |
.validateMachineGroup = virCgroupV2ValidateMachineGroup,
|
|
|
c480ed |
.copyMounts = virCgroupV2CopyMounts,
|
|
|
c480ed |
+ .copyPlacement = virCgroupV2CopyPlacement,
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|