From: Daniel Lezcano Date: Thu, 8 Apr 2010 07:44:23 +0000 (+0200) Subject: Store the container name in the handler X-Git-Tag: lxc-0.7.0~111 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bdf52d753ecf347b3b5cbff97675032f2de3e5e;p=thirdparty%2Flxc.git Store the container name in the handler Store the container in the handler, so it is accessible everywhere. Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/start.c b/src/lxc/start.c index ec084493b..acfb1e214 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -279,10 +279,16 @@ struct lxc_handler *lxc_init(const char *name, struct lxc_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*/ if (lxc_set_state(name, handler, STARTING)) { ERROR("failed to set state '%s'", lxc_state2str(STARTING)); - goto out_free; + goto out_free_name; } if (lxc_create_tty(name, conf)) { @@ -317,6 +323,9 @@ out_delete_tty: lxc_delete_tty(&conf->tty_info); out_aborting: lxc_set_state(name, handler, ABORTING); +out_free_name: + free(handler->name); + handler->name = NULL; out_free: free(handler); return NULL; @@ -333,6 +342,7 @@ void lxc_fini(const char *name, struct lxc_handler *handler) lxc_delete_console(&handler->conf->console); lxc_delete_tty(&handler->conf->tty_info); + free(handler->name); free(handler); LXC_TTY_DEL_HANDLER(SIGQUIT); diff --git a/src/lxc/start.h b/src/lxc/start.h index c07e95649..68be286d3 100644 --- a/src/lxc/start.h +++ b/src/lxc/start.h @@ -30,6 +30,7 @@ struct lxc_conf; struct lxc_handler { pid_t pid; + char *name; lxc_state_t state; int sigfd; char nsgroup[MAXPATHLEN];