[CRIU] [PATCH 02/24] parasite-syscall: Add "trap" postfix to parasite execute functions

Andrey Vagin avagin at openvz.org
Wed May 22 16:08:03 EDT 2013


From: Cyrill Gorcunov <gorcunov at openvz.org>

They are relying on trap being issued at the end of execution
so to distinguish it with future daemon mode add "trap" postfix
to them.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 arch/arm/crtools.c         |  2 +-
 arch/x86/crtools.c         |  2 +-
 include/parasite-syscall.h |  4 ++--
 mem.c                      |  6 +++---
 parasite-syscall.c         | 36 ++++++++++++++++++------------------
 5 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/arch/arm/crtools.c b/arch/arm/crtools.c
index 23cb158..a64a86c 100644
--- a/arch/arm/crtools.c
+++ b/arch/arm/crtools.c
@@ -74,7 +74,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
 	regs.ARM_r5 = arg6;
 
 	parasite_setup_regs(ctl->syscall_ip, &regs);
-	err = __parasite_execute(ctl, ctl->pid.real, &regs);
+	err = __parasite_execute_trap(ctl, ctl->pid.real, &regs);
 	if (err)
 		return err;
 
diff --git a/arch/x86/crtools.c b/arch/x86/crtools.c
index eba6ad3..284f2c0 100644
--- a/arch/x86/crtools.c
+++ b/arch/x86/crtools.c
@@ -98,7 +98,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
 	regs.r9  = arg6;
 
 	parasite_setup_regs(ctl->syscall_ip, &regs);
-	err = __parasite_execute(ctl, ctl->pid.real, &regs);
+	err = __parasite_execute_trap(ctl, ctl->pid.real, &regs);
 	if (err)
 		return err;
 
diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h
index 4441592..e4a644f 100644
--- a/include/parasite-syscall.h
+++ b/include/parasite-syscall.h
@@ -35,7 +35,7 @@ extern int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_fdse
 extern int parasite_dump_itimers_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_fdset);
 
 void *parasite_args_s(struct parasite_ctl *ctl, int args_size);
-int parasite_execute(unsigned int cmd, struct parasite_ctl *ctl);
+int parasite_execute_trap(unsigned int cmd, struct parasite_ctl *ctl);
 int parasite_send_fd(struct parasite_ctl *ctl, int fd);
 
 struct parasite_dump_misc;
@@ -81,7 +81,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
 		unsigned long arg5,
 		unsigned long arg6);
 
-extern int __parasite_execute(struct parasite_ctl *ctl, pid_t pid, user_regs_struct_t *regs);
 extern bool arch_can_dump_task(pid_t pid);
+extern int __parasite_execute_trap(struct parasite_ctl *ctl, pid_t pid, user_regs_struct_t *regs);
 
 #endif /* __CR_PARASITE_SYSCALL_H__ */
diff --git a/mem.c b/mem.c
index 3ee21b1..16f5177 100644
--- a/mem.c
+++ b/mem.c
@@ -382,7 +382,7 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl,
 		pr_debug("PPB: %d pages %d segs %u pipe %d off\n",
 				args->nr_pages, args->nr_segs, ppb->pipe_size, args->off);
 
-		ret = parasite_execute(PARASITE_CMD_DUMPPAGES, ctl);
+		ret = parasite_execute_trap(PARASITE_CMD_DUMPPAGES, ctl);
 		if (ret < 0)
 			goto out_pp;
 
@@ -448,7 +448,7 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl,
 	 */
 
 	pargs->add_prot = PROT_READ;
-	ret = parasite_execute(PARASITE_CMD_MPROTECT_VMAS, ctl);
+	ret = parasite_execute_trap(PARASITE_CMD_MPROTECT_VMAS, ctl);
 	if (ret) {
 		pr_err("Can't dump unprotect vmas with parasite\n");
 		return ret;
@@ -459,7 +459,7 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl,
 		pr_err("Can't dump page with parasite\n");
 
 	pargs->add_prot = 0;
-	ret = parasite_execute(PARASITE_CMD_MPROTECT_VMAS, ctl);
+	ret = parasite_execute_trap(PARASITE_CMD_MPROTECT_VMAS, ctl);
 	if (ret) {
 		pr_err("Can't rollback unprotected vmas with parasite\n");
 		ret = -1;
diff --git a/parasite-syscall.c b/parasite-syscall.c
index c02f426..b7891fe 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -61,7 +61,7 @@ static struct vma_area *get_vma_by_ip(struct list_head *vma_area_list, unsigned
 }
 
 /* we run at @regs->ip */
-int __parasite_execute(struct parasite_ctl *ctl, pid_t pid, user_regs_struct_t *regs)
+int __parasite_execute_trap(struct parasite_ctl *ctl, pid_t pid, user_regs_struct_t *regs)
 {
 	siginfo_t siginfo;
 	int status;
@@ -195,7 +195,7 @@ void *parasite_args_s(struct parasite_ctl *ctl, int args_size)
 		ctl->addr_args;					\
 	})
 
-static int parasite_execute_by_pid(unsigned int cmd, struct parasite_ctl *ctl, pid_t pid)
+static int parasite_execute_trap_by_pid(unsigned int cmd, struct parasite_ctl *ctl, pid_t pid)
 {
 	int ret;
 	user_regs_struct_t regs_orig, regs;
@@ -214,7 +214,7 @@ static int parasite_execute_by_pid(unsigned int cmd, struct parasite_ctl *ctl, p
 
 	parasite_setup_regs(ctl->parasite_ip, &regs);
 
-	ret = __parasite_execute(ctl, pid, &regs);
+	ret = __parasite_execute_trap(ctl, pid, &regs);
 	if (ret == 0)
 		ret = (int)REG_RES(regs);
 
@@ -230,9 +230,9 @@ static int parasite_execute_by_pid(unsigned int cmd, struct parasite_ctl *ctl, p
 	return ret;
 }
 
-int parasite_execute(unsigned int cmd, struct parasite_ctl *ctl)
+int parasite_execute_trap(unsigned int cmd, struct parasite_ctl *ctl)
 {
-	return parasite_execute_by_pid(cmd, ctl, ctl->pid.real);
+	return parasite_execute_trap_by_pid(cmd, ctl, ctl->pid.real);
 }
 
 static int munmap_seized(struct parasite_ctl *ctl, void *addr, size_t length)
@@ -278,7 +278,7 @@ static int parasite_set_logfd(struct parasite_ctl *ctl, pid_t pid)
 	a = parasite_args(ctl, struct parasite_log_args);
 	a->log_level = log_get_loglevel();
 
-	ret = parasite_execute(PARASITE_CMD_CFG_LOG, ctl);
+	ret = parasite_execute_trap(PARASITE_CMD_CFG_LOG, ctl);
 	if (ret < 0)
 		return ret;
 
@@ -337,7 +337,7 @@ static int parasite_init(struct parasite_ctl *ctl, pid_t pid, int nr_threads)
 		}
 	}
 
-	if (parasite_execute(PARASITE_CMD_INIT, ctl) < 0) {
+	if (parasite_execute_trap(PARASITE_CMD_INIT, ctl) < 0) {
 		pr_err("Can't init parasite\n");
 		goto err;
 	}
@@ -362,7 +362,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, struct pid *tid,
 
 	args = parasite_args(ctl, struct parasite_dump_thread);
 
-	ret = parasite_execute_by_pid(PARASITE_CMD_DUMP_THREAD, ctl, tid->real);
+	ret = parasite_execute_trap_by_pid(PARASITE_CMD_DUMP_THREAD, ctl, tid->real);
 
 	memcpy(&core->thread_core->blk_sigset, &args->blocked, sizeof(args->blocked));
 	CORE_THREAD_ARCH_INFO(core)->clear_tid_addr = encode_pointer(args->tid_addr);
@@ -380,7 +380,7 @@ int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_f
 
 	args = parasite_args(ctl, struct parasite_dump_sa_args);
 
-	ret = parasite_execute(PARASITE_CMD_DUMP_SIGACTS, ctl);
+	ret = parasite_execute_trap(PARASITE_CMD_DUMP_SIGACTS, ctl);
 	if (ret < 0)
 		return ret;
 
@@ -423,7 +423,7 @@ int parasite_dump_itimers_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_f
 
 	args = parasite_args(ctl, struct parasite_dump_itimers_args);
 
-	ret = parasite_execute(PARASITE_CMD_DUMP_ITIMERS, ctl);
+	ret = parasite_execute_trap(PARASITE_CMD_DUMP_ITIMERS, ctl);
 	if (ret < 0)
 		return ret;
 
@@ -443,7 +443,7 @@ int parasite_dump_misc_seized(struct parasite_ctl *ctl, struct parasite_dump_mis
 	struct parasite_dump_misc *ma;
 
 	ma = parasite_args(ctl, struct parasite_dump_misc);
-	if (parasite_execute(PARASITE_CMD_DUMP_MISC, ctl) < 0)
+	if (parasite_execute_trap(PARASITE_CMD_DUMP_MISC, ctl) < 0)
 		return -1;
 
 	*misc = *ma;
@@ -457,7 +457,7 @@ struct parasite_tty_args *parasite_dump_tty(struct parasite_ctl *ctl, int fd)
 	p = parasite_args(ctl, struct parasite_tty_args);
 	p->fd = fd;
 
-	if (parasite_execute(PARASITE_CMD_DUMP_TTY, ctl) < 0)
+	if (parasite_execute_trap(PARASITE_CMD_DUMP_TTY, ctl) < 0)
 		return NULL;
 
 	return p;
@@ -468,7 +468,7 @@ int parasite_dump_creds(struct parasite_ctl *ctl, CredsEntry *ce)
 	struct parasite_dump_creds *pc;
 
 	pc = parasite_args(ctl, struct parasite_dump_creds);
-	if (parasite_execute(PARASITE_CMD_DUMP_CREDS, ctl) < 0)
+	if (parasite_execute_trap(PARASITE_CMD_DUMP_CREDS, ctl) < 0)
 		return -1;
 
 	ce->secbits = pc->secbits;
@@ -495,7 +495,7 @@ int parasite_drain_fds_seized(struct parasite_ctl *ctl,
 	args = parasite_args_s(ctl, size);
 	memcpy(args, dfds, size);
 
-	ret = parasite_execute(PARASITE_CMD_DRAIN_FDS, ctl);
+	ret = parasite_execute_trap(PARASITE_CMD_DRAIN_FDS, ctl);
 	if (ret) {
 		pr_err("Parasite failed to drain descriptors\n");
 		goto err;
@@ -515,7 +515,7 @@ int parasite_get_proc_fd_seized(struct parasite_ctl *ctl)
 {
 	int ret = -1, fd;
 
-	ret = parasite_execute(PARASITE_CMD_GET_PROC_FD, ctl);
+	ret = parasite_execute_trap(PARASITE_CMD_GET_PROC_FD, ctl);
 	if (ret) {
 		pr_err("Parasite failed to get proc fd\n");
 		return ret;
@@ -538,7 +538,7 @@ int parasite_init_threads_seized(struct parasite_ctl *ctl, struct pstree_item *i
 		if (item->pid.real == item->threads[i].real)
 			continue;
 
-		ret = parasite_execute_by_pid(PARASITE_CMD_INIT_THREAD, ctl,
+		ret = parasite_execute_trap_by_pid(PARASITE_CMD_INIT_THREAD, ctl,
 					      item->threads[i].real);
 		if (ret) {
 			pr_err("Can't init thread in parasite %d\n",
@@ -558,7 +558,7 @@ int parasite_fini_threads_seized(struct parasite_ctl *ctl, struct pstree_item *i
 		if (item->pid.real == item->threads[i].real)
 			continue;
 
-		ret = parasite_execute_by_pid(PARASITE_CMD_FINI_THREAD, ctl,
+		ret = parasite_execute_trap_by_pid(PARASITE_CMD_FINI_THREAD, ctl,
 					      item->threads[i].real);
 		/*
 		 * Note the thread's fini() can be called even when not
@@ -591,7 +591,7 @@ int parasite_cure_remote(struct parasite_ctl *ctl, struct pstree_item *item)
 	if (ctl->parasite_ip) {
 		ctl->signals_blocked = 0;
 		parasite_fini_threads_seized(ctl, item);
-		parasite_execute(PARASITE_CMD_FINI, ctl);
+		parasite_execute_trap(PARASITE_CMD_FINI, ctl);
 	}
 
 	if (ctl->remote_map) {
-- 
1.8.2



More information about the CRIU mailing list