[CRIU] [PATCH 29/78] infect: Move unseize_task() into infect.c
Cyrill Gorcunov
gorcunov at openvz.org
Mon Nov 7 08:36:14 PST 2016
From: Pavel Emelyanov <xemul at virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/cr-exec.c | 2 +-
criu/include/infect.h | 1 +
criu/include/ptrace.h | 1 -
criu/infect.c | 35 +++++++++++++++++++++++++++++++++++
criu/ptrace.c | 35 -----------------------------------
criu/seize.c | 2 +-
6 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/criu/cr-exec.c b/criu/cr-exec.c
index 742e5f35be70..098bf96d7ced 100644
--- a/criu/cr-exec.c
+++ b/criu/cr-exec.c
@@ -191,7 +191,7 @@ int cr_exec(int pid, char **opt)
out_cure:
compel_cure(ctl);
out_unseize:
- unseize_task(pid, prev_state, prev_state);
+ compel_unseize_task(pid, prev_state, prev_state);
out:
return exit_code;
}
diff --git a/criu/include/infect.h b/criu/include/infect.h
index d528eabf7631..b906617e06be 100644
--- a/criu/include/infect.h
+++ b/criu/include/infect.h
@@ -16,6 +16,7 @@ struct seize_task_status {
extern int compel_wait_task(int pid, int ppid,
int (*get_status)(int pid, struct seize_task_status *),
struct seize_task_status *st);
+extern int compel_unseize_task(pid_t pid, int orig_state, int state);
/*
* FIXME -- these should be mapped to pid.h's
diff --git a/criu/include/ptrace.h b/criu/include/ptrace.h
index e96d29127c7a..b3343fdf83a5 100644
--- a/criu/include/ptrace.h
+++ b/criu/include/ptrace.h
@@ -73,7 +73,6 @@ struct ptrace_peeksiginfo_args {
#define SI_EVENT(_si_code) (((_si_code) & 0xFFFF) >> 8)
extern int suspend_seccomp(pid_t pid);
-extern int unseize_task(pid_t pid, int orig_state, int state);
extern int ptrace_peek_area(pid_t pid, void *dst, void *addr, long bytes);
extern int ptrace_poke_area(pid_t pid, void *src, void *addr, long bytes);
extern int ptrace_swap_area(pid_t pid, void *dst, void *src, long bytes);
diff --git a/criu/infect.c b/criu/infect.c
index 0237fd8a93f7..fc235136edfe 100644
--- a/criu/infect.c
+++ b/criu/infect.c
@@ -241,6 +241,41 @@ err:
return -1;
}
+int compel_unseize_task(pid_t pid, int orig_st, int st)
+{
+ pr_debug("\tUnseizing %d into %d\n", pid, st);
+
+ if (st == TASK_DEAD) {
+ kill(pid, SIGKILL);
+ return 0;
+ } else if (st == TASK_STOPPED) {
+ /*
+ * Task might have had STOP in queue. We detected such
+ * guy as TASK_STOPPED, but cleared signal to run the
+ * parasite code. hus after detach the task will become
+ * running. That said -- STOP everyone regardless of
+ * the initial state.
+ */
+ kill(pid, SIGSTOP);
+ } else if (st == TASK_ALIVE) {
+ /*
+ * Same as in the comment above -- there might be a
+ * task with STOP in queue that would get lost after
+ * detach, so stop it again.
+ */
+ if (orig_st == TASK_STOPPED)
+ kill(pid, SIGSTOP);
+ } else
+ pr_err("Unknown final state %d\n", st);
+
+ if (ptrace(PTRACE_DETACH, pid, NULL, NULL)) {
+ pr_perror("Unable to detach from %d", pid);
+ return -1;
+ }
+
+ return 0;
+}
+
static int gen_parasite_saddr(struct sockaddr_un *saddr, int key)
{
int sun_len;
diff --git a/criu/ptrace.c b/criu/ptrace.c
index f013346e32a6..15908c17ddb7 100644
--- a/criu/ptrace.c
+++ b/criu/ptrace.c
@@ -23,41 +23,6 @@
#include "seccomp.h"
#include "cr_options.h"
-int unseize_task(pid_t pid, int orig_st, int st)
-{
- pr_debug("\tUnseizing %d into %d\n", pid, st);
-
- if (st == TASK_DEAD) {
- kill(pid, SIGKILL);
- return 0;
- } else if (st == TASK_STOPPED) {
- /*
- * Task might have had STOP in queue. We detected such
- * guy as TASK_STOPPED, but cleared signal to run the
- * parasite code. hus after detach the task will become
- * running. That said -- STOP everyone regardless of
- * the initial state.
- */
- kill(pid, SIGSTOP);
- } else if (st == TASK_ALIVE) {
- /*
- * Same as in the comment above -- there might be a
- * task with STOP in queue that would get lost after
- * detach, so stop it again.
- */
- if (orig_st == TASK_STOPPED)
- kill(pid, SIGSTOP);
- } else
- pr_err("Unknown final state %d\n", st);
-
- if (ptrace(PTRACE_DETACH, pid, NULL, NULL)) {
- pr_perror("Unable to detach from %d", pid);
- return -1;
- }
-
- return 0;
-}
-
int suspend_seccomp(pid_t pid)
{
if (ptrace(PTRACE_SETOPTIONS, pid, NULL, PTRACE_O_SUSPEND_SECCOMP) < 0) {
diff --git a/criu/seize.c b/criu/seize.c
index 1b10224a05c0..c69f06346f87 100644
--- a/criu/seize.c
+++ b/criu/seize.c
@@ -538,7 +538,7 @@ static void unseize_task_and_threads(const struct pstree_item *item, int st)
* the item->state is the state task was in when we seized one.
*/
- unseize_task(item->pid.real, item->pid.state, st);
+ compel_unseize_task(item->pid.real, item->pid.state, st);
if (st == TASK_DEAD)
return;
--
2.7.4
More information about the CRIU
mailing list