[CRIU] [PATCH] cr-restore: Mount proc only for NEWNS or NEWPID

Radostin Stoyanov rstoyanov1 at gmail.com
Wed Dec 19 02:19:54 MSK 2018


In commit a201f59 (rst: Create custom proc every time we restore a
namespace) was introduced an approach to restore a mount namespace
using custom proc mount. This approach is also used to restore the
PID namespace.

However, there could be the case that neither of those namespaces is
being used. While commit 4dd0735 (restore: Save some time mounting
proc) handles the case when there are no namespaces to be restored,
this patch changes the CRIU's behaviour to use custom proc mount only
when it is needed (i.e. to restore mount or pid namespace).

Signed-off-by: Radostin Stoyanov <rstoyanov1 at gmail.com>
---
 criu/cr-restore.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 7bbe79aa..5b80cf40 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1552,7 +1552,7 @@ static int mount_proc(void)
 	int fd, ret;
 	char proc_mountpoint[] = "crtools-proc.XXXXXX";

-	if (root_ns_mask == 0)
+	if (!(root_ns_mask & CLONE_NEWNS || root_ns_mask & CLONE_NEWPID))
 		fd = ret = open("/proc", O_DIRECTORY);
 	else {
 		if (mkdtemp(proc_mountpoint) == NULL) {
@@ -1701,9 +1701,8 @@ static int restore_task_with_children(void *_arg)
 		restore_sid();

 		/*
-		 * We need non /proc proc mount for restoring pid and mount
-		 * namespaces and do not care for the rest of the cases.
-		 * Thus -- mount proc at custom location for any new namespace
+		 * For restoring pid and mount namespaces we need to
+		 * mount proc at custom location.
 		 */
 		if (mount_proc())
 			goto err;
--
2.19.2



More information about the CRIU mailing list