[CRIU] Re: [PATCH cr 1/2] crtools: add "pid" to the --namespaces cmdline option arguments (v2)

Pavel Emelyanov xemul at parallels.com
Thu Jun 21 09:49:02 EDT 2012


On 06/21/2012 02:17 PM, Andrey Vagin wrote:
> 
> to require dumping pid namespace. Dump and restore will be failed if
> a tress doesn't contain a process init.
> 
> pid namespace will be created implicitly if a process init in the tree.
> 
> v2: fix comments from Pavel
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  cr-dump.c    |    5 +----
>  cr-restore.c |    4 ++++
>  crtools.c    |    4 +++-
>  namespaces.c |    5 +++++
>  4 files changed, 13 insertions(+), 5 deletions(-)
> 

> @@ -720,8 +720,12 @@ static int restore_root_task(struct pstree_item *init, struct cr_options *opts)
>  		 * It should be restore in new pid ns.
>  		 * The first process in pid ns gets pid = 1 automaticaly. */
>  		opts->namespaces_flags |= CLONE_NEWPID;
> +	} else	if (opts->namespaces_flags & CLONE_NEWPID) {
> +		pr_err("Can't restore pid namespace without the process init\n");
> +		return -1;
>  	}

This should look like

if (flags & NEWPID)
	if (pid != 1)
		error;
else
	if (pid == 1)
		error;

or

if (pid == 1)
	if (! (flags & NEWPID))
		error;
else
	if (flags & NEWPID)
		error;

> +
>  	ret = fork_with_pid(init, opts->namespaces_flags);
>  	if (ret < 0)
>  		return -1;



More information about the CRIU mailing list