From c0836c20521a32fc8cbbb00d5f8b70a933096fec Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Mon, 21 Nov 2016 21:26:13 +0300 Subject: [PATCH] compel: Add compel_prepare_noctx 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). travis-ci: success for compel: Contrinue improving library Signed-off-by: Pavel Emelyanov Signed-off-by: Andrei Vagin --- 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 c8a6d9f6e..f28e5580f 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 3ba34cdc6..f924e8683 100644 --- a/compel/src/lib/infect.c +++ b/compel/src/lib/infect.c @@ -894,7 +894,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; @@ -924,6 +924,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 = compel_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 2448360c9..bbb499339 100644 --- a/criu/cr-restore.c +++ b/criu/cr-restore.c @@ -1657,7 +1657,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 77fc6238c..dc510ba66 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;