[CRIU] [PATCH 1/8] compel: Add compel_prepare_noctx

Cyrill Gorcunov gorcunov at openvz.org
Mon Nov 21 10:26:13 PST 2016


From: Pavel Emelyanov <xemul at virtuozzo.com>

The original compel_prepare() also initializes the infect_ctx with
values suitable for simple usage. As a starting point the task_size
value is set.

The compel_prepare_noctx() allocates ctx-less handler that is to be
filled by the caller (CRIU).

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 compel/include/uapi/infect.h |  1 +
 compel/src/lib/infect.c      | 17 ++++++++++++++++-
 criu/cr-restore.c            |  2 +-
 criu/parasite-syscall.c      |  2 +-
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/compel/include/uapi/infect.h b/compel/include/uapi/infect.h
index adc40f2d98d9..a17fd2efc6b8 100644
--- a/compel/include/uapi/infect.h
+++ b/compel/include/uapi/infect.h
@@ -40,6 +40,7 @@ struct parasite_ctl;
 struct parasite_thread_ctl;
 
 extern struct parasite_ctl *compel_prepare(int pid);
+extern struct parasite_ctl *compel_prepare_noctx(int pid);
 extern int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned long args_size);
 extern struct parasite_thread_ctl *compel_prepare_thread(struct parasite_ctl *ctl, int pid);
 extern void compel_release_thread(struct parasite_thread_ctl *);
diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c
index f0119de8523c..aee125d28f2f 100644
--- a/compel/src/lib/infect.c
+++ b/compel/src/lib/infect.c
@@ -896,7 +896,7 @@ void compel_release_thread(struct parasite_thread_ctl *tctl)
 	xfree(tctl);
 }
 
-struct parasite_ctl *compel_prepare(int pid)
+struct parasite_ctl *compel_prepare_noctx(int pid)
 {
 	struct parasite_ctl *ctl = NULL;
 
@@ -926,6 +926,21 @@ err:
 	return NULL;
 }
 
+struct parasite_ctl *compel_prepare(int pid)
+{
+	struct parasite_ctl *ctl;
+	struct infect_ctx *ictx;
+
+	ctl = compel_prepare_noctx(pid);
+	if (ctl == NULL)
+		goto out;
+
+	ictx = &ctl->ictx;
+	ictx->task_size = task_size();
+out:
+	return ctl;
+}
+
 static bool task_in_parasite(struct parasite_ctl *ctl, user_regs_struct_t *regs)
 {
 	void *addr = (void *) REG_IP(*regs);
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 4d846e8df6fe..d109b0d5b9b2 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1647,7 +1647,7 @@ static void finalize_restore(void)
 			continue;
 
 		/* Unmap the restorer blob */
-		ctl = compel_prepare(pid);
+		ctl = compel_prepare_noctx(pid);
 		if (ctl == NULL)
 			continue;
 
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index d44eced64546..f4312ed45f6a 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -573,7 +573,7 @@ struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
 		return NULL;
 	}
 
-	ctl = compel_prepare(pid);
+	ctl = compel_prepare_noctx(pid);
 	if (!ctl)
 		return NULL;
 
-- 
2.7.4



More information about the CRIU mailing list