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

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Fri Mar 24 02:32:27 PDT 2017



24.03.2017 00:13, Andrei Vagin пишет:
> 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.
>>
>> 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);
> make_sigframe_plain is called from parasite_start_daemon(), why it
> doesn't work for you. Could you describe your usecase for these changes?
>

Because I don't have parasite plugin, on which parasite_start_daemon relies.
But it makes sense to use this new helper in parasite_start_daemon to 
make sure it's tested.


>> +}
>> +
>>   struct parasite_ctl *compel_prepare(int pid)
>>   {
>>   	struct parasite_ctl *ctl;
>>



More information about the CRIU mailing list