Skip to content

Commit

Permalink
lxccontainer: use cgroup_freeze() and cgroup_unfreeze()
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 4639029 commit 97d7b20
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/lxc/lxccontainer.c
Expand Up @@ -507,32 +507,41 @@ WRAP_API(bool, lxcapi_is_running)

static bool do_lxcapi_freeze(struct lxc_container *c)
{
bool bret = true;
lxc_state_t s;

if (!c || !c->lxc_conf)
return false;

s = lxc_getstate(c->name, c->config_path);
if (s != FROZEN)
return lxc_freeze(c->lxc_conf, c->name, c->config_path) == 0;
if (s != FROZEN) {
bret = cgroup_freeze(c->lxc_conf, c->name, c->config_path, -1);
if (!bret && errno == ENOCGROUP2)
bret = lxc_freeze(c->lxc_conf, c->name, c->config_path);
}

return true;
return bret;
}

WRAP_API(bool, lxcapi_freeze)

static bool do_lxcapi_unfreeze(struct lxc_container *c)
{
bool bret = true;
lxc_state_t s;

if (!c || !c->lxc_conf)
return false;

s = lxc_getstate(c->name, c->config_path);
if (s == FROZEN)
return lxc_unfreeze(c->lxc_conf, c->name, c->config_path) == 0;
if (s == FROZEN) {
bret = cgroup_unfreeze(c->lxc_conf, c->name, c->config_path, -1);
if (!bret && errno == ENOCGROUP2)
bret = lxc_unfreeze(c->lxc_conf, c->name, c->config_path);
}

return true;

return bret;
}

WRAP_API(bool, lxcapi_unfreeze)
Expand Down

0 comments on commit 97d7b20

Please sign in to comment.