From: Cedric Le Goater Date: Thu, 14 Jan 2010 06:43:18 +0000 (+0100) Subject: add --define to execute X-Git-Tag: lxc-0.6.5~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=201172806c477ecb36bc00fad92b85e067712c38;p=thirdparty%2Flxc.git add --define to execute Signed-off-by: Cedric Le Goater Signed-off-by: Daniel Lezcano --- diff --git a/doc/lxc-execute.sgml.in b/doc/lxc-execute.sgml.in index ddd3a13e9..46d0d1a5e 100644 --- a/doc/lxc-execute.sgml.in +++ b/doc/lxc-execute.sgml.in @@ -49,7 +49,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA lxc-execute -n name - -f config_file + -f config_file -s KEY=VAL + command @@ -90,6 +91,18 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + + + + + + Assign value VAL to configuration + variable KEY. This overrides any + assignment done in config_file. + + + diff --git a/src/lxc/lxc_execute.c b/src/lxc/lxc_execute.c index 10469240b..b9020b40c 100644 --- a/src/lxc/lxc_execute.c +++ b/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_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); }