[CRIU] [PATCH 34/78] infect: Introduce API to configure the infection

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


From: Pavel Emelyanov <xemul at virtuozzo.com>

I.e. -- the infect_ctX structure. Now it's in infect.h and
is aimed for compel sources.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/arch/x86/crtools.c         |  2 +-
 criu/include/infect.h           | 24 ++++++++++++++++++++++++
 criu/include/parasite-syscall.h | 20 --------------------
 criu/infect.c                   |  5 +++++
 criu/parasite-syscall.c         | 21 ++++++++++++---------
 5 files changed, 42 insertions(+), 30 deletions(-)

diff --git a/criu/arch/x86/crtools.c b/criu/arch/x86/crtools.c
index 686b62914a58..dbc04915fefd 100644
--- a/criu/arch/x86/crtools.c
+++ b/criu/arch/x86/crtools.c
@@ -24,8 +24,8 @@
 #include "errno.h"
 #include "uapi/std/syscall-codes.h"
 #include "kerndat.h"
-#include "infect-priv.h"
 #include "infect.h"
+#include "infect-priv.h"
 
 #include "protobuf.h"
 #include "images/core.pb-c.h"
diff --git a/criu/include/infect.h b/criu/include/infect.h
index 973913d21a51..072143eedcf3 100644
--- a/criu/include/infect.h
+++ b/criu/include/infect.h
@@ -81,4 +81,28 @@ extern int compel_mode_native(struct parasite_ctl *ctl);
 
 extern k_rtsigset_t *compel_task_sigmask(struct parasite_ctl *ctl);
 
+struct rt_sigframe;
+
+struct infect_ctx {
+	int	*p_sock;
+
+	/*
+	 * Regs manipulation context.
+	 */
+	int (*save_regs)(void *, user_regs_struct_t *, user_fpregs_struct_t *);
+	int (*make_sigframe)(void *, struct rt_sigframe *, struct rt_sigframe *, k_rtsigset_t *);
+	void *regs_arg;
+
+	unsigned long		syscall_ip;				/* entry point of infection */
+	unsigned long		flags;			/* fine-tune (e.g. faults) */
+
+	void (*child_handler)(int, siginfo_t *, void *);	/* hander for SIGCHLD deaths */
+};
+
+extern struct infect_ctx *compel_infect_ctx(struct parasite_ctl *);
+
+#define INFECT_NO_MEMFD		0x1	/* don't use memfd() */
+#define INFECT_FAIL_CONNECT	0x2	/* make parasite connect() fail */
+#define INFECT_NO_BREAKPOINTS	0x4	/* no breakpoints in pie tracking */
+
 #endif
diff --git a/criu/include/parasite-syscall.h b/criu/include/parasite-syscall.h
index 15b4abfd8cb3..2efec72d4a03 100644
--- a/criu/include/parasite-syscall.h
+++ b/criu/include/parasite-syscall.h
@@ -27,26 +27,6 @@ struct thread_ctx {
 	user_regs_struct_t	regs;
 };
 
-struct infect_ctx {
-	int	*p_sock;
-
-	/*
-	 * Regs manipulation context.
-	 */
-	int (*save_regs)(void *, user_regs_struct_t *, user_fpregs_struct_t *);
-	int (*make_sigframe)(void *, struct rt_sigframe *, struct rt_sigframe *, k_rtsigset_t *);
-	void *regs_arg;
-
-	unsigned long		syscall_ip;				/* entry point of infection */
-	unsigned long		flags;			/* fine-tune (e.g. faults) */
-
-	void (*child_handler)(int, siginfo_t *, void *);	/* hander for SIGCHLD deaths */
-};
-
-#define INFECT_NO_MEMFD		0x1	/* don't use memfd() */
-#define INFECT_FAIL_CONNECT	0x2	/* make parasite connect() fail */
-#define INFECT_NO_BREAKPOINTS	0x4	/* no breakpoints in pie tracking */
-
 struct parasite_ctl;
 
 extern int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_imgset *cr_imgset);
diff --git a/criu/infect.c b/criu/infect.c
index 613dee1f9b06..008c253a2ef1 100644
--- a/criu/infect.c
+++ b/criu/infect.c
@@ -1216,3 +1216,8 @@ k_rtsigset_t *compel_task_sigmask(struct parasite_ctl *ctl)
 {
 	return &ctl->orig.sigmask;
 }
+
+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 376f77f16f0f..6f4b54ab6005 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -558,6 +558,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 		struct vm_area_list *vma_area_list)
 {
 	struct parasite_ctl *ctl;
+	struct infect_ctx *ictx;
 	unsigned long p;
 
 	BUG_ON(item->threads[0].real != pid);
@@ -572,20 +573,22 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 	if (!ctl)
 		return NULL;
 
-	ctl->ictx.child_handler = sigchld_handler;
-	ctl->ictx.p_sock = &dmpi(item)->netns->net.seqsk;
-	ctl->ictx.save_regs = save_task_regs;
-	ctl->ictx.make_sigframe = make_sigframe;
-	ctl->ictx.regs_arg = item->core[0];
-	ctl->ictx.syscall_ip = p;
+	ictx = compel_infect_ctx(ctl);
+
+	ictx->child_handler = sigchld_handler;
+	ictx->p_sock = &dmpi(item)->netns->net.seqsk;
+	ictx->save_regs = save_task_regs;
+	ictx->make_sigframe = make_sigframe;
+	ictx->regs_arg = item->core[0];
+	ictx->syscall_ip = p;
 	pr_debug("Parasite syscall_ip at %#lx\n", p);
 
 	if (fault_injected(FI_NO_MEMFD))
-		ctl->ictx.flags |= INFECT_NO_MEMFD;
+		ictx->flags |= INFECT_NO_MEMFD;
 	if (fault_injected(FI_PARASITE_CONNECT))
-		ctl->ictx.flags |= INFECT_FAIL_CONNECT;
+		ictx->flags |= INFECT_FAIL_CONNECT;
 	if (fault_injected(FI_NO_BREAKPOINTS))
-		ctl->ictx.flags |= INFECT_NO_BREAKPOINTS;
+		ictx->flags |= INFECT_NO_BREAKPOINTS;
 
 	parasite_ensure_args_size(dump_pages_args_size(vma_area_list));
 	parasite_ensure_args_size(aio_rings_args_size(vma_area_list));
-- 
2.7.4



More information about the CRIU mailing list