[CRIU] [PATCH v3 05/10] files: Do setup_newborn_fds() later

Kirill Tkhai ktkhai at virtuozzo.com
Fri Dec 29 12:35:54 MSK 2017


This patch makes the call of service fds relocation after
root_prepare_shared()->prepare_fd_pid(). Next patches
will make service_fd_base depend on task's max fd used,
and for root_item we need to read all fles to know
the maximum of them.

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

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index c8c3c8622..dc4a3b3b9 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1174,9 +1174,6 @@ static int setup_newborn_fds(struct pstree_item *me)
 			return -1;
 	}
 
-	if (log_init_by_pid(vpid(me)))
-		return -1;
-
 	return 0;
 }
 
@@ -1778,9 +1775,6 @@ static int restore_task_with_children(void *_arg)
 	if (current->pid->real < 0)
 		goto err;
 
-	if (setup_newborn_fds(current))
-		goto err;
-
 	pid = getpid();
 	if (last_level_pid(current->pid) != pid) {
 		pr_err("Pid %d do not match expected %d (task %d)\n",
@@ -1789,6 +1783,9 @@ static int restore_task_with_children(void *_arg)
 		goto err;
 	}
 
+	if (log_init_by_pid(vpid(current)))
+		return -1;
+
 	if (current->parent == NULL) {
 		/*
 		 * The root task has to be in its namespaces before executing
@@ -1855,6 +1852,9 @@ static int restore_task_with_children(void *_arg)
 			goto err;
 	}
 
+	if (setup_newborn_fds(current))
+		goto err;
+
 	if ((ca->clone_flags & CLONE_NEWPID) && setup_current_pid_ns())
 		goto err;
 



More information about the CRIU mailing list