[CRIU] [PATCH 32/78] infect: Move seized_native() into infect.c

Cyrill Gorcunov gorcunov at openvz.org
Mon Nov 7 08:36:17 PST 2016


From: Pavel Emelyanov <xemul at virtuozzo.com>

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/arch/x86/sys-exec-tbl.c    |  3 ++-
 criu/include/infect.h           |  3 +++
 criu/include/parasite-syscall.h |  1 -
 criu/infect.c                   | 13 +++++++++----
 criu/mem.c                      |  2 +-
 criu/parasite-syscall.c         | 25 ++++++++++---------------
 criu/vdso.c                     |  2 +-
 7 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/criu/arch/x86/sys-exec-tbl.c b/criu/arch/x86/sys-exec-tbl.c
index f52578736f29..1051af06fe46 100644
--- a/criu/arch/x86/sys-exec-tbl.c
+++ b/criu/arch/x86/sys-exec-tbl.c
@@ -1,3 +1,4 @@
+#include "infect.h"
 
 static struct syscall_exec_desc sc_exec_table_64[] = {
 #include "sys-exec-tbl-64.c"
@@ -29,7 +30,7 @@ find_syscall_table(char *name, struct syscall_exec_desc *tbl)
 #ifdef CONFIG_COMPAT
 struct syscall_exec_desc * find_syscall(char *name, struct parasite_ctl *ctl)
 {
-	if (seized_native(ctl))
+	if (compel_mode_native(ctl))
 		return find_syscall_table(name, sc_exec_table_64);
 	else
 		return find_syscall_table(name, sc_exec_table_32);
diff --git a/criu/include/infect.h b/criu/include/infect.h
index 4f7ae1c85e4c..8335127d8c11 100644
--- a/criu/include/infect.h
+++ b/criu/include/infect.h
@@ -76,4 +76,7 @@ extern int compel_stop_on_syscall(int tasks, int sys_nr,
 extern int compel_stop_pie(pid_t pid, void *addr, enum trace_flags *tf, bool no_bp);
 
 extern int compel_unmap(struct parasite_ctl *ctl, unsigned long addr);
+
+extern int compel_mode_native(struct parasite_ctl *ctl);
+
 #endif
diff --git a/criu/include/parasite-syscall.h b/criu/include/parasite-syscall.h
index 0d7d86f574fa..15b4abfd8cb3 100644
--- a/criu/include/parasite-syscall.h
+++ b/criu/include/parasite-syscall.h
@@ -90,6 +90,5 @@ extern int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
 			  unsigned long arg5, unsigned long arg6);
 
 extern bool arch_can_dump_task(struct parasite_ctl *ctl);
-extern bool seized_native(struct parasite_ctl *ctl);
 
 #endif /* __CR_PARASITE_SYSCALL_H__ */
diff --git a/criu/infect.c b/criu/infect.c
index 10c89a909b02..36c3be05f705 100644
--- a/criu/infect.c
+++ b/criu/infect.c
@@ -638,7 +638,7 @@ static int parasite_memfd_exchange(struct parasite_ctl *ctl, unsigned long size)
 	pid_t pid = ctl->rpid;
 	unsigned long sret = -ENOSYS;
 	int ret, fd, lfd;
-	bool __maybe_unused compat_task = !seized_native(ctl);
+	bool __maybe_unused compat_task = !compel_mode_native(ctl);
 
 	if (ctl->ictx.flags & INFECT_NO_MEMFD)
 		return 1;
@@ -752,7 +752,7 @@ int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned l
 	 * without using ptrace at all.
 	 */
 
-	if (seized_native(ctl))
+	if (compel_mode_native(ctl))
 		parasite_size = pie_size(parasite_native);
 #ifdef CONFIG_COMPAT
 	else
@@ -773,7 +773,7 @@ int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned l
 
 	pr_info("Putting parasite blob into %p->%p\n", ctl->local_map, ctl->remote_map);
 
-	if (seized_native(ctl))
+	if (compel_mode_native(ctl))
 		init_parasite_ctl(ctl, native);
 #ifdef CONFIG_COMPAT
 	else
@@ -964,7 +964,7 @@ int compel_cure_remote(struct parasite_ctl *ctl)
 	} else {
 		unsigned long ret;
 
-		syscall_seized(ctl, __NR(munmap, !seized_native(ctl)), &ret,
+		syscall_seized(ctl, __NR(munmap, !compel_mode_native(ctl)), &ret,
 				(unsigned long)ctl->remote_map, ctl->map_length,
 				0, 0, 0, 0);
 		if (ret) {
@@ -1206,3 +1206,8 @@ goon:
 
 	return 0;
 }
+
+int compel_mode_native(struct parasite_ctl *ctl)
+{
+	return user_regs_native(&ctl->orig.regs);
+}
diff --git a/criu/mem.c b/criu/mem.c
index a4d576ebc534..b4b21878b5e7 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -327,7 +327,7 @@ static int __parasite_dump_pages_seized(struct pstree_item *item,
 		 * use, i.e. on non-lazy non-predump.
 		 */
 		cpp_flags |= PP_CHUNK_MODE;
-	if (!seized_native(ctl))
+	if (!compel_mode_native(ctl))
 		cpp_flags |= PP_COMPAT;
 	pp = create_page_pipe(vma_area_list->priv_size,
 					    mdc->lazy ? NULL : pargs_iovs(args),
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index 4f97e626c519..36b5a59991bb 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -89,11 +89,6 @@ static inline int ptrace_set_regs(int pid, user_regs_struct_t *regs)
 }
 #endif
 
-bool seized_native(struct parasite_ctl *ctl)
-{
-	return user_regs_native(&ctl->orig.regs);
-}
-
 int parasite_send_fd(struct parasite_ctl *ctl, int fd)
 {
 	int sk;
@@ -180,7 +175,7 @@ int parasite_dump_thread_leader_seized(struct parasite_ctl *ctl, int pid, CoreEn
 	struct parasite_dump_creds *pc;
 	int ret;
 
-	if (seized_native(ctl)) {
+	if (compel_mode_native(ctl)) {
 		args = compel_parasite_args(ctl, struct parasite_dump_thread);
 		pc = args->creds;
 	} else {
@@ -200,7 +195,7 @@ int parasite_dump_thread_leader_seized(struct parasite_ctl *ctl, int pid, CoreEn
 		return -1;
 	}
 
-	if (seized_native(ctl))
+	if (compel_mode_native(ctl))
 		return dump_thread_core(pid, core, true, args);
 	else
 		return dump_thread_core(pid, core, false, args_c);
@@ -220,7 +215,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, int id,
 
 	BUG_ON(id == 0); /* Leader is dumped in dump_task_core_all */
 
-	if (seized_native(ctl)) {
+	if (compel_mode_native(ctl)) {
 		args = compel_parasite_args(ctl, struct parasite_dump_thread);
 		pc = args->creds;
 	} else {
@@ -255,7 +250,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, int id,
 		return -1;
 	}
 
-	if (seized_native(ctl)) {
+	if (compel_mode_native(ctl)) {
 		tid->virt = args->tid;
 		return dump_thread_core(pid, core, true, args);
 	} else {
@@ -281,7 +276,7 @@ int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_imgset *cr_
 	int ret, sig;
 	struct cr_img *img;
 	SaEntry se = SA_ENTRY__INIT;
-	bool native_task = seized_native(ctl);
+	bool native_task = compel_mode_native(ctl);
 
 	if (native_task)
 		args = compel_parasite_args(ctl, struct parasite_dump_sa_args);
@@ -335,7 +330,7 @@ int parasite_dump_itimers_seized(struct parasite_ctl *ctl, struct pstree_item *i
 	struct parasite_dump_itimers_args_compat *args_c = NULL;
 	int ret;
 
-	if (seized_native(ctl))
+	if (compel_mode_native(ctl))
 		args = compel_parasite_args(ctl, struct parasite_dump_itimers_args);
 	else
 		args_c = compel_parasite_args(ctl, struct parasite_dump_itimers_args_compat);
@@ -344,7 +339,7 @@ int parasite_dump_itimers_seized(struct parasite_ctl *ctl, struct pstree_item *i
 	if (ret < 0)
 		return ret;
 
-	if (seized_native(ctl))
+	if (compel_mode_native(ctl))
 		ASSIGN_ITIMER(args);
 	else
 		ASSIGN_ITIMER(args_c);
@@ -373,7 +368,7 @@ static int core_alloc_posix_timers(TaskTimersEntry *tte, int n,
 
 #define set_posix_timer_arg(args, ctl, m, val)					\
 do {										\
-	if (seized_native(ctl))							\
+	if (compel_mode_native(ctl))						\
 		ASSIGN_TYPED(							\
 		((struct parasite_dump_posix_timers_args*)args)->m, val);	\
 	else									\
@@ -383,7 +378,7 @@ do {										\
 
 #define get_posix_timer_arg(out, m)						\
 do {										\
-	if (seized_native(ctl))							\
+	if (compel_mode_native(ctl))						\
 		ASSIGN_TYPED(							\
 		out, ((struct parasite_dump_posix_timers_args*)args)->m);	\
 	else									\
@@ -423,7 +418,7 @@ int parasite_dump_posix_timers_seized(struct proc_posix_timers_stat *proc_args,
 	if (core_alloc_posix_timers(tte, proc_args->timer_n, &pte))
 		return -1;
 
-	if (seized_native(ctl))
+	if (compel_mode_native(ctl))
 		args_size = posix_timers_dump_size(proc_args->timer_n);
 	else
 		args_size = posix_timers_compat_dump_size(proc_args->timer_n);
diff --git a/criu/vdso.c b/criu/vdso.c
index 0c92e83d6088..4dd045698eb3 100644
--- a/criu/vdso.c
+++ b/criu/vdso.c
@@ -106,7 +106,7 @@ int parasite_fixup_vdso(struct parasite_ctl *ctl, pid_t pid,
 		 * XXX: For compatible tasks, vDSO pfn is different from
 		 * our native vdso_pfn. Check vma explicitly.
 		 */
-		if (!seized_native(ctl))
+		if (!compel_mode_native(ctl))
 			args->try_fill_symtable = true;
 		else
 			args->try_fill_symtable = (fd < 0) ? true : false;
-- 
2.7.4



More information about the CRIU mailing list