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

Index: lxc/doc/lxc-execute.sgml.in
===================================================================
--- lxc.orig/doc/lxc-execute.sgml.in
+++ lxc/doc/lxc-execute.sgml.in
@@ -49,7 +49,8 @@ Foundation, Inc., 59 Temple Place, Suite
   <refsynopsisdiv>
     <cmdsynopsis>
       <command>lxc-execute <replaceable>-n name</replaceable>
-	<optional>-f config_file</optional>
+	<optional>-f config_file</optional> <optional>-s KEY=VAL
+	</optional>
 	<replaceable>command</replaceable>
       </command>
     </cmdsynopsis>
@@ -90,6 +91,18 @@ Foundation, Inc., 59 Temple Place, Suite
 	  </para>
 	</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>
 
Index: lxc/src/lxc/lxc_execute.c
===================================================================
--- lxc.orig/src/lxc/lxc_execute.c
+++ lxc/src/lxc/lxc_execute.c
@@ -41,6 +41,8 @@
 
 lxc_log_define(lxc_execute_ui, lxc_start);
 
+static struct lxc_list defines;
+
 static int my_checker(const struct lxc_arguments* args)
 {
 	if (!args->argc) {
@@ -55,12 +57,14 @@ static int my_parser(struct lxc_argument
 {
 	switch (c) {
 	case 'f': args->rcfile = arg; break;
+	case 's': return lxc_config_define_add(&defines, arg);
 	}
 	return 0;
 }
 
 static const struct option my_longopts[] = {
 	{"rcfile", required_argument, 0, 'f'},
+	{"define", required_argument, 0, 's'},
 	LXC_COMMON_OPTIONS
 };
 
@@ -73,8 +77,9 @@ lxc-execute creates a container with the
 and execs COMMAND into this container.\n\
 \n\
 Options :\n\
-  -n, --name=NAME   NAME for name of the container\n\
-  -f, --rcfile=FILE Load configuration file FILE\n",
+  -n, --name=NAME      NAME for name of the container\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  = my_checker,
@@ -86,6 +91,8 @@ int main(int argc, char *argv[])
 	char *rcfile;
 	struct lxc_conf *conf;
 
+	lxc_list_init(&defines);
+
 	if (lxc_arguments_parse(&my_args, argc, argv))
 		return -1;
 
@@ -124,6 +131,9 @@ int main(int argc, char *argv[])
 		return -1;
 	}
 
+	if (lxc_config_define_load(&defines, conf))
+		return -1;
+
 	return lxc_start(my_args.name, args, conf);
 }
 



