mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
itimers: Don't write itimer_entry from parasite
Same as with previous patch -- we have to pull image-independent entry out of the victim task to be able to use protobuf library for encoding. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include <sys/time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
@@ -52,6 +52,12 @@ struct parasite_dump_sa_args {
|
||||
rt_sigaction_t sas[SIGMAX];
|
||||
};
|
||||
|
||||
struct parasite_dump_itimers_args {
|
||||
struct itimerval real;
|
||||
struct itimerval virt;
|
||||
struct itimerval prof;
|
||||
};
|
||||
|
||||
/*
|
||||
* Misc sfuff, that is too small for separate file, but cannot
|
||||
* be read w/o using parasite
|
||||
|
@@ -349,30 +349,6 @@ static int parasite_prep_file(int fd, struct parasite_ctl *ctl)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parasite_file_cmd(char *what, int cmd, int type,
|
||||
struct parasite_ctl *ctl,
|
||||
struct cr_fdset *cr_fdset)
|
||||
{
|
||||
int ret = -1, fd;
|
||||
|
||||
pr_info("\n");
|
||||
pr_info("Dumping %s (pid: %d)\n", what, ctl->pid);
|
||||
pr_info("----------------------------------------\n");
|
||||
|
||||
fd = fdset_fd(cr_fdset, type);
|
||||
ret = parasite_prep_file(fd, ctl);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
ret = parasite_execute(cmd, ctl, NULL, 0);
|
||||
|
||||
fchmod(fd, CR_FD_PERM);
|
||||
out:
|
||||
pr_info("----------------------------------------\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int parasite_init(struct parasite_ctl *ctl, pid_t pid)
|
||||
{
|
||||
struct parasite_init_args args = { };
|
||||
@@ -479,10 +455,36 @@ int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_f
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dump_one_timer(struct itimerval *v, int fd)
|
||||
{
|
||||
struct itimer_entry ie;
|
||||
|
||||
ie.isec = v->it_interval.tv_sec;
|
||||
ie.iusec = v->it_interval.tv_usec;
|
||||
ie.vsec = v->it_value.tv_sec;
|
||||
ie.vusec = v->it_value.tv_sec;
|
||||
|
||||
return write_img(fd, &ie);
|
||||
}
|
||||
|
||||
int parasite_dump_itimers_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_fdset)
|
||||
{
|
||||
return parasite_file_cmd("timers", PARASITE_CMD_DUMP_ITIMERS,
|
||||
CR_FD_ITIMERS, ctl, cr_fdset);
|
||||
struct parasite_dump_itimers_args args;
|
||||
int ret, fd;
|
||||
|
||||
ret = parasite_execute(PARASITE_CMD_DUMP_ITIMERS, ctl, &args, sizeof(args));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
fd = fdset_fd(cr_fdset, CR_FD_ITIMERS);
|
||||
|
||||
ret = dump_one_timer(&args.real, fd);
|
||||
if (!ret)
|
||||
ret = dump_one_timer(&args.virt, fd);
|
||||
if (!ret)
|
||||
ret = dump_one_timer(&args.prof, fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int parasite_dump_misc_seized(struct parasite_ctl *ctl, struct parasite_dump_misc *misc)
|
||||
|
50
parasite.c
50
parasite.c
@@ -280,53 +280,19 @@ static int dump_sigact(struct parasite_dump_sa_args *da)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dump_itimer(int which, int fd)
|
||||
static int dump_itimers(struct parasite_dump_itimers_args *args)
|
||||
{
|
||||
struct itimerval val;
|
||||
int ret;
|
||||
struct itimer_entry ie;
|
||||
|
||||
ret = sys_getitimer(which, &val);
|
||||
if (ret < 0) {
|
||||
sys_write_msg("getitimer failed\n");
|
||||
return ret;
|
||||
}
|
||||
ret = sys_getitimer(ITIMER_REAL, &args->real);
|
||||
if (!ret)
|
||||
ret = sys_getitimer(ITIMER_VIRTUAL, &args->virt);
|
||||
if (!ret)
|
||||
ret = sys_getitimer(ITIMER_PROF, &args->prof);
|
||||
|
||||
ie.isec = val.it_interval.tv_sec;
|
||||
ie.iusec = val.it_interval.tv_usec;
|
||||
ie.vsec = val.it_value.tv_sec;
|
||||
ie.vusec = val.it_value.tv_sec;
|
||||
|
||||
ret = sys_write_safe(fd, &ie, sizeof(ie));
|
||||
if (ret)
|
||||
return ret;
|
||||
sys_write_msg("getitimer failed\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dump_itimers()
|
||||
{
|
||||
int fd;
|
||||
int ret = -1;
|
||||
|
||||
fd = recv_fd(tsock);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
ret = dump_itimer(ITIMER_REAL, fd);
|
||||
if (ret < 0)
|
||||
goto err_close;
|
||||
|
||||
ret = dump_itimer(ITIMER_VIRTUAL, fd);
|
||||
if (ret < 0)
|
||||
goto err_close;
|
||||
|
||||
ret = dump_itimer(ITIMER_PROF, fd);
|
||||
if (ret < 0)
|
||||
goto err_close;
|
||||
|
||||
err_close:
|
||||
sys_close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -453,7 +419,7 @@ int __used parasite_service(unsigned long cmd, void *args)
|
||||
case PARASITE_CMD_DUMP_SIGACTS:
|
||||
return dump_sigact((struct parasite_dump_sa_args *)args);
|
||||
case PARASITE_CMD_DUMP_ITIMERS:
|
||||
return dump_itimers();
|
||||
return dump_itimers((struct parasite_dump_itimers_args *)args);
|
||||
case PARASITE_CMD_DUMP_MISC:
|
||||
return dump_misc((struct parasite_dump_misc *)args);
|
||||
case PARASITE_CMD_DUMP_TID_ADDR:
|
||||
|
Reference in New Issue
Block a user