[CRIU] [PATCH v4 26/41] pid: Save created pid_ns fd to fdstore
Kirill Tkhai
ktkhai at virtuozzo.com
Thu May 4 09:09:26 PDT 2017
Save pid_ns of just created pid_ns to fdstore. This will
allow other tasks to get it to create children.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/cr-restore.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index b760ba301..8c8878463 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1494,8 +1494,9 @@ static int create_children_and_session(void)
static int restore_task_with_children(void *_arg)
{
struct cr_clone_arg *ca = _arg;
+ struct ns_id *pid_ns;
+ int ret, fd;
pid_t pid;
- int ret;
current = ca->item;
@@ -1587,6 +1588,25 @@ static int restore_task_with_children(void *_arg)
goto err;
}
+ if (ca->clone_flags & CLONE_NEWPID) {
+ pid_ns = lookup_ns_by_id(current->ids->pid_ns_id, &pid_ns_desc);
+ if (!pid_ns) {
+ pr_err("Can't find pid_ns\n");
+ return -1;
+ }
+ fd = open_proc(PROC_SELF, "ns/pid");
+ if (fd < 0) {
+ pr_err("Can't get self pid_ns\n");
+ return -1;
+ }
+ pid_ns->pid.nsfd_id = fdstore_add(fd);
+ close(fd);
+ if (pid_ns->pid.nsfd_id < 0) {
+ pr_err("Can't add fd to fdstore\n");
+ return -1;
+ }
+ }
+
if (restore_task_mnt_ns(current))
goto err;
More information about the CRIU
mailing list