Commit 0086f499 by Serge Hallyn Committed by Stéphane Graber

stop cmd callback: unfreeze by path only

in particular, regular unfreeze uses the cmd api to request the cgroup of the container. If we are already in the lxc-start monitor, we can't use the cmd api. (I knew when I started this would be a problem but then as it didn't reliably crash, I forgot to handle it) Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 6873d6f0
...@@ -358,6 +358,18 @@ out_free: ...@@ -358,6 +358,18 @@ out_free:
return false; return false;
} }
static int cgm_unfreeze_fromhandler(struct lxc_handler *handler)
{
struct cgm_data *d = handler->cgroup_info->data;
if (cgmanager_set_value_sync(NULL, cgroup_manager, "freezer", d->cgroup_path,
"freezer.state", "THAWED") != 0) {
ERROR("Error unfreezing %s", d->cgroup_path);
return false;
}
return true;
}
static struct cgroup_ops cgmanager_ops = { static struct cgroup_ops cgmanager_ops = {
.destroy = cgm_destroy, .destroy = cgm_destroy,
.init = cgm_init, .init = cgm_init,
...@@ -367,6 +379,7 @@ static struct cgroup_ops cgmanager_ops = { ...@@ -367,6 +379,7 @@ static struct cgroup_ops cgmanager_ops = {
.get_cgroup = cgm_get_cgroup, .get_cgroup = cgm_get_cgroup,
.get = cgm_get, .get = cgm_get,
.set = cgm_set, .set = cgm_set,
.unfreeze_fromhandler = cgm_unfreeze_fromhandler,
.name = "cgmanager" .name = "cgmanager"
}; };
#endif #endif
...@@ -2168,6 +2168,21 @@ static char *cgfs_get_cgroup(struct lxc_handler *handler, const char *subsystem) ...@@ -2168,6 +2168,21 @@ static char *cgfs_get_cgroup(struct lxc_handler *handler, const char *subsystem)
return lxc_cgroup_get_hierarchy_path_handler(subsystem, handler); return lxc_cgroup_get_hierarchy_path_handler(subsystem, handler);
} }
static int cgfs_unfreeze_fromhandler(struct lxc_handler *handler)
{
char *cgabspath, *cgrelpath;
int ret;
cgrelpath = lxc_cgroup_get_hierarchy_path_handler("freezer", handler);
cgabspath = lxc_cgroup_find_abs_path("freezer", cgrelpath, true, NULL);
if (!cgabspath)
return -1;
ret = do_cgroup_set(cgabspath, "freezer.state", "THAWED");
free(cgabspath);
return ret;
}
static struct cgroup_ops cgfs_ops = { static struct cgroup_ops cgfs_ops = {
.destroy = cgfs_destroy, .destroy = cgfs_destroy,
.init = cgfs_init, .init = cgfs_init,
...@@ -2177,6 +2192,7 @@ static struct cgroup_ops cgfs_ops = { ...@@ -2177,6 +2192,7 @@ static struct cgroup_ops cgfs_ops = {
.get_cgroup = cgfs_get_cgroup, .get_cgroup = cgfs_get_cgroup,
.get = lxc_cgroupfs_get, .get = lxc_cgroupfs_get,
.set = lxc_cgroupfs_set, .set = lxc_cgroupfs_set,
.unfreeze_fromhandler = cgfs_unfreeze_fromhandler,
.name = "cgroupfs", .name = "cgroupfs",
}; };
static void init_cg_ops(void) static void init_cg_ops(void)
...@@ -2281,3 +2297,8 @@ int lxc_cgroup_get(const char *filename, char *value, size_t len, const char *na ...@@ -2281,3 +2297,8 @@ int lxc_cgroup_get(const char *filename, char *value, size_t len, const char *na
init_cg_ops(); init_cg_ops();
return active_cg_ops->get(filename, value, len, name, lxcpath); return active_cg_ops->get(filename, value, len, name, lxcpath);
} }
int lxc_unfreeze_fromhandler(struct lxc_handler *handler)
{
return active_cg_ops->unfreeze_fromhandler(handler);
}
...@@ -178,6 +178,7 @@ struct cgroup_ops { ...@@ -178,6 +178,7 @@ struct cgroup_ops {
char *(*get_cgroup)(struct lxc_handler *handler, const char *subsystem); char *(*get_cgroup)(struct lxc_handler *handler, const char *subsystem);
int (*set)(const char *filename, const char *value, const char *name, const char *lxcpath); int (*set)(const char *filename, const char *value, const char *name, const char *lxcpath);
int (*get)(const char *filename, char *value, size_t len, const char *name, const char *lxcpath); int (*get)(const char *filename, char *value, size_t len, const char *name, const char *lxcpath);
int (*unfreeze_fromhandler)(struct lxc_handler *handler);
const char *name; const char *name;
}; };
...@@ -214,5 +215,6 @@ extern bool cgroup_create_legacy(struct lxc_handler *handler); ...@@ -214,5 +215,6 @@ extern bool cgroup_create_legacy(struct lxc_handler *handler);
extern char *cgroup_get_cgroup(struct lxc_handler *handler, const char *subsystem); extern char *cgroup_get_cgroup(struct lxc_handler *handler, const char *subsystem);
extern int lxc_cgroup_set(const char *filename, const char *value, const char *name, const char *lxcpath); extern int lxc_cgroup_set(const char *filename, const char *value, const char *name, const char *lxcpath);
extern int lxc_cgroup_get(const char *filename, char *value, size_t len, const char *name, const char *lxcpath); extern int lxc_cgroup_get(const char *filename, char *value, size_t len, const char *name, const char *lxcpath);
extern int lxc_unfreeze_fromhandler(struct lxc_handler *handler);
#endif #endif
...@@ -591,7 +591,7 @@ static int lxc_cmd_stop_callback(int fd, struct lxc_cmd_req *req, ...@@ -591,7 +591,7 @@ static int lxc_cmd_stop_callback(int fd, struct lxc_cmd_req *req,
memset(&rsp, 0, sizeof(rsp)); memset(&rsp, 0, sizeof(rsp));
rsp.ret = kill(handler->pid, stopsignal); rsp.ret = kill(handler->pid, stopsignal);
if (!rsp.ret) { if (!rsp.ret) {
ret = lxc_unfreeze(handler->name, handler->lxcpath); ret = lxc_unfreeze_fromhandler(handler);
if (!ret) if (!ret)
return 0; return 0;
ERROR("Failed to unfreeze %s:%s", handler->lxcpath, handler->name); ERROR("Failed to unfreeze %s:%s", handler->lxcpath, handler->name);
......
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