]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxccontainer: use cgroup_set()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 2 Feb 2021 17:03:41 +0000 (18:03 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 2 Feb 2021 17:03:41 +0000 (18:03 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/lxccontainer.c

index ccb4c5c582078249baf0ab2b4671bc75bbaccc09..c8e2b78ffb9552e379bc20ae5e0d904770fb595d 100644 (file)
@@ -3277,6 +3277,7 @@ WRAP_API_1(bool, lxcapi_set_config_path, const char *)
 static bool do_lxcapi_set_cgroup_item(struct lxc_container *c, const char *subsys, const char *value)
 {
        call_cleaner(cgroup_exit) struct cgroup_ops *cgroup_ops = NULL;
+       int ret;
 
        if (!c)
                return false;
@@ -3284,12 +3285,16 @@ static bool do_lxcapi_set_cgroup_item(struct lxc_container *c, const char *subsy
        if (is_stopped(c))
                return false;
 
-       cgroup_ops = cgroup_init(c->lxc_conf);
-       if (!cgroup_ops)
-               return false;
+       ret = cgroup_set(c->lxc_conf, c->name, c->config_path, subsys, value);
+       if (ret == ENOCGROUP2) {
+               cgroup_ops = cgroup_init(c->lxc_conf);
+               if (!cgroup_ops)
+                       return false;
+
+               ret = cgroup_ops->set(cgroup_ops, subsys, value, c->name, c->config_path) == 0;
+       }
 
-       return cgroup_ops->set(cgroup_ops, subsys, value, c->name,
-                              c->config_path) == 0;
+       return ret == 0;
 }
 
 WRAP_API_2(bool, lxcapi_set_cgroup_item, const char *, const char *)