Commit 3bdf52d7 by Daniel Lezcano Committed by Daniel Lezcano

Store the container name in the handler

Store the container in the handler, so it is accessible everywhere. Signed-off-by: 's avatarDaniel Lezcano <dlezcan@fr.ibm.com>
parent e0f888d9
...@@ -279,10 +279,16 @@ struct lxc_handler *lxc_init(const char *name, struct lxc_conf *conf) ...@@ -279,10 +279,16 @@ struct lxc_handler *lxc_init(const char *name, struct lxc_conf *conf)
handler->conf = conf; handler->conf = conf;
handler->name = strdup(name);
if (!handler->name) {
ERROR("failed to allocate memory");
goto out_free;
}
/* Begin the set the state to STARTING*/ /* Begin the set the state to STARTING*/
if (lxc_set_state(name, handler, STARTING)) { if (lxc_set_state(name, handler, STARTING)) {
ERROR("failed to set state '%s'", lxc_state2str(STARTING)); ERROR("failed to set state '%s'", lxc_state2str(STARTING));
goto out_free; goto out_free_name;
} }
if (lxc_create_tty(name, conf)) { if (lxc_create_tty(name, conf)) {
...@@ -317,6 +323,9 @@ out_delete_tty: ...@@ -317,6 +323,9 @@ out_delete_tty:
lxc_delete_tty(&conf->tty_info); lxc_delete_tty(&conf->tty_info);
out_aborting: out_aborting:
lxc_set_state(name, handler, ABORTING); lxc_set_state(name, handler, ABORTING);
out_free_name:
free(handler->name);
handler->name = NULL;
out_free: out_free:
free(handler); free(handler);
return NULL; return NULL;
...@@ -333,6 +342,7 @@ void lxc_fini(const char *name, struct lxc_handler *handler) ...@@ -333,6 +342,7 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
lxc_delete_console(&handler->conf->console); lxc_delete_console(&handler->conf->console);
lxc_delete_tty(&handler->conf->tty_info); lxc_delete_tty(&handler->conf->tty_info);
free(handler->name);
free(handler); free(handler);
LXC_TTY_DEL_HANDLER(SIGQUIT); LXC_TTY_DEL_HANDLER(SIGQUIT);
......
...@@ -30,6 +30,7 @@ struct lxc_conf; ...@@ -30,6 +30,7 @@ struct lxc_conf;
struct lxc_handler { struct lxc_handler {
pid_t pid; pid_t pid;
char *name;
lxc_state_t state; lxc_state_t state;
int sigfd; int sigfd;
char nsgroup[MAXPATHLEN]; char nsgroup[MAXPATHLEN];
......
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