|
|
c480ed |
From b246f8418526ea154fe2f0223f6f34ea86b90ea4 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <b246f8418526ea154fe2f0223f6f34ea86b90ea4@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:06:28 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: extract virCgroupV1CopyPlacement
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 229a8b5d3504efdbe8cd25bb3a127ec74ab4bbd3)
|
|
|
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: <9a9b8e24c5574e7b61e19a46d9978bf0dc1b32d3.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroup.c | 38 +------------------------------------
|
|
|
c480ed |
src/util/vircgroupbackend.h | 6 ++++++
|
|
|
c480ed |
src/util/vircgroupv1.c | 37 ++++++++++++++++++++++++++++++++++++
|
|
|
c480ed |
3 files changed, 44 insertions(+), 37 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
|
c480ed |
index 10c99a66fd..b63321ca33 100644
|
|
|
c480ed |
--- a/src/util/vircgroup.c
|
|
|
c480ed |
+++ b/src/util/vircgroup.c
|
|
|
c480ed |
@@ -269,42 +269,6 @@ virCgroupDetectMounts(virCgroupPtr group)
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
-static int
|
|
|
c480ed |
-virCgroupCopyPlacement(virCgroupPtr group,
|
|
|
c480ed |
- const char *path,
|
|
|
c480ed |
- virCgroupPtr parent)
|
|
|
c480ed |
-{
|
|
|
c480ed |
- size_t i;
|
|
|
c480ed |
- for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c480ed |
- if (!group->controllers[i].mountPoint)
|
|
|
c480ed |
- continue;
|
|
|
c480ed |
-
|
|
|
c480ed |
- if (i == VIR_CGROUP_CONTROLLER_SYSTEMD)
|
|
|
c480ed |
- continue;
|
|
|
c480ed |
-
|
|
|
c480ed |
- if (path[0] == '/') {
|
|
|
c480ed |
- if (VIR_STRDUP(group->controllers[i].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->controllers[i].placement,
|
|
|
c480ed |
- "%s%s%s",
|
|
|
c480ed |
- parent->controllers[i].placement,
|
|
|
c480ed |
- (STREQ(parent->controllers[i].placement, "/") ||
|
|
|
c480ed |
- STREQ(path, "") ? "" : "/"),
|
|
|
c480ed |
- path) < 0)
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
- }
|
|
|
c480ed |
- }
|
|
|
c480ed |
-
|
|
|
c480ed |
- return 0;
|
|
|
c480ed |
-}
|
|
|
c480ed |
-
|
|
|
c480ed |
-
|
|
|
c480ed |
/*
|
|
|
c480ed |
* virCgroupDetectPlacement:
|
|
|
c480ed |
* @group: the group to process
|
|
|
c480ed |
@@ -532,7 +496,7 @@ virCgroupDetect(virCgroupPtr group,
|
|
|
c480ed |
* based on the parent cgroup...
|
|
|
c480ed |
*/
|
|
|
c480ed |
if ((parent || path[0] == '/') &&
|
|
|
c480ed |
- virCgroupCopyPlacement(group, path, parent) < 0)
|
|
|
c480ed |
+ group->backend->copyPlacement(group, path, parent) < 0)
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
|
|
|
c480ed |
/* ... but use /proc/cgroups to fill in the rest */
|
|
|
c480ed |
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
|
|
|
c480ed |
index fadc7efdcf..85906e7191 100644
|
|
|
c480ed |
--- a/src/util/vircgroupbackend.h
|
|
|
c480ed |
+++ b/src/util/vircgroupbackend.h
|
|
|
c480ed |
@@ -45,6 +45,11 @@ typedef int
|
|
|
c480ed |
(*virCgroupCopyMountsCB)(virCgroupPtr group,
|
|
|
c480ed |
virCgroupPtr parent);
|
|
|
c480ed |
|
|
|
c480ed |
+typedef int
|
|
|
c480ed |
+(*virCgroupCopyPlacementCB)(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ virCgroupPtr parent);
|
|
|
c480ed |
+
|
|
|
c480ed |
typedef int
|
|
|
c480ed |
(*virCgroupDetectMountsCB)(virCgroupPtr group,
|
|
|
c480ed |
const char *mntType,
|
|
|
c480ed |
@@ -64,6 +69,7 @@ struct _virCgroupBackend {
|
|
|
c480ed |
virCgroupAvailableCB available;
|
|
|
c480ed |
virCgroupValidateMachineGroupCB validateMachineGroup;
|
|
|
c480ed |
virCgroupCopyMountsCB copyMounts;
|
|
|
c480ed |
+ virCgroupCopyPlacementCB copyPlacement;
|
|
|
c480ed |
virCgroupDetectMountsCB detectMounts;
|
|
|
c480ed |
virCgroupDetectPlacementCB detectPlacement;
|
|
|
c480ed |
};
|
|
|
c480ed |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
|
c480ed |
index bd9f28f6e9..68bb1c6f5d 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv1.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv1.c
|
|
|
c480ed |
@@ -183,6 +183,42 @@ virCgroupV1CopyMounts(virCgroupPtr group,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV1CopyPlacement(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ virCgroupPtr parent)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
+ for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c480ed |
+ if (!group->controllers[i].mountPoint)
|
|
|
c480ed |
+ continue;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (i == VIR_CGROUP_CONTROLLER_SYSTEMD)
|
|
|
c480ed |
+ continue;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (path[0] == '/') {
|
|
|
c480ed |
+ if (VIR_STRDUP(group->controllers[i].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->controllers[i].placement,
|
|
|
c480ed |
+ "%s%s%s",
|
|
|
c480ed |
+ parent->controllers[i].placement,
|
|
|
c480ed |
+ (STREQ(parent->controllers[i].placement, "/") ||
|
|
|
c480ed |
+ STREQ(path, "") ? "" : "/"),
|
|
|
c480ed |
+ path) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
static int
|
|
|
c480ed |
virCgroupV1ResolveMountLink(const char *mntDir,
|
|
|
c480ed |
const char *typeStr,
|
|
|
c480ed |
@@ -343,6 +379,7 @@ virCgroupBackend virCgroupV1Backend = {
|
|
|
c480ed |
.available = virCgroupV1Available,
|
|
|
c480ed |
.validateMachineGroup = virCgroupV1ValidateMachineGroup,
|
|
|
c480ed |
.copyMounts = virCgroupV1CopyMounts,
|
|
|
c480ed |
+ .copyPlacement = virCgroupV1CopyPlacement,
|
|
|
c480ed |
.detectMounts = virCgroupV1DetectMounts,
|
|
|
c480ed |
.detectPlacement = virCgroupV1DetectPlacement,
|
|
|
c480ed |
};
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|