From bf90d192a53b1d940a42ef0343174933b4264534 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Sun, 21 Feb 2021 11:36:06 +0100 Subject: [PATCH] cgroups: handle lxc.cgroup.use global parameter Signed-off-by: Christian Brauner --- src/lxc/cgroups/cgfsng.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index ba67d88600..574e8569a4 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -275,7 +275,7 @@ static inline bool is_unified_hierarchy(const struct hierarchy *h) /* Return true if the controller @entry is found in the null-terminated list of * hierarchies @hlist. */ -static bool controller_found(struct hierarchy **hlist, char *entry) +static bool controller_available(struct hierarchy **hlist, char *entry) { if (!hlist) return false; @@ -287,10 +287,7 @@ static bool controller_found(struct hierarchy **hlist, char *entry) return false; } -/* Return true if all of the controllers which we require have been found. The - * required list is freezer and anything in lxc.cgroup.use. - */ -__lxc_unused static bool all_controllers_found(struct cgroup_ops *ops) +static bool controllers_available(struct cgroup_ops *ops) { struct hierarchy **hlist; @@ -299,8 +296,8 @@ __lxc_unused static bool all_controllers_found(struct cgroup_ops *ops) hlist = ops->hierarchies; for (char **cur = ops->cgroup_use; cur && *cur; cur++) - if (!controller_found(hlist, *cur)) - return log_error(false, "No %s controller mountpoint found", *cur); + if (!controller_available(hlist, *cur)) + return log_error(false, "The %s controller found", *cur); return true; } @@ -3225,6 +3222,9 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative, } } + if (!controllers_available(ops)) + return syserrno_set(-ENOENT, "One or more requested controllers unavailable or not delegated"); + return 0; }