Skip to content

Commit

Permalink
lxccontainer: use cgroup_get()
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Feb 26, 2021
1 parent 6d9ba01 commit cc9644d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/lxc/lxccontainer.c
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit cc9644d

Please sign in to comment.