cgroups: handle fallback gracefully

parent 1274eb5c
...@@ -3458,7 +3458,7 @@ int cgroup_get(const char *name, const char *lxcpath, ...@@ -3458,7 +3458,7 @@ int cgroup_get(const char *name, const char *lxcpath,
unified_fd = lxc_cmd_get_limiting_cgroup2_fd(name, lxcpath); unified_fd = lxc_cmd_get_limiting_cgroup2_fd(name, lxcpath);
if (unified_fd < 0) if (unified_fd < 0)
return ret_errno(ENOCGROUP2); return ret_errno(ENOSYS);
ret = lxc_read_try_buf_at(unified_fd, filename, buf, len); ret = lxc_read_try_buf_at(unified_fd, filename, buf, len);
if (ret < 0) if (ret < 0)
...@@ -3480,7 +3480,7 @@ int cgroup_set(const char *name, const char *lxcpath, ...@@ -3480,7 +3480,7 @@ int cgroup_set(const char *name, const char *lxcpath,
unified_fd = lxc_cmd_get_limiting_cgroup2_fd(name, lxcpath); unified_fd = lxc_cmd_get_limiting_cgroup2_fd(name, lxcpath);
if (unified_fd < 0) if (unified_fd < 0)
return ret_errno(ENOCGROUP2); return ret_errno(ENOSYS);
if (strnequal(filename, "devices.", STRLITERALLEN("devices."))) { if (strnequal(filename, "devices.", STRLITERALLEN("devices."))) {
struct device_item device = {}; struct device_item device = {};
......
...@@ -3290,7 +3290,7 @@ static bool do_lxcapi_set_cgroup_item(struct lxc_container *c, const char *subsy ...@@ -3290,7 +3290,7 @@ static bool do_lxcapi_set_cgroup_item(struct lxc_container *c, const char *subsy
return false; return false;
ret = cgroup_set(c->name, c->config_path, subsys, value); 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); cgroup_ops = cgroup_init(c->lxc_conf);
if (!cgroup_ops) if (!cgroup_ops)
return false; return false;
...@@ -3315,7 +3315,7 @@ static int do_lxcapi_get_cgroup_item(struct lxc_container *c, const char *subsys ...@@ -3315,7 +3315,7 @@ static int do_lxcapi_get_cgroup_item(struct lxc_container *c, const char *subsys
return -1; return -1;
ret = cgroup_get(c->name, c->config_path, subsys, retv, inlen); 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); cgroup_ops = cgroup_init(c->lxc_conf);
if (!cgroup_ops) if (!cgroup_ops)
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment