[CRIU] [PATCH 08/12] crtools: restore pending signals
Andrey Wagin
avagin at gmail.com
Tue Dec 18 23:07:40 EST 2012
2012/12/18 Pavel Emelyanov <xemul at parallels.com>:
>> @@ -1596,6 +1645,9 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
>>
>> struct task_restore_core_args *task_args;
>> struct thread_restore_args *thread_args;
>> + siginfo_t *siginfo_chunk;
>> + int siginfo_nr = 0;
>> + unsigned long siginfo_size = PAGE_SIZE;
>
> A question. Why do we restore pending signals in restorer, not in generic code?
Thread penging signals could not be restored, because threads are not exist yet.
SIGCHLD signal can't be restored in generic code too.
>
>> LIST_HEAD(self_vma_list);
>> int i;
>> @@ -1644,12 +1696,55 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
>> task_args = mem;
>> thread_args = mem + restore_task_vma_len;
>>
>> + siginfo_chunk = mmap(NULL, siginfo_size, PROT_READ | PROT_WRITE,
>> + MAP_PRIVATE | MAP_ANON, 0, 0);
>> + if (mem == MAP_FAILED) {
>> + pr_err("Can't allocate memory for siginfo-s\n");
>> + goto err;
>> + }
>
> This first mmap looks ugly. Re-mplement remapping in open_signal_image to
> hide one.
>
>> +
>> + ret = open_signal_image(CR_FD_SIGNAL, pid, &siginfo_chunk,
>> + &siginfo_size, &siginfo_nr);
>> + if (ret < 0) {
>> + if (errno != ENOENT) /* backward compatiblity */
>> + goto err;
>> + ret = 0;
>> + }
>> + task_args->siginfo_nr = ret;
>> +
>> + ret = open_signal_image(CR_FD_PSIGNAL, pid, &siginfo_chunk,
>> + &siginfo_size, &siginfo_nr);
>> + if (ret < 0) {
>> + if (errno != ENOENT) /* backward compatiblity */
>> + goto err;
>> + ret = 0;
>> + }
>> + task_args->t.siginfo_nr = ret;
>> +
>> + for (i = 0; i < current->nr_threads; i++) {
>
> We have already a loop that initialized thread restore data. This siginfos
> read-in should be there.
>
>> + thread_args[i].pid = current->threads[i].virt;
>> + /* skip self */
>> + if (thread_args[i].pid == pid)
>> + continue;
>> +
>> + ret = open_signal_image(CR_FD_PSIGNAL,
>> + thread_args[i].pid, &siginfo_chunk,
>> + &siginfo_size, &siginfo_nr);
>> + if (ret < 0) {
>> + if (errno != ENOENT) /* backward compatiblity */
>> + goto err;
>> + ret = 0;
>> + }
>> + thread_args[i].siginfo_nr = ret;
>> + }
>> +
>> restore_bootstrap_len = restorer_len +
>> restore_task_vma_len +
>> restore_thread_vma_len +
>> SHMEMS_SIZE + TASK_ENTRIES_SIZE +
>> self_vmas_len + vmas_len +
>> - rst_tcp_socks_size;
>> + rst_tcp_socks_size +
>> + siginfo_size;
>>
>> /*
>> * Restorer is a blob (code + args) that will get mapped in some
>> diff --git a/include/restorer.h b/include/restorer.h
>> index 2309a3d..f7a762d 100644
>> --- a/include/restorer.h
>> +++ b/include/restorer.h
>> @@ -79,6 +79,9 @@ struct thread_restore_args {
>> struct rst_sched_param sp;
>>
>> struct task_restore_core_args *ta;
>> +
>> + siginfo_t *siginfo;
>> + unsigned int siginfo_nr;
>> } __aligned(sizeof(long));
>>
>> struct task_restore_core_args {
>> @@ -98,6 +101,9 @@ struct task_restore_core_args {
>> struct task_entries *task_entries;
>> VmaEntry *self_vmas;
>> VmaEntry *tgt_vmas;
>> + siginfo_t *siginfo;
>> + unsigned int siginfo_nr;
>> + unsigned long siginfo_size;
>
> What for? Master thread's siginfos are in respective thread-info.
>
>> unsigned int nr_vmas;
>> unsigned long premmapped_addr;
>> unsigned long premmapped_len;
More information about the CRIU
mailing list