[CRIU] [PATCH] parasite-syscall: some cleanup
Kinsbursky Stanislav
skinsbursky at openvz.org
Tue Feb 21 09:47:53 EST 2012
Removed redundant on-stack variables typeof parasite_status_t and memcpy
between them and parasite_ctl->addr_args object. Ando a lot of cleanup done
around.
Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
parasite-syscall.c | 68 +++++++++++++++++++++-------------------------------
1 files changed, 27 insertions(+), 41 deletions(-)
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 02a50fa..3254650 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -226,27 +226,22 @@ err:
return ret;
}
-static int parasite_execute(unsigned long cmd, struct parasite_ctl *ctl,
- parasite_status_t *args, int args_size)
+static int parasite_execute(unsigned long cmd, struct parasite_ctl *ctl)
{
int ret;
-
user_regs_struct_t regs = ctl->regs_orig;
memcpy(ctl->addr_cmd, &cmd, sizeof(cmd));
- memcpy(ctl->addr_args, args, args_size);
-
parasite_setup_regs(ctl->parasite_ip, ®s);
ret = __parasite_execute(ctl, ®s);
- memcpy(args, ctl->addr_args, args_size);
- if (!ret)
- ret = args->ret;
+ if (ret) {
+ parasite_status_t *args = ctl->addr_args;
- if (ret)
pr_err("Parasite exited with %d ret (%li at %li)\n",
ret, args->sys_ret, args->line);
+ }
return ret;
}
@@ -356,8 +351,7 @@ static int parasite_file_cmd(char *what, int cmd, int type,
struct parasite_ctl *ctl,
struct cr_fdset *cr_fdset)
{
- parasite_status_t args = { };
- int ret = -1;
+ int ret;
pr_info("\n");
pr_info("Dumping %s (pid: %d)\n", what, ctl->pid);
@@ -367,7 +361,7 @@ static int parasite_file_cmd(char *what, int cmd, int type,
if (ret < 0)
goto out;
- ret = parasite_execute(cmd, ctl, (parasite_status_t *)&args, sizeof(args));
+ ret = parasite_execute(cmd, ctl);
fchmod(cr_fdset->fds[type], CR_FD_PERM);
out:
@@ -378,24 +372,22 @@ out:
static int parasite_init(struct parasite_ctl *ctl, pid_t pid)
{
- struct parasite_init_args args = { };
+ struct parasite_init_args *args = ctl->addr_args;
- args.sun_len = get_socket_name(&args.saddr, pid);
+ args->sun_len = get_socket_name(&args->saddr, pid);
- return parasite_execute(PARASITE_CMD_INIT, ctl,
- (parasite_status_t *)&args, sizeof(args));
+ return parasite_execute(PARASITE_CMD_INIT, ctl);
}
static int parasite_set_logfd(struct parasite_ctl *ctl, pid_t pid)
{
- parasite_status_t args = { };
int ret;
ret = parasite_send_fd(ctl, get_logfd());
if (ret)
return ret;
- ret = parasite_execute(PARASITE_CMD_SET_LOGFD, ctl, &args, sizeof(args));
+ ret = parasite_execute(PARASITE_CMD_SET_LOGFD, ctl);
if (ret < 0)
return ret;
@@ -416,9 +408,7 @@ int parasite_dump_itimers_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_f
int parasite_dump_misc_seized(struct parasite_ctl *ctl, struct parasite_dump_misc *misc)
{
- return parasite_execute(PARASITE_CMD_DUMP_MISC, ctl,
- (parasite_status_t *)misc,
- sizeof(struct parasite_dump_misc));
+ return parasite_execute(PARASITE_CMD_DUMP_MISC, ctl);
}
/*
@@ -428,8 +418,7 @@ int parasite_dump_misc_seized(struct parasite_ctl *ctl, struct parasite_dump_mis
int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_area_list,
struct cr_fdset *cr_fdset)
{
- struct parasite_dump_pages_args parasite_dumppages = { };
- parasite_status_t *st = ¶site_dumppages.status;
+ struct parasite_dump_pages_args *parasite_dumppages = ctl->addr_args;
unsigned long nrpages_dumped = 0;
struct vma_area *vma_area;
int ret = -1;
@@ -446,12 +435,12 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_a
if (ret < 0)
goto out;
- ret = parasite_execute(PARASITE_CMD_DUMPPAGES_INIT, ctl, st, sizeof(*st));
+ ret = parasite_execute(PARASITE_CMD_DUMPPAGES_INIT, ctl);
if (ret < 0) {
pr_panic("Dumping pages failed with %li (%li) at %li\n",
- parasite_dumppages.status.ret,
- parasite_dumppages.status.sys_ret,
- parasite_dumppages.status.line);
+ parasite_dumppages->status.ret,
+ parasite_dumppages->status.sys_ret,
+ parasite_dumppages->status.line);
goto out;
}
@@ -472,35 +461,33 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_a
continue;
pr_info_vma(vma_area);
- parasite_dumppages.vma_entry = vma_area->vma;
+ parasite_dumppages->vma_entry = vma_area->vma;
if (vma_area_is(vma_area, VMA_ANON_PRIVATE) ||
vma_area_is(vma_area, VMA_FILE_PRIVATE))
- parasite_dumppages.fd_type = PG_PRIV;
+ parasite_dumppages->fd_type = PG_PRIV;
else if (vma_area_is(vma_area, VMA_ANON_SHARED))
- parasite_dumppages.fd_type = PG_SHARED;
+ parasite_dumppages->fd_type = PG_SHARED;
else {
pr_warning("Unexpected VMA area found\n");
continue;
}
- ret = parasite_execute(PARASITE_CMD_DUMPPAGES, ctl,
- (parasite_status_t *) ¶site_dumppages,
- sizeof(parasite_dumppages));
+ ret = parasite_execute(PARASITE_CMD_DUMPPAGES, ctl);
if (ret) {
pr_panic("Dumping pages failed with %li (%li) at %li\n",
- parasite_dumppages.status.ret,
- parasite_dumppages.status.sys_ret,
- parasite_dumppages.status.line);
+ parasite_dumppages->status.ret,
+ parasite_dumppages->status.sys_ret,
+ parasite_dumppages->status.line);
goto out;
}
- pr_info(" (dumped: %16li pages)\n", parasite_dumppages.nrpages_dumped);
- nrpages_dumped += parasite_dumppages.nrpages_dumped;
+ pr_info(" (dumped: %16li pages)\n", parasite_dumppages->nrpages_dumped);
+ nrpages_dumped += parasite_dumppages->nrpages_dumped;
}
- parasite_execute(PARASITE_CMD_DUMPPAGES_FINI, ctl, st, sizeof(*st));
+ parasite_execute(PARASITE_CMD_DUMPPAGES_FINI, ctl);
if (write_img(cr_fdset->fds[CR_FD_PAGES], &zero_page_entry))
goto out;
@@ -521,11 +508,10 @@ out:
int parasite_cure_seized(struct parasite_ctl *ctl)
{
- parasite_status_t args = { };
int ret = 0;
if (ctl->parasite_ip) {
- if (parasite_execute(PARASITE_CMD_FINI, ctl, &args, sizeof(args))) {
+ if (parasite_execute(PARASITE_CMD_FINI, ctl)) {
pr_err("Can't finalize parasite (pid: %d) task\n", ctl->pid);
ret = -1;
}
More information about the CRIU
mailing list