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

Dmitry Safonov 0x7f454c46 at gmail.com
Mon Mar 27 06:15:43 PDT 2017


2017-03-27 15:57 GMT+03:00 Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>:
>
>
> 24.03.2017 11:14, Dmitry Safonov пишет:
>
>> 2017-03-24 12:32 GMT+03:00 Stanislav Kinsburskiy
>> <skinsbursky at virtuozzo.com>:
>>>
>>>
>>> 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>
>>
>> [...]
>>>>>
>>>>> --- 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.
>>
>> Maybe it worth not providing additional interfaces, but splitting the
>> existing.
>> If we can make non-parasite version of compel_infect() and reuse its code
>> in parasite's one, so it'll suit criu's needs and needs of projects
>> without parasite.
>> Does it make sense?
>
>
> Definitely.
>
>> Also, this looks incomplete without curing part. How do you use
>> prepared sigframe
>> afterward? Calling rt_sigreturn() with the help of compel_syscall() or
>> somehow alike?
>
>
> Yes. Somehow alike.
>
>> I guess, there should be also a patch to complement API.
>> And (by @avagin's rules) - adding new API/features means adding tests for
>> it,
>> looks like it wouldn't take much time to write a test for this.
>
>
> If this peace of code will be used by CRIU itself, then it looks like
> sufficient testing. No?
>

Ok for me, but the test also plays as an example how-to-use such API.
I don't insist, anyway.

-- 
             Dmitry



More information about the CRIU mailing list