[CRIU] [PATCH 07/12] posix-timer: Add dump functionality
Pavel Emelyanov
xemul at parallels.com
Thu May 30 06:54:56 EDT 2013
On 05/30/2013 03:36 AM, Pavel Tikhomirov wrote:
>
> Signed-off-by: Pavel Tikhomirov <snorcht at gmail.com>
> ---
> cr-dump.c | 13 ++++++++++
> include/parasite-syscall.h | 3 +++
> parasite-syscall.c | 62 ++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 78 insertions(+)
>
> diff --git a/cr-dump.c b/cr-dump.c
> index 6ea17a7..4b3f2da 100644
> --- a/cr-dump.c
> +++ b/cr-dump.c
> @@ -1488,6 +1488,19 @@ static int dump_one_task(struct pstree_item *item)
> goto err_cure;
> }
>
> + struct proc_posix_timers_stat proc_args;
Don't mix vars declarations and code.
> + ret = parse_posix_timers(pid, &proc_args);
> + if (ret < 0){
> + pr_err("Can't read posix timers file (pid: %d)\n", pid);
> + goto err_cure;
> + }
> +
> + ret = parasite_dump_posix_timers_seized(&proc_args, parasite_ctl, cr_fdset);
> + if (ret) {
> + pr_err("Can't dump posix timers (pid: %d)\n", pid);
> + goto err_cure;
> + }
> +
> ret = dump_task_core_all(parasite_ctl, item->core[0], &pps_buf, &misc, &vmas, cr_fdset);
> if (ret) {
> pr_err("Dump core (pid: %d) failed with %d\n", pid, ret);
> @@ -604,6 +607,65 @@ int parasite_dump_itimers_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_f
> return ret;
> }
>
> +static int dump_one_posix_timer(struct posix_timer *v, struct proc_posix_timer *vp, int fd)
> +{
> + PosixTimerEntry pte = POSIX_TIMER_ENTRY__INIT;
> +
> + pte.it_id = vp->it_id;
> + pte.clock_id = vp->clock_id;
> + pte.si_signo = vp->si_signo;
> + pte.it_sigev_notify = vp->it_sigev_notify;
> + pte.sival_ptr = vp->sival_ptr.i; //pointer to int through union
You only need the sival_ptr.i in this place. What for? Why not work with sival_ptr.p always?
> +
> + pte.overrun = v->overrun;
> +
> + pte.isec = v->val.it_interval.tv_sec;
> + pte.insec = v->val.it_interval.tv_nsec;
> + pte.vsec = v->val.it_value.tv_sec;
> + pte.vnsec = v->val.it_value.tv_nsec;
> +
> + return pb_write_one(fd, &pte, PB_POSIX_TIMERS);
> +}
> +
> +int parasite_dump_posix_timers_seized(struct proc_posix_timers_stat *proc_args, struct parasite_ctl *ctl, struct cr_fdset *cr_fdset)
> +{
> + struct parasite_dump_posix_timers_args * args;
> + struct proc_posix_timer *temp;
> + int i, fd;
> + int ret = 0;
> +
> + args = parasite_args_s(ctl, sizeof(int) + sizeof(struct posix_timer) * proc_args->timer_n);
Since you request for parasite_args with variable size, you should go to parasite_args_size function
and make sure it mmaps the args area of the desired size.
> + args->timer_n = proc_args->timer_n;
> +
> + i = 0;
> + list_for_each_entry(temp, &proc_args->timers, list) {
> + args->timer[i].it_id = temp->it_id;
> + i++;
> + }
> +
> + ret = parasite_execute_daemon(PARASITE_CMD_DUMP_POSIX_TIMERS, ctl);
> + if (ret < 0)
> + goto end_posix;
> +
> + fd = fdset_fd(cr_fdset, CR_FD_POSIX_TIMERS);
> +
> + i = 0;
> + list_for_each_entry(temp, &proc_args->timers, list) {
> + ret = dump_one_posix_timer(&args->timer[i], temp, fd);
> + i++;
> + if (ret)
> + goto end_posix;
> + }
> +
> +end_posix:
> + while (!list_empty(&proc_args->timers)) {
> + temp = list_first_entry(&proc_args->timers, struct proc_posix_timer, list);
> + list_del(&temp->list);
> + xfree(temp);
> + }
> + return ret;
> +}
> +
> int parasite_dump_misc_seized(struct parasite_ctl *ctl, struct parasite_dump_misc *misc)
> {
> struct parasite_dump_misc *ma;
>
More information about the CRIU
mailing list