[CRIU] [PATCH 10/78] infect: Introduce flags on ictx

Cyrill Gorcunov gorcunov at openvz.org
Mon Nov 7 08:35:55 PST 2016


From: Pavel Emelyanov <xemul at virtuozzo.com>

These will control various behavior of infection engine. For now
only fault-injections.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/include/parasite-syscall.h | 4 ++++
 criu/parasite-syscall.c         | 9 +++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/criu/include/parasite-syscall.h b/criu/include/parasite-syscall.h
index b161a47ab48d..b1ca5024fb77 100644
--- a/criu/include/parasite-syscall.h
+++ b/criu/include/parasite-syscall.h
@@ -28,8 +28,12 @@ struct thread_ctx {
 
 struct infect_ctx {
 	int	*p_sock;
+	unsigned long		flags;			/* fine-tune (e.g. faults) */
 };
 
+#define INFECT_NO_MEMFD		0x1	/* don't use memfd() */
+#define INFECT_FAIL_CONNECT	0x2	/* make parasite connect() fail */
+
 /* parasite control block */
 struct parasite_ctl {
 	int			rpid;					/* Real pid of the victim */
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index 137517c9cca5..f467ea6205e1 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -474,7 +474,7 @@ static int prepare_tsock(struct parasite_ctl *ctl, pid_t pid,
 	}
 
 	/* Check a case when parasite can't initialize a command socket */
-	if (fault_injected(FI_PARASITE_CONNECT))
+	if (ctl->ictx.flags & INFECT_FAIL_CONNECT)
 		args->h_addr_len = gen_parasite_saddr(&args->h_addr, getpid() + 1);
 
 	/*
@@ -1317,7 +1317,7 @@ static int parasite_memfd_exchange(struct parasite_ctl *ctl, unsigned long size)
 	int ret, fd, lfd;
 	bool __maybe_unused compat_task = !seized_native(ctl);
 
-	if (fault_injected(FI_NO_MEMFD))
+	if (ctl->ictx.flags & INFECT_NO_MEMFD)
 		return 1;
 
 	BUILD_BUG_ON(sizeof(orig_code) < sizeof(long));
@@ -1482,6 +1482,11 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 
 	ctl->ictx.p_sock = &dmpi(item)->netns->net.seqsk;
 
+	if (fault_injected(FI_NO_MEMFD))
+		ctl->ictx.flags |= INFECT_NO_MEMFD;
+	if (fault_injected(FI_PARASITE_CONNECT))
+		ctl->ictx.flags |= INFECT_FAIL_CONNECT;
+
 	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