[CRIU] [PATCH 24/78] infect: Move parasite_run_in_thread() into infect.c
Cyrill Gorcunov
gorcunov at openvz.org
Mon Nov 7 08:36:09 PST 2016
From: Pavel Emelyanov <xemul at virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/include/infect.h | 3 +++
criu/infect.c | 22 ++++++++++++++++++++++
criu/parasite-syscall.c | 24 +-----------------------
3 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/criu/include/infect.h b/criu/include/infect.h
index 38e22465ab34..a521fe49c0fb 100644
--- a/criu/include/infect.h
+++ b/criu/include/infect.h
@@ -53,4 +53,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 thread_ctx *octx);
#endif
diff --git a/criu/infect.c b/criu/infect.c
index 042344130de1..e5d0a3049365 100644
--- a/criu/infect.c
+++ b/criu/infect.c
@@ -793,3 +793,25 @@ 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 thread_ctx *octx)
+{
+ void *stack = ctl->r_thread_stack;
+ user_regs_struct_t regs = octx->regs;
+ int ret;
+
+ *ctl->addr_cmd = cmd;
+
+ ret = parasite_run(pid, PTRACE_CONT, ctl->parasite_ip, stack, ®s, octx);
+ if (ret == 0)
+ ret = parasite_trap(ctl, pid, ®s, octx);
+ if (ret == 0)
+ ret = (int)REG_RES(regs);
+
+ if (ret)
+ pr_err("Parasite exited with %d\n", ret);
+
+ return ret;
+}
+
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index e95f24d0b524..88879f376db4 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -166,28 +166,6 @@ err:
return ret;
}
-static int parasite_run_in_thread(pid_t pid, unsigned int cmd,
- struct parasite_ctl *ctl,
- struct thread_ctx *octx)
-{
- void *stack = ctl->r_thread_stack;
- user_regs_struct_t regs = octx->regs;
- int ret;
-
- *ctl->addr_cmd = cmd;
-
- ret = parasite_run(pid, PTRACE_CONT, ctl->parasite_ip, stack, ®s, octx);
- if (ret == 0)
- ret = parasite_trap(ctl, pid, ®s, octx);
- if (ret == 0)
- ret = (int)REG_RES(regs);
-
- if (ret)
- pr_err("Parasite exited with %d\n", ret);
-
- return ret;
-}
-
static int __parasite_send_cmd(int sockfd, struct ctl_msg *m)
{
int ret;
@@ -414,7 +392,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, int id,
tc->has_blk_sigset = true;
memcpy(&tc->blk_sigset, &octx.sigmask, sizeof(k_rtsigset_t));
- ret = parasite_run_in_thread(pid, PARASITE_CMD_DUMP_THREAD, ctl, &octx);
+ ret = compel_run_in_thread(pid, PARASITE_CMD_DUMP_THREAD, ctl, &octx);
if (ret) {
pr_err("Can't init thread in parasite %d\n", pid);
return -1;
--
2.7.4
More information about the CRIU
mailing list