cgroups/freezer: fix and improve cgroup2 freezer implementation

parent df3218e1
......@@ -1255,6 +1255,72 @@ static int lxc_cmd_unfreeze_callback(int fd, struct lxc_cmd_req *req,
return lxc_cmd_rsp_send(fd, &rsp);
}
int lxc_cmd_freeze(const char *name, const char *lxcpath, int timeout)
{
int ret, stopped;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_FREEZE,
.data = INT_TO_PTR(timeout),
},
};
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret <= 0 || cmd.rsp.ret < 0)
return error_log_errno(errno, "Failed to freeze container");
return cmd.rsp.ret;
}
static int lxc_cmd_freeze_callback(int fd, struct lxc_cmd_req *req,
struct lxc_handler *handler,
struct lxc_epoll_descr *descr)
{
int timeout = PTR_TO_INT(req->data);
struct lxc_cmd_rsp rsp = {
.ret = -ENOENT,
};
struct cgroup_ops *ops = handler->cgroup_ops;
if (ops->cgroup_layout == CGROUP_LAYOUT_UNIFIED)
rsp.ret = ops->freeze(ops, timeout);
return lxc_cmd_rsp_send(fd, &rsp);
}
int lxc_cmd_unfreeze(const char *name, const char *lxcpath, int timeout)
{
int ret, stopped;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = LXC_CMD_UNFREEZE,
.data = INT_TO_PTR(timeout),
},
};
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret <= 0 || cmd.rsp.ret < 0)
return error_log_errno(errno, "Failed to unfreeze container");
return cmd.rsp.ret;
}
static int lxc_cmd_unfreeze_callback(int fd, struct lxc_cmd_req *req,
struct lxc_handler *handler,
struct lxc_epoll_descr *descr)
{
int timeout = PTR_TO_INT(req->data);
struct lxc_cmd_rsp rsp = {
.ret = -ENOENT,
};
struct cgroup_ops *ops = handler->cgroup_ops;
if (ops->cgroup_layout == CGROUP_LAYOUT_UNIFIED)
rsp.ret = ops->unfreeze(ops, timeout);
return lxc_cmd_rsp_send(fd, &rsp);
}
static int lxc_cmd_process(int fd, struct lxc_cmd_req *req,
struct lxc_handler *handler,
struct lxc_epoll_descr *descr)
......
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