Whick makes for easier error checking and fallback code.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
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;
"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;
"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;
}
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)
{
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;
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;
else
ret = do_freeze_thaw(false, conf, name, lxcpath);
lxc_cmd_notify_state_listeners(name, lxcpath, !ret ? RUNNING : FROZEN);
- return ret == 0;
+ return ret;
}
* @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
static bool do_lxcapi_freeze(struct lxc_container *c)
{
- bool bret = true;
+ int ret = 0;
lxc_state_t s;
if (!c || !c->lxc_conf)
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)
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)