]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Move configuration info to the structure
authorDaniel Lezcano <dlezcano@fr.ibm.com>
Fri, 9 Oct 2009 09:38:39 +0000 (11:38 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Fri, 9 Oct 2009 09:38:39 +0000 (11:38 +0200)
Move configuration informations from the handler structure to
the configuration structure.

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

index 262e780d1867659c5857db3a668a026edc11e001..864cdb35f83dedebf585150bd5deafec04d6bb04 100644 (file)
@@ -132,7 +132,7 @@ static int trigger_command(int fd, struct lxc_request *request,
 static void command_fd_cleanup(int fd, struct lxc_handler *handler,
                               struct lxc_epoll_descr *descr)
 {
-       lxc_console_remove_fd(fd, &handler->tty_info);
+       lxc_console_remove_fd(fd, &handler->conf.tty_info);
        lxc_mainloop_del_handler(descr, fd);
        close(fd);
 }
index b783b1b040962e6e4831dd196fb6c6b1e379fe09..6e12b7fd2ea1e7e51634be770b3d2074348fe10e 100644 (file)
@@ -1242,6 +1242,7 @@ int lxc_conf_init(struct lxc_conf *conf)
        conf->utsname = NULL;
        conf->tty = 0;
        conf->pts = 0;
+       conf->console[0] = '\0';
        lxc_list_init(&conf->cgroup);
        lxc_list_init(&conf->networks);
        return 0;
@@ -1619,44 +1620,44 @@ void lxc_delete_tty(struct lxc_tty_info *tty_info)
        tty_info->nbtty = 0;
 }
 
-int lxc_setup(const char *name, struct lxc_handler *handler)
+int lxc_setup(const char *name, struct lxc_conf *lxc_conf)
 {
-       if (setup_utsname(handler->lxc_conf.utsname)) {
+       if (setup_utsname(lxc_conf->utsname)) {
                ERROR("failed to setup the utsname for '%s'", name);
                return -1;
        }
 
-       if (!lxc_list_empty(&handler->lxc_conf.networks) && setup_network(name)) {
+       if (!lxc_list_empty(&lxc_conf->networks) && setup_network(name)) {
                ERROR("failed to setup the network for '%s'", name);
                return -1;
        }
 
-       if (setup_cgroup(name, &handler->lxc_conf.cgroup)) {
+       if (setup_cgroup(name, &lxc_conf->cgroup)) {
                ERROR("failed to setup the cgroups for '%s'", name);
                return -1;
        }
 
-       if (setup_mount(handler->lxc_conf.fstab)) {
+       if (setup_mount(lxc_conf->fstab)) {
                ERROR("failed to setup the mounts for '%s'", name);
                return -1;
        }
 
-       if (setup_console(handler->lxc_conf.rootfs, handler->tty)) {
+       if (setup_console(lxc_conf->rootfs, lxc_conf->console)) {
                ERROR("failed to setup the console for '%s'", name);
                return -1;
        }
 
-       if (setup_tty(handler->lxc_conf.rootfs, &handler->tty_info)) {
+       if (setup_tty(lxc_conf->rootfs, &lxc_conf->tty_info)) {
                ERROR("failed to setup the ttys for '%s'", name);
                return -1;
        }
 
-       if (setup_rootfs(handler->lxc_conf.rootfs)) {
+       if (setup_rootfs(lxc_conf->rootfs)) {
                ERROR("failed to set rootfs for '%s'", name);
                return -1;
        }
 
-       if (setup_pts(handler->lxc_conf.pts)) {
+       if (setup_pts(lxc_conf->pts)) {
                ERROR("failed to setup the new pts instance");
                return -1;
        }
index 17a69c8b6874a5f435e4fbf074d12adce57c3f70..edb5f2ae1e67d1c40b2e71a91721b22905e2b442 100644 (file)
@@ -109,24 +109,6 @@ struct lxc_cgroup {
        char *value;
 };
 
-/*
- * Defines the global container configuration
- * @rootfs  : the root directory to run the container
- * @mount   : the list of mount points
- * @network : the network configuration
- * @utsname : the container utsname
- */
-struct lxc_conf {
-       const char *rcfile;
-       char *rootfs;
-       char *fstab;
-       int tty;
-       int pts;
-       struct utsname *utsname;
-       struct lxc_list cgroup;
-       struct lxc_list networks;
-};
-
 /*
  * Defines a structure containing a pty information for
  * virtualizing a tty
@@ -151,6 +133,26 @@ struct lxc_tty_info {
        struct lxc_pty_info *pty_info;
 };
 
+/*
+ * Defines the global container configuration
+ * @rootfs  : the root directory to run the container
+ * @mount   : the list of mount points
+ * @network : the network configuration
+ * @utsname : the container utsname
+ */
+struct lxc_conf {
+       const char *rcfile;
+       char *rootfs;
+       char *fstab;
+       int tty;
+       int pts;
+       struct utsname *utsname;
+       struct lxc_list cgroup;
+       struct lxc_list networks;
+       struct lxc_tty_info tty_info;
+       char console[MAXPATHLEN];
+};
+
 /*
  * Initialize the lxc configuration structure
  */
@@ -179,7 +181,7 @@ extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
 
 struct lxc_handler;
 
-extern int lxc_setup(const char *name, struct lxc_handler *handler);
+extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf);
 
 extern int conf_has(const char *name, const char *info);
 
index 05f06309b10d07d04f403f1b9dd6ff3161a03a67..bd117a5e976e242293a8feb38e48a5126503e039 100644 (file)
@@ -95,7 +95,7 @@ extern int lxc_console_callback(int fd, struct lxc_request *request,
                        struct lxc_handler *handler)
 {
        int ttynum = request->data;
-       struct lxc_tty_info *tty_info = &handler->tty_info;
+       struct lxc_tty_info *tty_info = &handler->conf.tty_info;
 
        if (ttynum > 0) {
                if (ttynum > tty_info->nbtty)
index 8fb8e368875e015c8b0d322a62f75da61e49e428..4afebc11356244f35a448d7fc6f6f50c405cecf2 100644 (file)
@@ -256,7 +256,7 @@ struct lxc_handler *lxc_init(const char *name)
                goto out_put_lock;
        }
 
-       if (lxc_conf_init(&handler->lxc_conf)) {
+       if (lxc_conf_init(&handler->conf)) {
                ERROR("failed to initialize the configuration");
                goto out_aborting;
        }
@@ -265,18 +265,18 @@ struct lxc_handler *lxc_init(const char *name)
 
        if (!access(path, F_OK)) {
 
-               if (lxc_config_read(path, &handler->lxc_conf)) {
+               if (lxc_config_read(path, &handler->conf)) {
                        ERROR("failed to read the configuration file");
                        goto out_aborting;
                }
        }
 
-       if (console_init(handler->tty, sizeof(handler->tty))) {
+       if (console_init(handler->conf.console, sizeof(handler->conf.console))) {
                ERROR("failed to initialize the console");
                goto out_aborting;
        }
 
-       if (lxc_create_tty(name, &handler->tty_info)) {
+       if (lxc_create_tty(name, &handler->conf.tty_info)) {
                ERROR("failed to create the ttys");
                goto out_aborting;
        }
@@ -301,7 +301,7 @@ out:
        return handler;
 
 out_delete_tty:
-       lxc_delete_tty(&handler->tty_info);
+       lxc_delete_tty(&handler->conf.tty_info);
 out_aborting:
        set_state(name, handler, ABORTING);
 out_put_lock:
@@ -323,7 +323,7 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
 
        if (handler) {
                remove_init_pid(name, handler->pid);
-               lxc_delete_tty(&handler->tty_info);
+               lxc_delete_tty(&handler->conf.tty_info);
                lxc_put_lock(handler->lock);
                free(handler);
        }
@@ -377,7 +377,7 @@ static int do_start(void *arg)
        }
 
        /* Setup the container, ip, names, utsname, ... */
-       if (lxc_setup(name, handler)) {
+       if (lxc_setup(name, &handler->conf)) {
                ERROR("failed to setup the container");
                goto out_warn_father;
        }
index e838754b06a032f6ffb70205f933c92b953cb4bd..805a3a47c616f0a3755a69ac70940ae5b0b4e6c0 100644 (file)
@@ -28,11 +28,9 @@ struct lxc_handler {
 
        int sigfd;
        int lock;
-       char tty[MAXPATHLEN];
        char nsgroup[MAXPATHLEN];
        sigset_t oldmask;
-       struct lxc_tty_info tty_info;
-       struct lxc_conf lxc_conf;
+       struct lxc_conf conf;
 };
 
 extern struct lxc_handler *lxc_init(const char *name);