]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgroups: handle fallback gracefully
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 24 Feb 2021 08:41:32 +0000 (09:41 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 24 Feb 2021 08:41:32 +0000 (09:41 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c
src/lxc/lxccontainer.c

index a27c89ad96e7d9c2c05ebcbed39580de982f8748..59f0242905e2d3ea430c65e26beed75b4d26c289 100644 (file)
@@ -3460,7 +3460,7 @@ int cgroup_get(const char *name, const char *lxcpath,
 
        unified_fd = lxc_cmd_get_limiting_cgroup2_fd(name, lxcpath);
        if (unified_fd < 0)
-               return ret_errno(ENOCGROUP2);
+               return ret_errno(ENOSYS);
 
        ret = lxc_read_try_buf_at(unified_fd, filename, buf, len);
        if (ret < 0)
@@ -3482,7 +3482,7 @@ int cgroup_set(const char *name, const char *lxcpath,
 
        unified_fd = lxc_cmd_get_limiting_cgroup2_fd(name, lxcpath);
        if (unified_fd < 0)
-               return ret_errno(ENOCGROUP2);
+               return ret_errno(ENOSYS);
 
        if (strnequal(filename, "devices.", STRLITERALLEN("devices."))) {
                struct device_item device = {};
index 1d53907ebd1212edb8071ecf143ba5d69afb76d8..5d43815c71ab9a4192987447be444cd241293664 100644 (file)
@@ -3290,7 +3290,7 @@ static bool do_lxcapi_set_cgroup_item(struct lxc_container *c, const char *subsy
                return false;
 
        ret = cgroup_set(c->name, c->config_path, subsys, value);
-       if (ret == -ENOCGROUP2) {
+       if (ret < 0 && ERRNO_IS_NOT_SUPPORTED(ret)) {
                cgroup_ops = cgroup_init(c->lxc_conf);
                if (!cgroup_ops)
                        return false;
@@ -3315,7 +3315,7 @@ static int do_lxcapi_get_cgroup_item(struct lxc_container *c, const char *subsys
                return -1;
 
        ret = cgroup_get(c->name, c->config_path, subsys, retv, inlen);
-       if (ret == -ENOCGROUP2) {
+       if (ret < 0 && ERRNO_IS_NOT_SUPPORTED(ret)) {
                cgroup_ops = cgroup_init(c->lxc_conf);
                if (!cgroup_ops)
                        return -1;