[systemd-devel] [PATCH v2] cgroup-util: fix is_valid check to pass for unified cgroup hierchy.
Dimitri John Ledkov
dimitri.j.ledkov at intel.com
Thu May 28 08:42:54 PDT 2015
It appears in /proc/self/cgroup as `0::/'
---
v2 change: Test for unified cgroup should pass irrespective of
whether allow_named is set.
src/shared/cgroup-util.c | 4 ++++
src/test/test-cgroup-util.c | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
index c0b0ca4..eda7523 100644
--- a/src/shared/cgroup-util.c
+++ b/src/shared/cgroup-util.c
@@ -1616,6 +1616,10 @@ bool cg_controller_is_valid(const char *p, bool allow_named) {
if (!p)
return false;
+ /* Unified cgroup */
+ if (*p == 0)
+ return true;
+
if (allow_named) {
s = startswith(p, "name=");
if (s)
diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c
index 4a89f64..015d3d7 100644
--- a/src/test/test-cgroup-util.c
+++ b/src/test/test-cgroup-util.c
@@ -247,7 +247,8 @@ static void test_controller_is_valid(void) {
assert_se(cg_controller_is_valid("foobar", false));
assert_se(cg_controller_is_valid("foo_bar", false));
assert_se(cg_controller_is_valid("name=foo", true));
- assert_se(!cg_controller_is_valid("", false));
+ assert_se(cg_controller_is_valid("", true));
+ assert_se(cg_controller_is_valid("", false));
assert_se(!cg_controller_is_valid("name=", true));
assert_se(!cg_controller_is_valid("=", false));
assert_se(!cg_controller_is_valid("cpu,cpuacct", false));
--
2.1.4
More information about the systemd-devel
mailing list