[lxc-devel] [CRIU] [PATCH] criu: Add exec-cmd option.

Andrew Vagin avagin at parallels.com
Wed Mar 19 20:29:47 UTC 2014


On Wed, Mar 19, 2014 at 07:39:24PM +0200, Deyan Doychev wrote:
> From: Deyan Doychev <deyandoichev at gmail.com>
> 
> The --exec-cmd option specifies a command that will be execve()-ed on successful
> restore. This way the command specified here will become the parent process of
> the restored process tree.
> 
> When this option is specified criu will fork to become a daemon before it starts
> restoring the processes. It also implies the -d option so waiting for the
> restored processes to finish is responsibility of the command specified here.
> 
> This option will be used when restoring LinuX Containers.
> 
> Signed-off-by: Deyan Doychev <deyandoichev at gmail.com>
> ---

...

> diff --git a/crtools.c b/crtools.c
> index 047ac53..5591225 100644
> --- a/crtools.c
> +++ b/crtools.c
> @@ -77,6 +77,23 @@ bad_ns:
>  	return -1;
>  }
>  
> +char **parse_exec_cmd(char *optarg)
> +{

I don't like this function. Can we use '--' to split criu options and an
exec command

./criu restore .... --exec-cmd -- lxc-start --attach -n CTNAME --smth-else

For me it looks better. What do you think about this?

Thanks.

> +	int i;
> +	int count = 1;
> +	char **res;
> +
> +	for (i = strlen(optarg); i >= 0; i--)
> +		if (strchr(" \t\r\n", optarg[i]))
> +			count++;
> +
> +	res = xmalloc(count * sizeof(char *));
> +	res[0] = strtok(optarg, " \t\r\n");
> +	for (i = 1; (res[i] = strtok(NULL, " \t\r\n")); i++);
> +
> +	return res;
> +}
> +
>  static int parse_cpu_cap(struct cr_options *opts, const char *optarg)
>  {
>  	bool inverse = false;


More information about the lxc-devel mailing list