summaryrefslogtreecommitdiff
path: root/src/util/vircgroupv1.c
diff options
context:
space:
mode:
authorPavel Hrdina <phrdina@redhat.com>2020-10-21 14:35:48 +0200
committerPavel Hrdina <phrdina@redhat.com>2020-11-03 21:26:32 +0100
commit085590fee4c88783c27534d2103adceacfa279bb (patch)
tree8b1faf8ca9506edcc5c83eb1fc5ae8ad06121694 /src/util/vircgroupv1.c
parentca7b305631ded82a5a32f00c4c55bcdf78d19408 (diff)
downloadlibvirt-085590fee4c88783c27534d2103adceacfa279bb.tar.gz
vircgroup: introduce virCgroupSetPlacement
Currently this task is done by virCgroupCopyPlacement when the @path starts with "/". virCgroupNew is always called with @path starting with "/" and there is no parent to copy path from. To make it obvious what the code is doing introduce new helper. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Diffstat (limited to 'src/util/vircgroupv1.c')
-rw-r--r--src/util/vircgroupv1.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 98b5aa047d..ed4b0813f2 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -365,6 +365,26 @@ virCgroupV1DetectPlacement(virCgroupPtr group,
static int
+virCgroupV1SetPlacement(virCgroupPtr group,
+ const char *path)
+{
+ size_t i;
+
+ for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
+ if (!group->legacy[i].mountPoint)
+ continue;
+
+ if (i == VIR_CGROUP_CONTROLLER_SYSTEMD)
+ continue;
+
+ group->legacy[i].placement = g_strdup(path);
+ }
+
+ return 0;
+}
+
+
+static int
virCgroupV1ValidatePlacement(virCgroupPtr group,
pid_t pid)
{
@@ -2101,6 +2121,7 @@ virCgroupBackend virCgroupV1Backend = {
.copyPlacement = virCgroupV1CopyPlacement,
.detectMounts = virCgroupV1DetectMounts,
.detectPlacement = virCgroupV1DetectPlacement,
+ .setPlacement = virCgroupV1SetPlacement,
.validatePlacement = virCgroupV1ValidatePlacement,
.stealPlacement = virCgroupV1StealPlacement,
.detectControllers = virCgroupV1DetectControllers,