[lxc-devel] [PATCH 3/3] Let lxc-start read container name from rcfile if not specified on command line

Michel Normand michel_mno at laposte.net
Sat Jan 9 07:00:48 UTC 2010


Michael Holzt a e'crit :
> Let lxc-start read container name from rcfile if not specified on command
> line.
> 
> Signed-off-by: Michael Holzt <lxc at my.fqdn.org>
> ---
>  src/lxc/lxc_start.c |   20 +++++++++++++++++++-
>  1 files changed, 19 insertions(+), 1 deletions(-)
> 
> diff --git a/src/lxc/lxc_start.c b/src/lxc/lxc_start.c
> index fdd3b15..4b19a6a 100644
> --- a/src/lxc/lxc_start.c
> +++ b/src/lxc/lxc_start.c
> @@ -50,6 +50,16 @@
>  
>  lxc_log_define(lxc_start, lxc);
>  
> +static int my_checker(const struct lxc_arguments* args)
> +{
> +	if (!args->name && !args->rcfile) {
> +		lxc_error(args, "neither container name nor configuration file specified");
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
>  static int my_parser(struct lxc_arguments* args, int c, char* arg)
>  {
>  	switch (c) {
> @@ -78,7 +88,7 @@ Options :\n\
>    -f, --rcfile=FILE    Load configuration file FILE\n",
>  	.options   = my_longopts,
>  	.parser    = my_parser,
> -	.checker   = NULL,
> +	.checker   = my_checker,
>  	.daemonize = 0,
>  };
>  
> @@ -174,6 +184,14 @@ int main(int argc, char *argv[])
>  		return err;
>  	}
>  
> +	if (!my_args.name) {
> +		if (!conf->name) {
> +			ERROR("container name not defined in configuration file and not set on cmdline");
> +			return err;
> +		}
> +		my_args.name = conf->name;
> +	}
> +
After this line the code may continue to run with
a conf->name and my_args.name that are potentially different.
(if name specified in two places by caller: as parameter and in rcfile)

Does is mean the purpose of these three patches, is only
to have the -n/--name parameter to not be mandatory for
the lxc-start command ? and be able to place it in the rcfile ?

For me I do not think this is a good thing to introduce in
the rcfile of the container a name that is only here
to manage the container in the host.
For me the name is something that is outside the container itself.

---
Michel

>  	if (!rcfile && !strcmp("/sbin/init", args[0])) {
>  		ERROR("no configuration file for '/sbin/init' (may crash the host)");
>  		return err;






More information about the lxc-devel mailing list