[lxc-devel] [patch 1/2] Add container name into lxc_conf
Andrian Nord
nightnord at gmail.com
Sat Nov 14 21:59:52 UTC 2009
This is required for resolving relative path's in include, but also may
be used for other purposes lately.
Signed-off-by: Andrian Nord <NightNord at gmail.com>
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index ab324ab..0f7b723 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -812,11 +812,18 @@ out:
return ret;
}
-int lxc_conf_init(struct lxc_conf *conf)
+int lxc_conf_init(const char *name, struct lxc_conf *conf)
{
conf->rootfs = NULL;
conf->fstab = NULL;
conf->utsname = NULL;
+
+ conf->name = strdup(name);
+ if (!conf->name) {
+ SYSERROR( "failed to allocate memory" );
+ return -1;
+ }
+
conf->tty = 0;
conf->pts = 0;
conf->console[0] = '\0';
diff --git a/src/lxc/conf.h b/src/lxc/conf.h
index 8a3ebf0..2808820 100644
--- a/src/lxc/conf.h
+++ b/src/lxc/conf.h
@@ -131,6 +131,7 @@ struct lxc_tty_info {
struct lxc_conf {
char *rootfs;
char *fstab;
+ char *name;
int tty;
int pts;
struct utsname *utsname;
@@ -144,7 +145,7 @@ struct lxc_conf {
/*
* Initialize the lxc configuration structure
*/
-extern int lxc_conf_init(struct lxc_conf *conf);
+extern int lxc_conf_init(const char *name, struct lxc_conf *conf);
extern int lxc_create_network(struct lxc_list *networks);
extern int lxc_assign_network(struct lxc_list *networks, pid_t pid);
diff --git a/src/lxc/start.c b/src/lxc/start.c
index 6537780..435b41f 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -243,7 +243,7 @@ struct lxc_handler *lxc_init(const char *name, const char *rcfile)
goto out_free;
}
- if (lxc_conf_init(&handler->conf)) {
+ if (lxc_conf_init(name, &handler->conf)) {
ERROR("failed to initialize the configuration");
goto out_aborting;
}
More information about the lxc-devel
mailing list