[CRIU] [PATCH 10/12] mounts: create a temporary directory for restoring non-root mntns

Pavel Emelyanov xemul at parallels.com
Thu Mar 6 07:19:48 PST 2014


On 01/10/2014 05:50 PM, Andrey Vagin wrote:
> All non-root namespaces will be restored as sub-trees of the root tree.
> 
> This patch creates a temporary directory and mount tmpfs in it, then
> create directories for each non-root mount namespace.
> 
> tmpfs is quite useful here to simplify destroying this construction,
> we don't need to unmount each namespace separately.
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  cr-restore.c    | 22 ++++++++-----
>  include/mount.h |  2 ++
>  mount.c         | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 115 insertions(+), 7 deletions(-)
> 
> diff --git a/cr-restore.c b/cr-restore.c
> index 003e0f0..5825849 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -1281,10 +1281,10 @@ static int restore_task_with_children(void *_arg)
>  		 * Thus -- mount proc at custom location for any new namespace
>  		 */
>  		if (mount_proc())
> -			exit(1);
> +			goto err;
>  
>  		if (root_prepare_shared())
> -			exit(1);
> +			goto err;
>  	}
>  
>  	/*
> @@ -1297,31 +1297,39 @@ static int restore_task_with_children(void *_arg)
>  	ret = sigprocmask(SIG_BLOCK, &blockmask, NULL);
>  	if (ret) {
>  		pr_perror("%d: Can't block signals", current->pid.virt);
> -		exit(1);
> +		goto err;
>  	}
>  
>  	if (prepare_mappings(pid))
> -		exit(1);
> +		goto err;
>  
>  	if ((!(ca->clone_flags & CLONE_FILES)) &&
>  	    current->parent && current->parent->rst->fdt)
>  		close_old_servie_fd(current->parent->rst->fdt->nr);
>  
>  	if (create_children_and_session())
> -		exit(1);
> +		goto err;
>  
>  	if (unmap_guard_pages())
> -		exit(1);
> +		goto err;
>  
>  	restore_pgid();
>  
>  	if (restore_finish_stage(CR_STATE_FORKING) < 0)
> -		exit(1);
> +		goto err;
> +
> +	if (current->parent == NULL && fini_mnt_ns())
> +		exit (1);
>  
>  	if (current->state == TASK_HELPER)
>  		return 0;
>  
>  	return restore_one_task(current->pid.virt, ca->core);
> +err:
> +	if (current->parent == NULL)
> +		fini_mnt_ns();
> +
> +	exit(1);
>  }
>  
>  static inline int stage_participants(int next_stage)

Thus hunk into separate patch, please.


More information about the CRIU mailing list