From 80079fbb0d495428964c0836eaf46cf0f4dd8928 Mon Sep 17 00:00:00 2001 From: Liu Chao Date: Tue, 29 Jun 2021 02:02:51 +0000 Subject: [PATCH] criu: dump and restore notify_thread_id of posix timer 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. Signed-off-by: Liu Chao --- criu/cr-restore.c | 1 + criu/include/posix-timer.h | 1 + criu/parasite-syscall.c | 1 + criu/pie/restorer.c | 5 +++++ criu/proc_parse.c | 1 + images/timer.proto | 1 + 6 files changed, 10 insertions(+) diff --git a/criu/cr-restore.c b/criu/cr-restore.c index 7b6eec9ad..93765966c 100644 --- a/criu/cr-restore.c +++ b/criu/cr-restore.c @@ -2798,6 +2798,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.notify_thread_id = pte->notify_thread_id; pt->overrun = pte->overrun; return 0; diff --git a/criu/include/posix-timer.h b/criu/include/posix-timer.h index fa99d8628..139f5c9a5 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 notify_thread_id; void * sival_ptr; }; diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c index 04364e5bf..6f07ccf1f 100644 --- a/criu/parasite-syscall.c +++ b/criu/parasite-syscall.c @@ -325,6 +325,7 @@ static void encode_posix_timer(struct posix_timer *v, pte->clock_id = vp->spt.clock_id; pte->si_signo = vp->spt.si_signo; pte->it_sigev_notify = vp->spt.it_sigev_notify; + pte->notify_thread_id = vp->spt.notify_thread_id; pte->sival_ptr = encode_pointer(vp->spt.sival_ptr); pte->overrun = v->overrun; diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c index 310ce2754..de0cdb8f5 100644 --- a/criu/pie/restorer.c +++ b/criu/pie/restorer.c @@ -1069,6 +1069,11 @@ static int create_posix_timers(struct task_restore_args *args) for (i = 0; i < args->posix_timers_n; i++) { sev.sigev_notify = args->posix_timers[i].spt.it_sigev_notify; sev.sigev_signo = args->posix_timers[i].spt.si_signo; +#ifdef __GLIBC__ + sev._sigev_un._tid = args->posix_timers[i].spt.notify_thread_id; +#else + sev.sigev_notify_thread_id = args->posix_timers[i].spt.notify_thread_id; +#endif sev.sigev_value.sival_ptr = args->posix_timers[i].spt.sival_ptr; while (1) { diff --git a/criu/proc_parse.c b/criu/proc_parse.c index 86debe2f5..3015b4703 100644 --- a/criu/proc_parse.c +++ b/criu/proc_parse.c @@ -2342,6 +2342,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.notify_thread_id = pid_t; } else { switch (sigpid[0]) { case 's' : diff --git a/images/timer.proto b/images/timer.proto index 4eb5452b3..3b95562ab 100644 --- a/images/timer.proto +++ b/images/timer.proto @@ -21,6 +21,7 @@ message posix_timer_entry { required uint64 insec = 8; required uint64 vsec = 9; required uint64 vnsec = 10; + optional int32 notify_thread_id= 11; } message task_timers_entry {