]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
add --define to execute
authorCedric Le Goater <clg@fr.ibm.com>
Thu, 14 Jan 2010 06:43:18 +0000 (07:43 +0100)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Thu, 14 Jan 2010 06:43:18 +0000 (07:43 +0100)
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
doc/lxc-execute.sgml.in
src/lxc/lxc_execute.c

index ddd3a13e98177f3671588df3f29f2574fd873b81..46d0d1a5e14cfba344ccffcd5ab19f59e71c981c 100644 (file)
@@ -49,7 +49,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   <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 330, Boston, MA 02111-1307 USA
          </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 10469240b2ac7b24b7db80e283624bb070cd8d1d..b9020b40cc87334ae62328eb756508bf4f1067de 100644 (file)
@@ -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_arguments* args, int c, char* arg)
 {
        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 identifier NAME\n\
 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);
 }