[CRIU] [PATCH v5 27/42] pid: Save created pid_ns fd to fdstore

Kirill Tkhai ktkhai at virtuozzo.com
Fri May 5 09:17:17 PDT 2017


Save pid_ns of just created pid_ns to fdstore. This will
allow other tasks to get it to create children.

v5: Use store_self_ns() helper. Move code to separate function.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/cr-restore.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 1ff029368..f145e2a6a 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1461,6 +1461,23 @@ static int mount_proc(void)
 	return ret;
 }
 
+static int setup_current_pid_ns(void)
+{
+	struct ns_id *ns;
+
+	ns = lookup_ns_by_id(current->ids->pid_ns_id, &pid_ns_desc);
+	if (!ns) {
+		pr_err("Can't find pid_ns\n");
+		return -1;
+	}
+	ns->pid.nsfd_id = store_self_ns(ns);
+	if (ns->pid.nsfd_id < 0) {
+		pr_err("Can't add fd to fdstore\n");
+		return -1;
+	}
+	return 0;
+}
+
 /*
  * Tasks cannot change sid (session id) arbitrary, but can either
  * inherit one from ancestor, or create a new one with id equal to
@@ -1594,6 +1611,9 @@ static int restore_task_with_children(void *_arg)
 			goto err;
 	}
 
+	if ((ca->clone_flags & CLONE_NEWPID) && setup_current_pid_ns())
+		goto err;
+
 	if (restore_task_mnt_ns(current))
 		goto err;
 



More information about the CRIU mailing list