diff options
author | Daniel Lezcano <dlezcano@fr.ibm.com> | 2009-10-09 11:38:39 +0200 |
---|---|---|
committer | Daniel Lezcano <dlezcano@fr.ibm.com> | 2009-10-09 11:38:39 +0200 |
commit | 88d5514d1665625f7a8876c09186f249a23e3e55 (patch) | |
tree | 6f27f4f9e2822d1e40284e86913623cd340fb298 | |
parent | use the configuration structure for the cgroup (diff) | |
download | lxc-88d5514d1665625f7a8876c09186f249a23e3e55.tar.gz lxc-88d5514d1665625f7a8876c09186f249a23e3e55.tar.bz2 lxc-88d5514d1665625f7a8876c09186f249a23e3e55.zip |
Move the configuration file to the start function
We want to store more information in the configuration structure,
especially the ttys.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
-rw-r--r-- | src/lxc/conf.c | 40 | ||||
-rw-r--r-- | src/lxc/conf.h | 6 | ||||
-rw-r--r-- | src/lxc/start.c | 21 | ||||
-rw-r--r-- | src/lxc/start.h | 1 |
4 files changed, 34 insertions, 34 deletions
diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 3477571..b783b1b 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -1619,66 +1619,44 @@ void lxc_delete_tty(struct lxc_tty_info *tty_info) tty_info->nbtty = 0; } -extern int lxc_config_read(const char *file, struct lxc_conf *conf); - -int lxc_setup(const char *name, const char *cons, - const struct lxc_tty_info *tty_info) - +int lxc_setup(const char *name, struct lxc_handler *handler) { - struct lxc_conf lxc_conf; - char path[MAXPATHLEN]; - - if (lxc_conf_init(&lxc_conf)) { - ERROR("failed to initialize the configuration"); - return -1; - } - - snprintf(path, sizeof(path), LXCPATH "/%s/config", name); - - if (!access(path, F_OK)) { - - if (lxc_config_read(path, &lxc_conf)) { - ERROR("failed to read the configuration file"); - return -1; - } - } - - if (setup_utsname(lxc_conf.utsname)) { + if (setup_utsname(handler->lxc_conf.utsname)) { ERROR("failed to setup the utsname for '%s'", name); return -1; } - if (!lxc_list_empty(&lxc_conf.networks) && setup_network(name)) { + if (!lxc_list_empty(&handler->lxc_conf.networks) && setup_network(name)) { ERROR("failed to setup the network for '%s'", name); return -1; } - if (setup_cgroup(name, &lxc_conf.cgroup)) { + if (setup_cgroup(name, &handler->lxc_conf.cgroup)) { ERROR("failed to setup the cgroups for '%s'", name); return -1; } - if (setup_mount(lxc_conf.fstab)) { + if (setup_mount(handler->lxc_conf.fstab)) { ERROR("failed to setup the mounts for '%s'", name); return -1; } - if (setup_console(lxc_conf.rootfs, cons)) { + if (setup_console(handler->lxc_conf.rootfs, handler->tty)) { ERROR("failed to setup the console for '%s'", name); return -1; } - if (setup_tty(lxc_conf.rootfs, tty_info)) { + if (setup_tty(handler->lxc_conf.rootfs, &handler->tty_info)) { ERROR("failed to setup the ttys for '%s'", name); return -1; } - if (setup_rootfs(lxc_conf.rootfs)) { + if (setup_rootfs(handler->lxc_conf.rootfs)) { ERROR("failed to set rootfs for '%s'", name); return -1; } - if (setup_pts(lxc_conf.pts)) { + if (setup_pts(handler->lxc_conf.pts)) { ERROR("failed to setup the new pts instance"); return -1; } diff --git a/src/lxc/conf.h b/src/lxc/conf.h index 9635ec9..17a69c8 100644 --- a/src/lxc/conf.h +++ b/src/lxc/conf.h @@ -176,8 +176,10 @@ extern void lxc_delete_tty(struct lxc_tty_info *tty_info); /* * Configure the container from inside */ -extern int lxc_setup(const char *name, const char *tty, - const struct lxc_tty_info *tty_info); + +struct lxc_handler; + +extern int lxc_setup(const char *name, struct lxc_handler *handler); extern int conf_has(const char *name, const char *info); diff --git a/src/lxc/start.c b/src/lxc/start.c index 2447b2d..8fb8e36 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -44,6 +44,9 @@ #include <sys/un.h> #include <sys/poll.h> +#include <lxc/lxc.h> +#include <lxc/confile.h> + #ifdef HAVE_SYS_SIGNALFD_H # include <sys/signalfd.h> #else @@ -235,6 +238,7 @@ static int console_init(char *console, size_t size) struct lxc_handler *lxc_init(const char *name) { struct lxc_handler *handler; + char path[MAXPATHLEN]; handler = malloc(sizeof(*handler)); if (!handler) @@ -252,6 +256,21 @@ struct lxc_handler *lxc_init(const char *name) goto out_put_lock; } + if (lxc_conf_init(&handler->lxc_conf)) { + ERROR("failed to initialize the configuration"); + goto out_aborting; + } + + snprintf(path, sizeof(path), LXCPATH "/%s/config", name); + + if (!access(path, F_OK)) { + + if (lxc_config_read(path, &handler->lxc_conf)) { + ERROR("failed to read the configuration file"); + goto out_aborting; + } + } + if (console_init(handler->tty, sizeof(handler->tty))) { ERROR("failed to initialize the console"); goto out_aborting; @@ -358,7 +377,7 @@ static int do_start(void *arg) } /* Setup the container, ip, names, utsname, ... */ - if (lxc_setup(name, handler->tty, &handler->tty_info)) { + if (lxc_setup(name, handler)) { ERROR("failed to setup the container"); goto out_warn_father; } diff --git a/src/lxc/start.h b/src/lxc/start.h index bb86f40..e838754 100644 --- a/src/lxc/start.h +++ b/src/lxc/start.h @@ -32,6 +32,7 @@ struct lxc_handler { char nsgroup[MAXPATHLEN]; sigset_t oldmask; struct lxc_tty_info tty_info; + struct lxc_conf lxc_conf; }; extern struct lxc_handler *lxc_init(const char *name); |