[CRIU] [PATCH 2/4] restore: fill up thread_args a bit earlier
Andrey Vagin
avagin at openvz.org
Fri Dec 21 09:33:53 EST 2012
It's preparation for the next patch.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
cr-restore.c | 109 ++++++++++++++++++++++++++++++-----------------------------
1 file changed, 55 insertions(+), 54 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index bf69881..3f1f5d9 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1868,54 +1868,12 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
strncpy(task_args->comm, core->tc->comm, sizeof(task_args->comm));
- task_args->t.clear_tid_addr = core->thread_info->clear_tid_addr;
- task_args->ids = *core->ids;
- task_args->t.gpregs = *core->thread_info->gpregs;
- task_args->t.blk_sigset = core->tc->blk_sigset;
- task_args->t.has_blk_sigset = true;
-
- if (core->thread_core) {
- task_args->t.has_futex = true;
- task_args->t.futex_rla = core->thread_core->futex_rla;
- task_args->t.futex_rla_len = core->thread_core->futex_rla_len;
-
- ret = prep_sched_info(&task_args->t.sp, core->thread_core);
- if (ret)
- goto err;
- }
-
- if (sigreturn_prep_xsave_frame(&task_args->t, core))
- goto err;
-
- /* No longer need it */
- core_entry__free_unpacked(core, NULL);
-
- ret = prepare_itimers(pid, task_args);
- if (ret < 0)
- goto err;
-
- ret = prepare_creds(pid, task_args);
- if (ret < 0)
- goto err;
-
- ret = prepare_mm(pid, task_args);
- if (ret < 0)
- goto err;
-
- mutex_init(&task_args->rst_lock);
-
- /*
- * Now prepare run-time data for threads restore.
- */
- task_args->nr_threads = current->nr_threads;
- task_args->clone_restore_fn = (void *)restore_thread_exec_start;
- task_args->thread_args = thread_args;
-
/*
* Fill up per-thread data.
*/
for (i = 0; i < current->nr_threads; i++) {
int fd_core;
+ CoreEntry *tcore;
thread_args[i].pid = current->threads[i].virt;
/* skip self */
@@ -1929,10 +1887,10 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
goto err;
}
- ret = pb_read_one(fd_core, &core, PB_CORE);
+ ret = pb_read_one(fd_core, &tcore, PB_CORE);
close(fd_core);
- if (core->tc || core->ids) {
+ if (tcore->tc || tcore->ids) {
pr_err("Thread has optional fields present %d\n",
thread_args[i].pid);
ret = -1;
@@ -1945,17 +1903,17 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
}
thread_args[i].ta = task_args;
- thread_args[i].gpregs = *core->thread_info->gpregs;
- thread_args[i].clear_tid_addr = core->thread_info->clear_tid_addr;
+ thread_args[i].gpregs = *tcore->thread_info->gpregs;
+ thread_args[i].clear_tid_addr = tcore->thread_info->clear_tid_addr;
- if (core->thread_core) {
+ if (tcore->thread_core) {
thread_args[i].has_futex = true;
- thread_args[i].futex_rla = core->thread_core->futex_rla;
- thread_args[i].futex_rla_len = core->thread_core->futex_rla_len;
- thread_args[i].has_blk_sigset = core->thread_core->has_blk_sigset;
- thread_args[i].blk_sigset = core->thread_core->blk_sigset;
+ thread_args[i].futex_rla = tcore->thread_core->futex_rla;
+ thread_args[i].futex_rla_len = tcore->thread_core->futex_rla_len;
+ thread_args[i].has_blk_sigset = tcore->thread_core->has_blk_sigset;
+ thread_args[i].blk_sigset = tcore->thread_core->blk_sigset;
- ret = prep_sched_info(&thread_args[i].sp, core->thread_core);
+ ret = prep_sched_info(&thread_args[i].sp, tcore->thread_core);
if (ret)
goto err;
}
@@ -1963,7 +1921,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
if (sigreturn_prep_xsave_frame(&thread_args[i], core))
goto err;
- core_entry__free_unpacked(core, NULL);
+ core_entry__free_unpacked(tcore, NULL);
pr_info("Thread %4d stack %8p heap %8p rt_sigframe %8p\n",
i, thread_args[i].mem_zone.stack,
@@ -1972,6 +1930,49 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
}
+ task_args->t.clear_tid_addr = core->thread_info->clear_tid_addr;
+ task_args->ids = *core->ids;
+ task_args->t.gpregs = *core->thread_info->gpregs;
+ task_args->t.blk_sigset = core->tc->blk_sigset;
+ task_args->t.has_blk_sigset = true;
+
+ if (core->thread_core) {
+ task_args->t.has_futex = true;
+ task_args->t.futex_rla = core->thread_core->futex_rla;
+ task_args->t.futex_rla_len = core->thread_core->futex_rla_len;
+
+ ret = prep_sched_info(&task_args->t.sp, core->thread_core);
+ if (ret)
+ goto err;
+ }
+
+ if (sigreturn_prep_xsave_frame(&task_args->t, core))
+ goto err;
+
+ /* No longer need it */
+ core_entry__free_unpacked(core, NULL);
+
+ ret = prepare_itimers(pid, task_args);
+ if (ret < 0)
+ goto err;
+
+ ret = prepare_creds(pid, task_args);
+ if (ret < 0)
+ goto err;
+
+ ret = prepare_mm(pid, task_args);
+ if (ret < 0)
+ goto err;
+
+ mutex_init(&task_args->rst_lock);
+
+ /*
+ * Now prepare run-time data for threads restore.
+ */
+ task_args->nr_threads = current->nr_threads;
+ task_args->clone_restore_fn = (void *)restore_thread_exec_start;
+ task_args->thread_args = thread_args;
+
close_image_dir();
pr_info("task_args: %p\n"
--
1.7.11.7
More information about the CRIU
mailing list