[CRIU] [PATCH] compel: compel_emergency_sigframe() helper introduced

Andrei Vagin avagin at virtuozzo.com
Thu Mar 23 15:56:14 PDT 2017


Dima and Kirill, could you review this patch?

On Fri, Mar 17, 2017 at 01:17:58PM +0300, Stanislav Kinsburskiy wrote:
> This helper constructs sigframe, which can be used to resume process from the
> point where it was stopped.
> Result has to be copied to the process manually and then used with rt_sigreturn.

How does it work in criu now? We need a test for this.

> 
> Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
> ---
>  compel/include/uapi/infect.h |    3 +++
>  compel/src/lib/infect.c      |   14 ++++++++++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/compel/include/uapi/infect.h b/compel/include/uapi/infect.h
> index aebb77c..08e9c54 100644
> --- a/compel/include/uapi/infect.h
> +++ b/compel/include/uapi/infect.h
> @@ -95,6 +95,9 @@ extern k_rtsigset_t *compel_thread_sigmask(struct parasite_thread_ctl *tctl);
>  
>  struct rt_sigframe;
>  
> +extern int compel_emergency_sigframe(struct parasite_ctl *ctl, struct rt_sigframe *f,
> +				     struct rt_sigframe *rtf);
> +
>  typedef int (*open_proc_fn)(int pid, int mode, const char *fmt, ...)
>  	__attribute__ ((__format__ (__printf__, 3, 4)));
>  
> diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c
> index a2cb5d6..f6cedc5 100644
> --- a/compel/src/lib/infect.c
> +++ b/compel/src/lib/infect.c
> @@ -1162,6 +1162,20 @@ static int make_sigframe_plain(void *from, struct rt_sigframe *f, struct rt_sigf
>  	return 0;
>  }
>  
> +int compel_emergency_sigframe(struct parasite_ctl *ctl, struct rt_sigframe *f,
> +			      struct rt_sigframe *rtf)
> +{
> +	pid_t pid = ctl->rpid;
> +	struct thread_ctx *thread = &ctl->orig;
> +	struct plain_regs_struct regs;
> +
> +	if (get_task_regs(pid, &thread->regs, save_regs_plain, &regs)) {
> +		pr_err("Can't obtain regs for thread %d\n", pid);
> +		return -1;
> +	}
> +	return make_sigframe_plain(&regs, f, rtf, &thread->sigmask);
> +}
> +
>  struct parasite_ctl *compel_prepare(int pid)
>  {
>  	struct parasite_ctl *ctl;
> 


More information about the CRIU mailing list