[CRIU] [crtools-bot] parasite: transfer image fd in parasite
Cyrill Gorcunov
gorcunov at openvz.org
Wed Feb 1 10:26:59 EST 2012
The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit d4c67416e92a707538af2ea163a5203b92a71a07
Author: Andrey Vagin <avagin at openvz.org>
Date: Wed Feb 1 13:00:51 2012 +0300
parasite: transfer image fd in parasite
Don't open image files from parasite.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
Acked-by: Pavel Emelyanov <xemul at parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
include/parasite.h | 10 +---------
parasite-syscall.c | 24 ++++++++++++------------
parasite.c | 33 ++++++++-------------------------
3 files changed, 21 insertions(+), 46 deletions(-)
diff --git a/include/parasite.h b/include/parasite.h
index a79d54c..d682f08 100644
--- a/include/parasite.h
+++ b/include/parasite.h
@@ -68,16 +68,8 @@ struct parasite_init_args {
struct sockaddr_un saddr;
};
-struct parasite_dump_file_args {
- parasite_status_t status;
- unsigned long open_mode;
- unsigned long open_flags;
- char open_path[PATH_MAX];
-};
-
struct parasite_dump_pages_args {
- struct parasite_dump_file_args fa;
-
+ parasite_status_t status;
struct vma_entry vma_entry;
unsigned long nrpages_dumped; /* how many pages are dumped */
unsigned long fd;
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 0df4ea2..62affd4 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -383,34 +383,34 @@ out:
return ret;
}
-static int parasite_prep_file(int type, struct parasite_dump_file_args *fa,
+static int parasite_prep_file(int type,
struct parasite_ctl *ctl, struct cr_fdset *fdset)
{
- if (get_image_path(fa->open_path, sizeof(fa->open_path),
- fdset_template[type].fmt, ctl->pid))
- return -1;
+ int ret;
if (fchmod(fdset->fds[type], CR_FD_PERM_DUMP)) {
pr_perror("Can't change permissions on %d file", type);
return -1;
}
- fa->open_flags = O_WRONLY;
- fa->open_mode = CR_FD_PERM_DUMP;
+ ret = parasite_send_fd(ctl, fdset->fds[type]);
+ if (ret)
+ return ret;
+
return 0;
}
static int parasite_file_cmd(int cmd, int type,
struct parasite_ctl *ctl, struct cr_fdset *cr_fdset)
{
- struct parasite_dump_file_args args = { };
+ parasite_status_t args = { };
int status, ret = -1;
pr_info("\n");
pr_info("Dumping sigactions (pid: %d)\n", ctl->pid);
pr_info("----------------------------------------\n");
- ret = parasite_prep_file(type, &args, ctl, cr_fdset);
+ ret = parasite_prep_file(type, ctl, cr_fdset);
if (ret < 0)
goto out;
@@ -488,7 +488,7 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_a
pr_info("Dumping pages (type: %d pid: %d)\n", CR_FD_PAGES, ctl->pid);
pr_info("----------------------------------------\n");
- ret = parasite_prep_file(CR_FD_PAGES, ¶site_dumppages.fa, ctl, cr_fdset);
+ ret = parasite_prep_file(CR_FD_PAGES, ctl, cr_fdset);
if (ret < 0)
goto out;
@@ -519,9 +519,9 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_a
sizeof(parasite_dumppages));
if (ret) {
pr_panic("Dumping pages failed with %li (%li) at %li\n",
- parasite_dumppages.fa.status.ret,
- parasite_dumppages.fa.status.sys_ret,
- parasite_dumppages.fa.status.line);
+ parasite_dumppages.status.ret,
+ parasite_dumppages.status.sys_ret,
+ parasite_dumppages.status.line);
goto err_restore;
}
diff --git a/parasite.c b/parasite.c
index e353177..f1a2acb 100644
--- a/parasite.c
+++ b/parasite.c
@@ -94,27 +94,13 @@ static inline int should_dump_page(struct vma_entry *vmae, unsigned char mincore
#endif
}
-static int parasite_open_file(struct parasite_dump_file_args *fa)
-{
- int fd;
-
- fd = sys_open(fa->open_path, fa->open_flags, fa->open_mode);
- if (fd < 0) {
- sys_write_msg("sys_open failed\n");
- SET_PARASITE_STATUS(&fa->status, PARASITE_ERR_OPEN, fd);
- fd = fa->status.ret;
- }
-
- return fd;
-}
-
/*
* This is the main page dumping routine, it's executed
* inside a victim process space.
*/
static int dump_pages(struct parasite_dump_pages_args *args)
{
- parasite_status_t *st = &args->fa.status;
+ parasite_status_t *st = &args->status;
unsigned long nrpages, pfn, length;
unsigned long prot_old, prot_new;
unsigned char *map_brk = NULL;
@@ -126,7 +112,7 @@ static int dump_pages(struct parasite_dump_pages_args *args)
prot_old = prot_new = 0;
if (args->fd == -1UL) {
- ret = parasite_open_file(&args->fa);
+ ret = recv_fd(tsock);
if (ret < 0)
goto err;
@@ -241,16 +227,15 @@ err:
return ret;
}
-static int dump_sigact(struct parasite_dump_file_args *args)
+static int dump_sigact(parasite_status_t *st)
{
- parasite_status_t *st = &args->status;
rt_sigaction_t act;
struct sa_entry e;
int fd, sig;
int ret = PARASITE_ERR_FAIL;
- fd = parasite_open_file(args);
+ fd = recv_fd(tsock);
if (fd < 0)
return fd;
@@ -318,16 +303,15 @@ static int dump_itimer(int which, int fd, parasite_status_t *st)
return 0;
}
-static int dump_itimers(struct parasite_dump_file_args *args)
+static int dump_itimers(parasite_status_t *st)
{
- parasite_status_t *st = &args->status;
rt_sigaction_t act;
struct sa_entry e;
int fd, sig;
int ret = PARASITE_ERR_FAIL;
- fd = parasite_open_file(args);
+ fd = recv_fd(tsock);
if (fd < 0)
return fd;
@@ -398,7 +382,6 @@ static int __used parasite_service(unsigned long cmd, void *args, void *brk)
brk_init(brk);
BUILD_BUG_ON(sizeof(struct parasite_dump_pages_args) > PARASITE_ARG_SIZE);
- BUILD_BUG_ON(sizeof(struct parasite_dump_file_args) > PARASITE_ARG_SIZE);
switch (cmd) {
case PARASITE_CMD_PINGME:
@@ -412,9 +395,9 @@ static int __used parasite_service(unsigned long cmd, void *args, void *brk)
case PARASITE_CMD_DUMPPAGES:
return dump_pages((struct parasite_dump_pages_args *)args);
case PARASITE_CMD_DUMP_SIGACTS:
- return dump_sigact((struct parasite_dump_file_args *)args);
+ return dump_sigact((parasite_status_t *)args);
case PARASITE_CMD_DUMP_ITIMERS:
- return dump_itimers((struct parasite_dump_file_args *)args);
+ return dump_itimers((parasite_status_t *)args);
case PARASITE_CMD_DUMP_MISC:
return dump_misc((struct parasite_dump_misc *)args);
default:
More information about the CRIU
mailing list