[CRIU] [PATCH 1/2] restore: TASK_HELPERs live through restore stage
Tycho Andersen
tycho.andersen at canonical.com
Fri Sep 5 12:38:04 PDT 2014
In order to use TASK_HELPERS to open files from dead processes, they should
persist through the end of the restore phase, since that is when the fds are
set up.
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
cr-restore.c | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index cefa78e..5f481b0 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -92,6 +92,7 @@ static int prepare_restorer_blob(void);
static int prepare_rlimits(int pid, CoreEntry *core);
static int prepare_posix_timers(int pid, CoreEntry *core);
static int prepare_signals(int pid, CoreEntry *core);
+static int restore_switch_stage(int next_stage);
static int root_as_sibling;
@@ -765,35 +766,42 @@ err:
static int restore_one_alive_task(int pid, CoreEntry *core)
{
+ int ret = -1;
+
pr_info("Restoring resources\n");
rst_mem_switch_to_private();
- if (pstree_wait_helpers())
- return -1;
-
if (prepare_fds(current))
- return -1;
+ goto err;
if (prepare_file_locks(pid))
- return -1;
+ goto err;
if (open_vmas(pid))
- return -1;
+ goto err;
if (open_cores(pid, core))
- return -1;
+ goto err;
if (prepare_signals(pid, core))
- return -1;
+ goto err;
if (prepare_posix_timers(pid, core))
- return -1;
+ goto err;
if (prepare_rlimits(pid, core) < 0)
- return -1;
+ goto err;
+
+ if (sigreturn_restore(pid, core))
+ goto err;
- return sigreturn_restore(pid, core);
+ ret = 0;
+err:
+ if (pstree_wait_helpers())
+ ret = -1;
+
+ return ret;
}
static void zombie_prepare_signals(void)
@@ -930,9 +938,9 @@ 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)
- ret = 0;
- else {
+ else if (current->state == TASK_HELPER) {
+ ret = restore_finish_stage(CR_STATE_RESTORE);
+ } else {
pr_err("Unknown state in code %d\n", (int)core->tc->task_state);
ret = -1;
}
@@ -1489,6 +1497,7 @@ static inline int stage_participants(int next_stage)
case CR_STATE_FORKING:
return task_entries->nr_tasks + task_entries->nr_helpers;
case CR_STATE_RESTORE:
+ return task_entries->nr_threads + task_entries->nr_helpers;
case CR_STATE_RESTORE_SIGCHLD:
return task_entries->nr_threads;
case CR_STATE_RESTORE_CREDS:
--
1.9.1
More information about the CRIU
mailing list