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

Andrey Vagin avagin at openvz.org
Tue Mar 11 08:18:26 PDT 2014


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 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 84aaccc..6430531 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1253,10 +1253,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;
 	}
 
 	/*
@@ -1269,31 +1269,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)
-- 
1.8.5.3



More information about the CRIU mailing list