Skip to content

Commit

Permalink
lxccontainer: use cgroup_set()
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 2, 2021
1 parent efb4b3e commit 69edb51
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/lxc/lxccontainer.c
Expand Up @@ -3277,19 +3277,24 @@ 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;

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 *)
Expand Down

0 comments on commit 69edb51

Please sign in to comment.