From: Daniel Lezcano Date: Fri, 9 Oct 2009 09:38:39 +0000 (+0200) Subject: Move configuration info to the structure X-Git-Tag: lxc_0_6_4~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=571e6ec89e5165083a28eb148824a233c56e14d7;p=thirdparty%2Flxc.git Move configuration info to the structure Move configuration informations from the handler structure to the configuration structure. Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/commands.c b/src/lxc/commands.c index 262e780d1..864cdb35f 100644 --- a/src/lxc/commands.c +++ b/src/lxc/commands.c @@ -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); } diff --git a/src/lxc/conf.c b/src/lxc/conf.c index b783b1b04..6e12b7fd2 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -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; } diff --git a/src/lxc/conf.h b/src/lxc/conf.h index 17a69c8b6..edb5f2ae1 100644 --- a/src/lxc/conf.h +++ b/src/lxc/conf.h @@ -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); diff --git a/src/lxc/console.c b/src/lxc/console.c index 05f06309b..bd117a5e9 100644 --- a/src/lxc/console.c +++ b/src/lxc/console.c @@ -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) diff --git a/src/lxc/start.c b/src/lxc/start.c index 8fb8e3688..4afebc113 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -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; } diff --git a/src/lxc/start.h b/src/lxc/start.h index e838754b0..805a3a47c 100644 --- a/src/lxc/start.h +++ b/src/lxc/start.h @@ -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);