[CRIU] [PATCH 2/4] restore: TASK_HELPERs live until RESTORE stage

Tycho Andersen tycho.andersen at canonical.com
Fri Sep 12 11:13:00 PDT 2014


In order to use TASK_HELPERS to open files from dead processes, they should
persist until the end of the restore stage, so that the /proc files exist when
setting up the fds.

This commit is in preparation for the remap_dead_pid commits.

v2: wait() on helpers after restore stage is over

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 cr-restore.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 4d5ccd5..75d3afa 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -702,7 +702,7 @@ static int pstree_wait_helpers()
 {
 	struct pstree_item *pi;
 
-	list_for_each_entry(pi, &current->children, sibling) {
+	for_each_pstree_item(pi) {
 		int status, ret;
 
 		if (pi->state != TASK_HELPER)
@@ -770,9 +770,6 @@ static int restore_one_alive_task(int pid, CoreEntry *core)
 
 	rst_mem_switch_to_private();
 
-	if (pstree_wait_helpers())
-		return -1;
-
 	if (prepare_fds(current))
 		return -1;
 
@@ -931,9 +928,10 @@ static int restore_one_task(int pid, CoreEntry *core)
 		ret = restore_one_alive_task(pid, core);
 	else if (current->state == TASK_DEAD)
 		ret = restore_one_zombie(pid, core);
-	else if (current->state == TASK_HELPER)
+	else if (current->state == TASK_HELPER) {
+		restore_finish_stage(CR_STATE_RESTORE);
 		ret = 0;
-	else {
+	} else {
 		pr_err("Unknown state in code %d\n", (int)core->tc->task_state);
 		ret = -1;
 	}
@@ -1711,6 +1709,9 @@ static int restore_root_task(struct pstree_item *init)
 	if (ret < 0)
 		goto out_kill;
 
+	if (pstree_wait_helpers() < 0)
+		goto out_kill;
+
 	ret = run_scripts(ACT_POST_RESTORE);
 	if (ret != 0) {
 		pr_err("Aborting restore due to script ret code %d\n", ret);
-- 
1.9.1



More information about the CRIU mailing list