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);
}
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;
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;
}
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
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
*/
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);
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)
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;
}
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;
}
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:
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);
}
}
/* 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;
}
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);