[CRIU] [PATCH 3/8] compel: Prepare to hide parasite_thread_ctl

Pavel Emelyanov xemul at virtuozzo.com
Mon Nov 14 05:05:22 PST 2016


This only means introducing a compel_get_task_regs wrapper
over the get_task_regs() call that works on thread-ctl, not
thread-ctx.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 compel/arch/aarch64/src/lib/infect.c | 2 +-
 compel/arch/arm/src/lib/infect.c     | 2 +-
 compel/arch/ppc64/src/lib/infect.c   | 2 +-
 compel/arch/x86/src/lib/infect.c     | 2 +-
 compel/include/infect-priv.h         | 1 +
 compel/include/uapi/infect.h         | 2 +-
 compel/src/lib/infect.c              | 7 ++++++-
 criu/parasite-syscall.c              | 2 +-
 8 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/compel/arch/aarch64/src/lib/infect.c b/compel/arch/aarch64/src/lib/infect.c
index fceea28..95d6fc5 100644
--- a/compel/arch/aarch64/src/lib/infect.c
+++ b/compel/arch/aarch64/src/lib/infect.c
@@ -26,7 +26,7 @@ static inline void __always_unused __check_code_syscall(void)
 	BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
 }
 
-int compel_get_task_regs(pid_t pid, user_regs_struct_t regs, save_regs_t save, void *arg)
+int get_task_regs(pid_t pid, user_regs_struct_t regs, save_regs_t save, void *arg)
 {
 	struct iovec iov;
 	user_fpregs_struct_t fpsimd;
diff --git a/compel/arch/arm/src/lib/infect.c b/compel/arch/arm/src/lib/infect.c
index b440ff7..b452392 100644
--- a/compel/arch/arm/src/lib/infect.c
+++ b/compel/arch/arm/src/lib/infect.c
@@ -26,7 +26,7 @@ static inline __always_unused void __check_code_syscall(void)
 }
 
 #define PTRACE_GETVFPREGS 27
-int compel_get_task_regs(pid_t pid, user_regs_struct_t regs, save_regs_t save, void *arg)
+int get_task_regs(pid_t pid, user_regs_struct_t regs, save_regs_t save, void *arg)
 {
 	user_fpregs_struct_t vfp;
 	int ret = -1;
diff --git a/compel/arch/ppc64/src/lib/infect.c b/compel/arch/ppc64/src/lib/infect.c
index 959098b..b208f3d 100644
--- a/compel/arch/ppc64/src/lib/infect.c
+++ b/compel/arch/ppc64/src/lib/infect.c
@@ -244,7 +244,7 @@ static int __get_task_regs(pid_t pid, user_regs_struct_t *regs,
 	return 0;
 }
 
-int compel_get_task_regs(pid_t pid, user_regs_struct_t regs, save_regs_t save, void *arg)
+int get_task_regs(pid_t pid, user_regs_struct_t regs, save_regs_t save, void *arg)
 {
 	user_fpregs_struct_t fpregs;
 	int ret;
diff --git a/compel/arch/x86/src/lib/infect.c b/compel/arch/x86/src/lib/infect.c
index 12af087..455ecfb 100644
--- a/compel/arch/x86/src/lib/infect.c
+++ b/compel/arch/x86/src/lib/infect.c
@@ -51,7 +51,7 @@ static inline __always_unused void __check_code_syscall(void)
 	((user_regs_native(pregs)) ? (int64_t)((pregs)->native.name) :	\
 				(int32_t)((pregs)->compat.name))
 
-int compel_get_task_regs(pid_t pid, user_regs_struct_t regs, save_regs_t save, void *arg)
+int get_task_regs(pid_t pid, user_regs_struct_t regs, save_regs_t save, void *arg)
 {
 	user_fpregs_struct_t xsave	= {  }, *xs = NULL;
 
diff --git a/compel/include/infect-priv.h b/compel/include/infect-priv.h
index db5259c..2ba85cf 100644
--- a/compel/include/infect-priv.h
+++ b/compel/include/infect-priv.h
@@ -55,5 +55,6 @@ extern void *remote_mmap(struct parasite_ctl *ctl,
 		void *addr, size_t length, int prot,
 		int flags, int fd, off_t offset);
 extern bool arch_can_dump_task(struct parasite_ctl *ctl);
+extern int get_task_regs(pid_t pid, user_regs_struct_t regs, save_regs_t save, void *arg);
 
 #endif
diff --git a/compel/include/uapi/infect.h b/compel/include/uapi/infect.h
index d7ef921..f0520ff 100644
--- a/compel/include/uapi/infect.h
+++ b/compel/include/uapi/infect.h
@@ -146,7 +146,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_task_regs(pid_t pid, user_regs_struct_t regs, save_regs_t, void *);
+extern int compel_get_thread_regs(pid_t pid, 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 a3e0241..dd0e174 100644
--- a/compel/src/lib/infect.c
+++ b/compel/src/lib/infect.c
@@ -607,7 +607,7 @@ static int parasite_start_daemon(struct parasite_ctl *ctl)
 	 * while in daemon it is not such.
 	 */
 
-	if (compel_get_task_regs(pid, ctl->orig.regs, ictx->save_regs, ictx->regs_arg)) {
+	if (get_task_regs(pid, ctl->orig.regs, ictx->save_regs, ictx->regs_arg)) {
 		pr_err("Can't obtain regs for thread %d\n", pid);
 		return -1;
 	}
@@ -1288,6 +1288,11 @@ 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)
+{
+	return get_task_regs(pid, tctl->th.regs, save, arg);
+}
+
 struct infect_ctx *compel_infect_ctx(struct parasite_ctl *ctl)
 {
 	return &ctl->ictx;
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index 4b265f1..b83940b 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -215,7 +215,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, int id,
 		goto err_rth;
 	}
 
-	ret = compel_get_task_regs(pid, tctl->th.regs, save_task_regs, core);
+	ret = compel_get_thread_regs(pid, 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