cgroups: switch back to returning ints

Whick makes for easier error checking and fallback code. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 29619d41
......@@ -3592,7 +3592,7 @@ static int __cgroup_freeze(int unified_fd,
return log_trace(0, "Container now %s", (state_num == 1) ? "frozen" : "unfrozen");
}
bool cgroup_freeze(const char *name, const char *lxcpath, int timeout)
int cgroup_freeze(const char *name, const char *lxcpath, int timeout)
{
__do_close int unified_fd = -EBADF;
int ret;
......@@ -3609,10 +3609,10 @@ bool cgroup_freeze(const char *name, const char *lxcpath, int timeout)
"Failed to create epoll instance to wait for container freeze",
"Failed to wait for container to be frozen");
lxc_cmd_notify_state_listeners(name, lxcpath, !ret ? FROZEN : RUNNING);
return ret == 0;
return ret;
}
bool cgroup_unfreeze(const char *name, const char *lxcpath, int timeout)
int cgroup_unfreeze(const char *name, const char *lxcpath, int timeout)
{
__do_close int unified_fd = -EBADF;
int ret;
......@@ -3629,5 +3629,5 @@ bool cgroup_unfreeze(const char *name, const char *lxcpath, int timeout)
"Failed to create epoll instance to wait for container freeze",
"Failed to wait for container to be frozen");
lxc_cmd_notify_state_listeners(name, lxcpath, !ret ? RUNNING : FROZEN);
return ret == 0;
return ret;
}
......@@ -195,8 +195,8 @@ __hidden extern int cgroup_get(const char *name, const char *lxcpath,
const char *filename, char *buf, size_t len);
__hidden extern int cgroup_set(const char *name, const char *lxcpath,
const char *filename, const char *value);
__hidden extern bool cgroup_freeze(const char *name, const char *lxcpath, int timeout);
__hidden extern bool cgroup_unfreeze(const char *name, const char *lxcpath, int timeout);
__hidden extern int cgroup_freeze(const char *name, const char *lxcpath, int timeout);
__hidden extern int cgroup_unfreeze(const char *name, const char *lxcpath, int timeout);
static inline bool pure_unified_layout(const struct cgroup_ops *ops)
{
......
......@@ -68,7 +68,7 @@ static int do_freeze_thaw(bool freeze, struct lxc_conf *conf, const char *name,
return 0;
}
bool lxc_freeze(struct lxc_conf *conf, const char *name, const char *lxcpath)
int lxc_freeze(struct lxc_conf *conf, const char *name, const char *lxcpath)
{
int ret;
......@@ -78,10 +78,10 @@ bool lxc_freeze(struct lxc_conf *conf, const char *name, const char *lxcpath)
else
ret = do_freeze_thaw(true, conf, name, lxcpath);
lxc_cmd_notify_state_listeners(name, lxcpath, !ret ? FROZEN : RUNNING);
return ret == 0;
return ret;
}
bool lxc_unfreeze(struct lxc_conf *conf, const char *name, const char *lxcpath)
int lxc_unfreeze(struct lxc_conf *conf, const char *name, const char *lxcpath)
{
int ret;
......@@ -91,5 +91,5 @@ bool lxc_unfreeze(struct lxc_conf *conf, const char *name, const char *lxcpath)
else
ret = do_freeze_thaw(false, conf, name, lxcpath);
lxc_cmd_notify_state_listeners(name, lxcpath, !ret ? RUNNING : FROZEN);
return ret == 0;
return ret;
}
......@@ -62,14 +62,14 @@ __hidden extern int lxc_monitor_close(int fd);
* @name : the container name
* Returns 0 on success, < 0 otherwise
*/
__hidden extern bool lxc_freeze(struct lxc_conf *conf, const char *name, const char *lxcpath);
__hidden extern int lxc_freeze(struct lxc_conf *conf, const char *name, const char *lxcpath);
/*
* Unfreeze all previously frozen tasks.
* @name : the name of the container
* Return 0 on success, < 0 otherwise
*/
__hidden extern bool lxc_unfreeze(struct lxc_conf *conf, const char *name, const char *lxcpath);
__hidden extern int lxc_unfreeze(struct lxc_conf *conf, const char *name, const char *lxcpath);
/*
* Retrieve the container state
......
......@@ -507,7 +507,7 @@ WRAP_API(bool, lxcapi_is_running)
static bool do_lxcapi_freeze(struct lxc_container *c)
{
bool bret = true;
int ret = 0;
lxc_state_t s;
if (!c || !c->lxc_conf)
......@@ -515,19 +515,19 @@ static bool do_lxcapi_freeze(struct lxc_container *c)
s = lxc_getstate(c->name, c->config_path);
if (s != FROZEN) {
bret = cgroup_freeze(c->name, c->config_path, -1);
if (!bret && errno == ENOCGROUP2)
bret = lxc_freeze(c->lxc_conf, c->name, c->config_path);
ret = cgroup_freeze(c->name, c->config_path, -1);
if (ret == -ENOCGROUP2)
ret = lxc_freeze(c->lxc_conf, c->name, c->config_path);
}
return bret;
return ret == 0;
}
WRAP_API(bool, lxcapi_freeze)
static bool do_lxcapi_unfreeze(struct lxc_container *c)
{
bool bret = true;
int ret = 0;
lxc_state_t s;
if (!c || !c->lxc_conf)
......@@ -535,13 +535,13 @@ static bool do_lxcapi_unfreeze(struct lxc_container *c)
s = lxc_getstate(c->name, c->config_path);
if (s == FROZEN) {
bret = cgroup_unfreeze(c->name, c->config_path, -1);
if (!bret && errno == ENOCGROUP2)
bret = lxc_unfreeze(c->lxc_conf, c->name, c->config_path);
ret = cgroup_unfreeze(c->name, c->config_path, -1);
if (ret == -ENOCGROUP2)
ret = lxc_unfreeze(c->lxc_conf, c->name, c->config_path);
}
return bret;
return ret == 0;
}
WRAP_API(bool, lxcapi_unfreeze)
......
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