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

index da18be8aa172bb7d40a005e8228295c6ca35ed21..eb29beb43c7ea07e092d93360019c572e8d36431 100644 (file)
@@ -3296,6 +3296,8 @@ WRAP_API_2(bool, lxcapi_set_cgroup_item, const char *, const char *)
 
 static int do_lxcapi_get_cgroup_item(struct lxc_container *c, const char *subsys, char *retv, int inlen)
 {
+       int ret;
+
        call_cleaner(cgroup_exit) struct cgroup_ops *cgroup_ops = NULL;
 
        if (!c)
@@ -3304,12 +3306,16 @@ static int do_lxcapi_get_cgroup_item(struct lxc_container *c, const char *subsys
        if (is_stopped(c))
                return -1;
 
-       cgroup_ops = cgroup_init(c->lxc_conf);
-       if (!cgroup_ops)
-               return -1;
+       ret = cgroup_get(c->lxc_conf, subsys, retv, inlen, c->name, c->config_path);
+       if (ret == ENOCGROUP2) {
+               cgroup_ops = cgroup_init(c->lxc_conf);
+               if (!cgroup_ops)
+                       return -1;
+
+               return cgroup_ops->get(cgroup_ops, subsys, retv, inlen, c->name, c->config_path);
+       }
 
-       return cgroup_ops->get(cgroup_ops, subsys, retv, inlen, c->name,
-                              c->config_path);
+       return ret;
 }
 
 WRAP_API_3(int, lxcapi_get_cgroup_item, const char *, char *, int)