From: Liu Chao liuchao173@huawei.com
When sigev_notify_thread_id is not set, get_pid will return a NULL pointer and do_timer_create will return -EINVAL in kernel. So criu will failed to create posix timer:
(09.806760) pie: 41301: Error (criu/pie/restorer.c:1998): Can't restore posix timers -22 (09.806824) pie: 41301: Error (criu/pie/restorer.c:2133): Restorer fail 41301 (09.891880) Error (criu/cr-restore.c:2596): Restoring FAILED.
Conflict:NA Reference:https://gitee.com/src-openeuler/criu/pulls/21 Signed-off-by: Liu Chao liuchao173@huawei.com --- criu/cr-restore.c | 1 + criu/include/posix-timer.h | 1 + criu/parasite-syscall.c | 1 + criu/pie/restorer.c | 1 + criu/proc_parse.c | 1 + images/timer.proto | 1 + 6 files changed, 6 insertions(+)
diff --git a/criu/cr-restore.c b/criu/cr-restore.c index ecebdfe..2ed61d0 100644 --- a/criu/cr-restore.c +++ b/criu/cr-restore.c @@ -2848,6 +2848,7 @@ static inline int decode_posix_timer(PosixTimerEntry *pte, pt->spt.si_signo = pte->si_signo; pt->spt.it_sigev_notify = pte->it_sigev_notify; pt->spt.sival_ptr = decode_pointer(pte->sival_ptr); + pt->spt.sigev_notify_thread_id = pte->sigev_notify_thread_id; pt->overrun = pte->overrun;
return 0; diff --git a/criu/include/posix-timer.h b/criu/include/posix-timer.h index fa99d86..11b7618 100644 --- a/criu/include/posix-timer.h +++ b/criu/include/posix-timer.h @@ -8,6 +8,7 @@ struct str_posix_timer { int clock_id; int si_signo; int it_sigev_notify; + int sigev_notify_thread_id; void * sival_ptr; };
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c index c7074c7..8d9e01b 100644 --- a/criu/parasite-syscall.c +++ b/criu/parasite-syscall.c @@ -316,6 +316,7 @@ static void encode_posix_timer(struct posix_timer *v, pte->si_signo = vp->spt.si_signo; pte->it_sigev_notify = vp->spt.it_sigev_notify; pte->sival_ptr = encode_pointer(vp->spt.sival_ptr); + pte->sigev_notify_thread_id = vp->spt.sigev_notify_thread_id;
pte->overrun = v->overrun;
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c index 0bd220a..5e06abb 100644 --- a/criu/pie/restorer.c +++ b/criu/pie/restorer.c @@ -1224,6 +1224,7 @@ static int create_posix_timers(struct task_restore_args *args) sev.sigev_notify = args->posix_timers[i].spt.it_sigev_notify; sev.sigev_signo = args->posix_timers[i].spt.si_signo; sev.sigev_value.sival_ptr = args->posix_timers[i].spt.sival_ptr; + sev._sigev_un._tid = args->posix_timers[i].spt.sigev_notify_thread_id;
while (1) { ret = sys_timer_create(args->posix_timers[i].spt.clock_id, &sev, &next_id); diff --git a/criu/proc_parse.c b/criu/proc_parse.c index 32d84b3..c8a18cf 100644 --- a/criu/proc_parse.c +++ b/criu/proc_parse.c @@ -2380,6 +2380,7 @@ int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args)
if ( tidpid[0] == 't') { timer->spt.it_sigev_notify = SIGEV_THREAD_ID; + timer->spt.sigev_notify_thread_id = pid_t; } else { switch (sigpid[0]) { case 's' : diff --git a/images/timer.proto b/images/timer.proto index a254a6f..41db460 100644 --- a/images/timer.proto +++ b/images/timer.proto @@ -19,6 +19,7 @@ message posix_timer_entry { required uint64 insec = 8; required uint64 vsec = 9; required uint64 vnsec = 10; + required int32 sigev_notify_thread_id = 11; }
message task_timers_entry {