2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00

timers: save tid from a task pid namespace

Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
Andrei Vagin
2021-07-11 00:55:08 +03:00
parent 61e1334ab0
commit 7eab5a7dc7

View File

@@ -318,14 +318,13 @@ static int core_alloc_posix_timers(TaskTimersEntry *tte, int n,
return 0;
}
static void encode_posix_timer(struct posix_timer *v,
struct proc_posix_timer *vp, PosixTimerEntry *pte)
static int encode_posix_timer(struct pstree_item *item, struct posix_timer *v,
struct proc_posix_timer *vp, PosixTimerEntry *pte)
{
pte->it_id = vp->spt.it_id;
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;
@@ -334,6 +333,27 @@ static void encode_posix_timer(struct posix_timer *v,
pte->insec = v->val.it_interval.tv_nsec;
pte->vsec = v->val.it_value.tv_sec;
pte->vnsec = v->val.it_value.tv_nsec;
if (vp->spt.notify_thread_id != 0) {
pid_t vtid = 0, rtid = vp->spt.notify_thread_id;
int i;
for (i = 0; i < item->nr_threads; i++) {
if (item->threads[i].real != rtid)
continue;
vtid = item->threads[i].ns[0].virt;
break;
}
if (vtid == 0) {
pr_err("Unable to find the thread %d\n", rtid);
return -1;
}
pte->notify_thread_id = vtid;
pte->has_notify_thread_id = true;
}
return 0;
}
int parasite_dump_posix_timers_seized(struct proc_posix_timers_stat *proc_args,
@@ -344,8 +364,8 @@ int parasite_dump_posix_timers_seized(struct proc_posix_timers_stat *proc_args,
PosixTimerEntry *pte;
struct proc_posix_timer *temp;
struct parasite_dump_posix_timers_args *args;
int ret, exit_code = -1;
int args_size;
int ret = 0;
int i;
if (core_alloc_posix_timers(tte, proc_args->timer_n, &pte))
@@ -368,14 +388,16 @@ int parasite_dump_posix_timers_seized(struct proc_posix_timers_stat *proc_args,
i = 0;
list_for_each_entry(temp, &proc_args->timers, list) {
posix_timer_entry__init(&pte[i]);
encode_posix_timer(&args->timer[i], temp, &pte[i]);
if (encode_posix_timer(item, &args->timer[i], temp, &pte[i]))
goto end_posix;
tte->posix[i] = &pte[i];
i++;
}
exit_code = 0;
end_posix:
free_posix_timers(proc_args);
return ret;
return exit_code;
}
int parasite_dump_misc_seized(struct parasite_ctl *ctl, struct parasite_dump_misc *misc)