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