Commit c0836c20 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

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: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 5be54240
......@@ -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 *);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment