[CRIU] [PATCH 71/78] infect: Add log_fd on ictx

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


From: Pavel Emelyanov <xemul at virtuozzo.com>

This is the descriptor to be used by parasite code for
messages. In pure compel environment this will have to
be some file provided by caller or a pipe from which
libcompel will pull messages.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/include/infect.h   | 2 ++
 criu/infect.c           | 6 +++++-
 criu/parasite-syscall.c | 2 ++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/criu/include/infect.h b/criu/include/infect.h
index fc4f949f9e77..3f3913ac3165 100644
--- a/criu/include/infect.h
+++ b/criu/include/infect.h
@@ -109,6 +109,8 @@ struct infect_ctx {
 	void (*child_handler)(int, siginfo_t *, void *);	/* hander for SIGCHLD deaths */
 
 	open_proc_fn open_proc;
+
+	int			log_fd;	/* fd for parasite code to send messages to */
 };
 
 extern struct infect_ctx *compel_infect_ctx(struct parasite_ctl *);
diff --git a/criu/infect.c b/criu/infect.c
index cd6f1a9b87e9..94338c398ff8 100644
--- a/criu/infect.c
+++ b/criu/infect.c
@@ -575,7 +575,7 @@ static int parasite_init_daemon(struct parasite_ctl *ctl)
 	if (accept_tsock(ctl) < 0)
 		goto err;
 
-	if (compel_util_send_fd(ctl, log_get_fd()))
+	if (compel_util_send_fd(ctl, ctl->ictx.log_fd))
 		goto err;
 
 	pr_info("Wait for parasite being daemonized...\n");
@@ -768,6 +768,9 @@ int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned l
 	int ret;
 	unsigned long p, map_exchange_size, parasite_size = 0;
 
+	if (ctl->ictx.log_fd < 0)
+		goto err;
+
 	if (!arch_can_dump_task(ctl))
 		goto err;
 
@@ -858,6 +861,7 @@ struct parasite_ctl *compel_prepare(int pid)
 	}
 
 	ctl->tsock = -1;
+	ctl->ictx.log_fd = -1;
 
 	if (compel_prepare_thread(pid, &ctl->orig))
 		goto err;
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index 1821efd85fc5..db405bca5dad 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -562,6 +562,8 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 	if (kdat.has_compat_sigreturn)
 		ictx->flags |= INFECT_HAS_COMPAT_SIGRETURN;
 
+	ictx->log_fd = log_get_fd();
+
 	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