forked from rpms/libvirt
105 lines
3.6 KiB
Diff
105 lines
3.6 KiB
Diff
|
From 3980cde103a2804abc62a2eb3bcea39cccf20286 Mon Sep 17 00:00:00 2001
|
||
|
Message-Id: <3980cde103a2804abc62a2eb3bcea39cccf20286@dist-git>
|
||
|
From: Pavel Hrdina <phrdina@redhat.com>
|
||
|
Date: Mon, 1 Jul 2019 17:08:20 +0200
|
||
|
Subject: [PATCH] util: vircgroupv2: separate return values of
|
||
|
virCgroupV2EnableController
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
In order to skip controllers that we are not able to activate we need
|
||
|
to return different return value so the caller can decide what to do.
|
||
|
|
||
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
||
|
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
|
||
|
(cherry picked from commit 29a94a3fefeea0fb29b0b9f485c83c49b5bdae71)
|
||
|
|
||
|
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
||
|
|
||
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
||
|
Message-Id: <d0356666404a39fd0d6499490f60df17f3ee90b5.1561993100.git.phrdina@redhat.com>
|
||
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||
|
---
|
||
|
src/util/vircgroupv2.c | 32 ++++++++++++++++++++++++++------
|
||
|
1 file changed, 26 insertions(+), 6 deletions(-)
|
||
|
|
||
|
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
||
|
index 98d313bf82..a67d5cfe04 100644
|
||
|
--- a/src/util/vircgroupv2.c
|
||
|
+++ b/src/util/vircgroupv2.c
|
||
|
@@ -352,22 +352,40 @@ virCgroupV2PathOfController(virCgroupPtr group,
|
||
|
}
|
||
|
|
||
|
|
||
|
+/**
|
||
|
+ * virCgroupV2EnableController:
|
||
|
+ *
|
||
|
+ * Returns: -1 on fatal error
|
||
|
+ * -2 if we failed to write into cgroup.subtree_control
|
||
|
+ * 0 on success
|
||
|
+ */
|
||
|
static int
|
||
|
virCgroupV2EnableController(virCgroupPtr parent,
|
||
|
- int controller)
|
||
|
+ int controller,
|
||
|
+ bool report)
|
||
|
{
|
||
|
VIR_AUTOFREE(char *) val = NULL;
|
||
|
+ VIR_AUTOFREE(char *) path = NULL;
|
||
|
|
||
|
if (virAsprintf(&val, "+%s",
|
||
|
virCgroupV2ControllerTypeToString(controller)) < 0) {
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
- if (virCgroupSetValueStr(parent, controller,
|
||
|
- "cgroup.subtree_control", val) < 0) {
|
||
|
+ if (virCgroupPathOfController(parent, controller,
|
||
|
+ "cgroup.subtree_control", &path) < 0) {
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
+ if (virFileWriteStr(path, val, 0) < 0) {
|
||
|
+ if (report) {
|
||
|
+ virReportSystemError(errno,
|
||
|
+ _("Failed to enable controller '%s' for '%s'"),
|
||
|
+ val, path);
|
||
|
+ }
|
||
|
+ return -2;
|
||
|
+ }
|
||
|
+
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
@@ -405,13 +423,15 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
|
||
|
|
||
|
if (virCgroupV2HasController(parent, VIR_CGROUP_CONTROLLER_CPU) &&
|
||
|
virCgroupV2EnableController(parent,
|
||
|
- VIR_CGROUP_CONTROLLER_CPU) < 0) {
|
||
|
+ VIR_CGROUP_CONTROLLER_CPU,
|
||
|
+ true) < 0) {
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
if (virCgroupV2HasController(parent, VIR_CGROUP_CONTROLLER_CPUSET) &&
|
||
|
virCgroupV2EnableController(parent,
|
||
|
- VIR_CGROUP_CONTROLLER_CPUSET) < 0) {
|
||
|
+ VIR_CGROUP_CONTROLLER_CPUSET,
|
||
|
+ true) < 0) {
|
||
|
return -1;
|
||
|
}
|
||
|
} else {
|
||
|
@@ -424,7 +444,7 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
|
||
|
if (i == VIR_CGROUP_CONTROLLER_CPUACCT)
|
||
|
continue;
|
||
|
|
||
|
- if (virCgroupV2EnableController(parent, i) < 0)
|
||
|
+ if (virCgroupV2EnableController(parent, i, true) < 0)
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
--
|
||
|
2.22.0
|
||
|
|