[CRIU] [PATCH 5/8] compel: Relax the thread mgmt API
Pavel Emelyanov
xemul at virtuozzo.com
Mon Nov 14 05:05:49 PST 2016
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
compel/include/infect-priv.h | 2 ++
compel/include/uapi/infect.h | 6 ++----
compel/src/lib/infect.c | 13 ++++++++-----
criu/parasite-syscall.c | 4 ++--
4 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/compel/include/infect-priv.h b/compel/include/infect-priv.h
index da56f08..4eda1ac 100644
--- a/compel/include/infect-priv.h
+++ b/compel/include/infect-priv.h
@@ -42,6 +42,8 @@ struct parasite_ctl {
};
struct parasite_thread_ctl {
+ int tid;
+ struct parasite_ctl *ctl;
struct thread_ctx th;
};
diff --git a/compel/include/uapi/infect.h b/compel/include/uapi/infect.h
index 28f0c46..75fc4a7 100644
--- a/compel/include/uapi/infect.h
+++ b/compel/include/uapi/infect.h
@@ -64,9 +64,7 @@ extern void *compel_parasite_args_s(struct parasite_ctl *ctl, int args_size);
extern int compel_execute_syscall(struct parasite_ctl *ctl,
user_regs_struct_t *regs, const char *code_syscall);
-extern int compel_run_in_thread(pid_t pid, unsigned int cmd,
- struct parasite_ctl *ctl,
- struct parasite_thread_ctl *tctl);
+extern int compel_run_in_thread(struct parasite_thread_ctl *tctl, unsigned int cmd);
/*
* The PTRACE_SYSCALL will trap task twice -- on
@@ -139,7 +137,7 @@ struct parasite_blob_desc {
extern struct parasite_blob_desc *compel_parasite_blob_desc(struct parasite_ctl *);
typedef int (*save_regs_t)(void *, user_regs_struct_t *, user_fpregs_struct_t *);
-extern int compel_get_thread_regs(pid_t pid, struct parasite_thread_ctl *, save_regs_t, void *);
+extern int compel_get_thread_regs(struct parasite_thread_ctl *, save_regs_t, void *);
extern void compel_relocs_apply(void *mem, void *vbase, size_t size, compel_reloc_t *elf_relocs, size_t nr_relocs);
diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c
index dd0e174..6bb8632 100644
--- a/compel/src/lib/infect.c
+++ b/compel/src/lib/infect.c
@@ -847,6 +847,9 @@ struct parasite_thread_ctl *compel_prepare_thread(struct parasite_ctl *ctl, int
if (prepare_thread(pid, &tctl->th)) {
xfree(tctl);
tctl = NULL;
+ } else {
+ tctl->tid = pid;
+ tctl->ctl = ctl;
}
}
@@ -1074,10 +1077,10 @@ void *compel_parasite_args_s(struct parasite_ctl *ctl, int args_size)
return compel_parasite_args_p(ctl);
}
-int compel_run_in_thread(pid_t pid, unsigned int cmd,
- struct parasite_ctl *ctl,
- struct parasite_thread_ctl *tctl)
+int compel_run_in_thread(struct parasite_thread_ctl *tctl, unsigned int cmd)
{
+ int pid = tctl->tid;
+ struct parasite_ctl *ctl = tctl->ctl;
struct thread_ctx *octx = &tctl->th;
void *stack = ctl->r_thread_stack;
user_regs_struct_t regs = octx->regs;
@@ -1288,9 +1291,9 @@ k_rtsigset_t *compel_task_sigmask(struct parasite_ctl *ctl)
return thread_ctx_sigmask(&ctl->orig);
}
-int compel_get_thread_regs(pid_t pid, struct parasite_thread_ctl *tctl, save_regs_t save, void * arg)
+int compel_get_thread_regs(struct parasite_thread_ctl *tctl, save_regs_t save, void * arg)
{
- return get_task_regs(pid, tctl->th.regs, save, arg);
+ return get_task_regs(tctl->tid, tctl->th.regs, save, arg);
}
struct infect_ctx *compel_infect_ctx(struct parasite_ctl *ctl)
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index b83940b..37c0e16 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -203,7 +203,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, int id,
tc->has_blk_sigset = true;
memcpy(&tc->blk_sigset, compel_thread_sigmask(tctl), sizeof(k_rtsigset_t));
- ret = compel_run_in_thread(pid, PARASITE_CMD_DUMP_THREAD, ctl, tctl);
+ ret = compel_run_in_thread(tctl, PARASITE_CMD_DUMP_THREAD);
if (ret) {
pr_err("Can't init thread in parasite %d\n", pid);
goto err_rth;
@@ -215,7 +215,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, int id,
goto err_rth;
}
- ret = compel_get_thread_regs(pid, tctl, save_task_regs, core);
+ ret = compel_get_thread_regs(tctl, save_task_regs, core);
if (ret) {
pr_err("Can't obtain regs for thread %d\n", pid);
goto err_rth;
--
2.5.0
More information about the CRIU
mailing list