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;
}
#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
struct lxc_handler *lxc_init(const char *name)
{
struct lxc_handler *handler;
+ char path[MAXPATHLEN];
handler = malloc(sizeof(*handler));
if (!handler)
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;
}
/* 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;
}