[lxc-devel] [PATCH 1/3] Add config keyword 'lxc.name' for container name

Michael Holzt lxc at my.fqdn.org
Sat Jan 9 02:35:57 UTC 2010


Add config keyword 'lxc.name' for container name

Signed-off-by: Michael Holzt <lxc at my.fqdn.org>
---
 src/lxc/conf.h    |    1 +
 src/lxc/confile.c |   18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/lxc/conf.h b/src/lxc/conf.h
index ec0badb..300b5b8 100644
--- a/src/lxc/conf.h
+++ b/src/lxc/conf.h
@@ -159,6 +159,7 @@ struct lxc_conf {
 	char *rootfs;
 	char *pivotdir;
 	char *fstab;
+	char *name;
 	int tty;
 	int pts;
 	struct utsname *utsname;
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 6e15d09..3389a46 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -47,6 +47,7 @@ static int config_mount(const char *, char *, struct lxc_conf *);
 static int config_rootfs(const char *, char *, struct lxc_conf *);
 static int config_pivotdir(const char *, char *, struct lxc_conf *);
 static int config_utsname(const char *, char *, struct lxc_conf *);
+static int config_name(const char *, char *, struct lxc_conf *);
 static int config_network_type(const char *, char *, struct lxc_conf *);
 static int config_network_flags(const char *, char *, struct lxc_conf *);
 static int config_network_link(const char *, char *, struct lxc_conf *);
@@ -75,6 +76,7 @@ static struct config config[] = {
 	{ "lxc.rootfs",               config_rootfs               },
 	{ "lxc.pivotdir",             config_pivotdir             },
 	{ "lxc.utsname",              config_utsname              },
+	{ "lxc.name",                 config_name                 },
 	{ "lxc.network.type",         config_network_type         },
 	{ "lxc.network.flags",        config_network_flags        },
 	{ "lxc.network.link",         config_network_link         },
@@ -620,6 +622,22 @@ static int config_utsname(const char *key, char *value, struct lxc_conf *lxc_con
 	return 0;
 }
 
+static int config_name(const char *key, char *value, struct lxc_conf *lxc_conf)
+{
+	if (strlen(value) >= MAXPATHLEN) {
+		ERROR("container name %s is too long", value);
+		return -1;
+	}
+
+	lxc_conf->name = strdup(value);
+	if (!lxc_conf->name) {
+		SYSERROR("failed to duplicate container name string %s", value);
+		return -1;
+	}
+
+	return 0;
+}
+
 static int parse_line(void *buffer, void *data)
 {
 	struct config *config;
-- 
1.6.5





More information about the lxc-devel mailing list