]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Store the container name in the handler
authorDaniel Lezcano <daniel.lezcan@free.fr>
Thu, 8 Apr 2010 07:44:23 +0000 (09:44 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Thu, 8 Apr 2010 07:44:23 +0000 (09:44 +0200)
Store the container in the handler, so it is accessible
everywhere.

Signed-off-by: Daniel Lezcano <dlezcan@fr.ibm.com>
src/lxc/start.c
src/lxc/start.h

index ec084493b946922ae1f394a557a0f25916f59ad7..acfb1e214d34045232a69f2a1bff598a7662f113 100644 (file)
@@ -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);
index c07e956490fcc550aa0f31d15a078450a8ac3e32..68be286d347b65d1e570abc2fdecdfc460b032b9 100644 (file)
@@ -30,6 +30,7 @@ struct lxc_conf;
 
 struct lxc_handler {
        pid_t pid;
+       char *name;
        lxc_state_t state;
        int sigfd;
        char nsgroup[MAXPATHLEN];