Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
---
 doc/lxc-start.sgml.in |   16 +++++++++++++++-
 src/lxc/lxc_start.c   |   12 +++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

Index: lxc/doc/lxc-start.sgml.in
===================================================================
--- lxc.orig/doc/lxc-start.sgml.in
+++ lxc/doc/lxc-start.sgml.in
@@ -49,7 +49,8 @@ Foundation, Inc., 59 Temple Place, Suite
   <refsynopsisdiv>
     <cmdsynopsis><command>lxc-start <replaceable>-n
     name</replaceable> <optional>-f
-    config_file</optional> <optional>command</optional></command></cmdsynopsis>
+    config_file</optional> <optional>-s KEY=VAL</optional>
+    <optional>command</optional></command></cmdsynopsis>
   </refsynopsisdiv>
 
   <refsect1>
@@ -105,6 +106,19 @@ Foundation, Inc., 59 Temple Place, Suite
 	</listitem>
       </varlistentry>
 
+      <varlistentry>
+	<term>
+	  <option>-s <replaceable>KEY=VAL</replaceable></option>
+	</term>
+	<listitem>
+	  <para>
+	    Assign value <replaceable>VAL</replaceable> to configuration
+	    variable <replaceable>KEY</replaceable>. This overrides any
+	    assignment done in <replaceable>config_file</replaceable>.
+	  </para>
+	</listitem>
+      </varlistentry>
+
     </variablelist>
 
   </refsect1>
Index: lxc/src/lxc/lxc_start.c
===================================================================
--- lxc.orig/src/lxc/lxc_start.c
+++ lxc/src/lxc/lxc_start.c
@@ -50,11 +50,14 @@
 
 lxc_log_define(lxc_start_ui, lxc_start);
 
+static struct lxc_list defines;
+
 static int my_parser(struct lxc_arguments* args, int c, char* arg)
 {
 	switch (c) {
 	case 'd': args->daemonize = 1; break;
 	case 'f': args->rcfile = arg; break;
+	case 's': return lxc_config_define_add(&defines, arg);
 	}
 	return 0;
 }
@@ -62,6 +65,7 @@ static int my_parser(struct lxc_argument
 static const struct option my_longopts[] = {
 	{"daemon", no_argument, 0, 'd'},
 	{"rcfile", required_argument, 0, 'f'},
+	{"define", required_argument, 0, 's'},
 	LXC_COMMON_OPTIONS
 };
 
@@ -75,7 +79,8 @@ lxc-start start COMMAND in specified con
 Options :\n\
   -n, --name=NAME      NAME for name of the container\n\
   -d, --daemon         daemonize the container\n\
-  -f, --rcfile=FILE    Load configuration file FILE\n",
+  -f, --rcfile=FILE    Load configuration file FILE\n\
+  -s, --define KEY=VAL Assign VAL to configuration variable KEY\n",
 	.options   = my_longopts,
 	.parser    = my_parser,
 	.checker   = NULL,
@@ -135,6 +140,8 @@ int main(int argc, char *argv[])
 	char *rcfile = NULL;
 	struct lxc_conf *conf;
 
+	lxc_list_init(&defines);
+
 	if (lxc_arguments_parse(&my_args, argc, argv))
 		return err;
 
@@ -174,6 +181,9 @@ int main(int argc, char *argv[])
 		return err;
 	}
 
+	if (lxc_config_define_load(&defines, conf))
+		return err;
+
 	if (!rcfile && !strcmp("/sbin/init", args[0])) {
 		ERROR("no configuration file for '/sbin/init' (may crash the host)");
 		return err;



