Commit 043bf95f authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Cyrill Gorcunov

parasite: Arguments sanitation

Remove typedefs and make the common part of sigacts and pages dumping arguments
for dumping something into a specific file. Will be used almost as-is soon.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent ed3405cf
...@@ -56,22 +56,20 @@ typedef struct { ...@@ -56,22 +56,20 @@ typedef struct {
st->line = __LINE__; \ st->line = __LINE__; \
} while (0) } while (0)
typedef struct { struct parasite_dump_file_args {
parasite_status_t status; parasite_status_t status;
struct vma_entry vma_entry;
unsigned long nrpages_dumped; /* how many pages are dumped */
unsigned long fd;
unsigned long open_mode; unsigned long open_mode;
unsigned long open_flags; unsigned long open_flags;
char open_path[PATH_MAX]; char open_path[PATH_MAX];
} parasite_args_cmd_dumppages_t; };
typedef struct { struct parasite_dump_pages_args {
parasite_status_t status; struct parasite_dump_file_args fa;
unsigned long open_mode;
unsigned long open_flags; struct vma_entry vma_entry;
char open_path[PATH_MAX]; unsigned long nrpages_dumped; /* how many pages are dumped */
} parasite_args_cmd_dumpsigacts_t; unsigned long fd;
};
/* /*
* Some useful offsets * Some useful offsets
......
...@@ -343,8 +343,7 @@ err: ...@@ -343,8 +343,7 @@ err:
int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_fdset) int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_fdset)
{ {
parasite_args_cmd_dumpsigacts_t parasite_sigacts = { }; struct parasite_dump_file_args parasite_sigacts = { };
int status, ret = -1; int status, ret = -1;
pr_info("\n"); pr_info("\n");
...@@ -383,9 +382,7 @@ out: ...@@ -383,9 +382,7 @@ out:
int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_area_list, int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_area_list,
struct cr_fdset *cr_fdset) struct cr_fdset *cr_fdset)
{ {
parasite_args_cmd_dumppages_t parasite_dumppages = { }; struct parasite_dump_pages_args parasite_dumppages = { };
parasite_args_t parasite_arg = { };
user_regs_struct_t regs, regs_orig; user_regs_struct_t regs, regs_orig;
unsigned long nrpages_dumped = 0; unsigned long nrpages_dumped = 0;
struct vma_area *vma_area; struct vma_area *vma_area;
...@@ -396,8 +393,8 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_a ...@@ -396,8 +393,8 @@ 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("Dumping pages (type: %d pid: %d)\n", CR_FD_PAGES, ctl->pid);
pr_info("----------------------------------------\n"); pr_info("----------------------------------------\n");
if (get_image_path(parasite_dumppages.open_path, if (get_image_path(parasite_dumppages.fa.open_path,
sizeof(parasite_dumppages.open_path), sizeof(parasite_dumppages.fa.open_path),
fdset_template[CR_FD_PAGES].fmt, ctl->pid)) fdset_template[CR_FD_PAGES].fmt, ctl->pid))
goto out; goto out;
...@@ -412,9 +409,9 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_a ...@@ -412,9 +409,9 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_a
*/ */
fsync(cr_fdset->fds[CR_FD_PAGES]); fsync(cr_fdset->fds[CR_FD_PAGES]);
parasite_dumppages.open_flags = O_WRONLY; parasite_dumppages.fa.open_flags = O_WRONLY;
parasite_dumppages.open_mode = CR_FD_PERM_DUMP; parasite_dumppages.fa.open_mode = CR_FD_PERM_DUMP;
parasite_dumppages.fd = -1UL; parasite_dumppages.fd = -1UL;
list_for_each_entry(vma_area, vma_area_list, list) { list_for_each_entry(vma_area, vma_area_list, list) {
...@@ -437,9 +434,9 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_a ...@@ -437,9 +434,9 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct list_head *vma_a
sizeof(parasite_dumppages)); sizeof(parasite_dumppages));
if (ret) { if (ret) {
pr_panic("Dumping pages failed with %li (%li) at %li\n", pr_panic("Dumping pages failed with %li (%li) at %li\n",
parasite_dumppages.status.ret, parasite_dumppages.fa.status.ret,
parasite_dumppages.status.sys_ret, parasite_dumppages.fa.status.sys_ret,
parasite_dumppages.status.line); parasite_dumppages.fa.status.line);
goto err_restore; goto err_restore;
} }
......
...@@ -92,9 +92,9 @@ static inline int should_dump_page(struct vma_entry *vmae, unsigned char mincore ...@@ -92,9 +92,9 @@ static inline int should_dump_page(struct vma_entry *vmae, unsigned char mincore
* This is the main page dumping routine, it's executed * This is the main page dumping routine, it's executed
* inside a victim process space. * inside a victim process space.
*/ */
static int dump_pages(parasite_args_cmd_dumppages_t *args) static int dump_pages(struct parasite_dump_pages_args *args)
{ {
parasite_status_t *st = &args->status; parasite_status_t *st = &args->fa.status;
unsigned long nrpages, pfn, length; unsigned long nrpages, pfn, length;
unsigned long prot_old, prot_new; unsigned long prot_old, prot_new;
unsigned char *map_brk = NULL; unsigned char *map_brk = NULL;
...@@ -106,7 +106,7 @@ static int dump_pages(parasite_args_cmd_dumppages_t *args) ...@@ -106,7 +106,7 @@ static int dump_pages(parasite_args_cmd_dumppages_t *args)
prot_old = prot_new = 0; prot_old = prot_new = 0;
if (args->fd == -1UL) { if (args->fd == -1UL) {
args->fd = sys_open(args->open_path, args->open_flags, args->open_mode); args->fd = sys_open(args->fa.open_path, args->fa.open_flags, args->fa.open_mode);
if ((long)args->fd < 0) { if ((long)args->fd < 0) {
sys_write_msg("sys_open failed\n"); sys_write_msg("sys_open failed\n");
SET_PARASITE_STATUS(st, PARASITE_ERR_OPEN, args->fd); SET_PARASITE_STATUS(st, PARASITE_ERR_OPEN, args->fd);
...@@ -223,7 +223,7 @@ err: ...@@ -223,7 +223,7 @@ err:
return ret; return ret;
} }
static int dump_sigact(parasite_args_cmd_dumpsigacts_t *args) static int dump_sigact(struct parasite_dump_file_args *args)
{ {
parasite_status_t *st = &args->status; parasite_status_t *st = &args->status;
rt_sigaction_t act; rt_sigaction_t act;
...@@ -280,8 +280,8 @@ static int __used parasite_service(unsigned long cmd, void *args, void *brk) ...@@ -280,8 +280,8 @@ static int __used parasite_service(unsigned long cmd, void *args, void *brk)
{ {
brk_init(brk); brk_init(brk);
BUILD_BUG_ON(sizeof(parasite_args_cmd_dumppages_t) > PARASITE_ARG_SIZE); BUILD_BUG_ON(sizeof(struct parasite_dump_pages_args) > PARASITE_ARG_SIZE);
BUILD_BUG_ON(sizeof(parasite_args_cmd_dumpsigacts_t) > PARASITE_ARG_SIZE); BUILD_BUG_ON(sizeof(struct parasite_dump_file_args) > PARASITE_ARG_SIZE);
switch (cmd) { switch (cmd) {
case PARASITE_CMD_KILLME: case PARASITE_CMD_KILLME:
...@@ -290,10 +290,10 @@ static int __used parasite_service(unsigned long cmd, void *args, void *brk) ...@@ -290,10 +290,10 @@ static int __used parasite_service(unsigned long cmd, void *args, void *brk)
case PARASITE_CMD_PINGME: case PARASITE_CMD_PINGME:
break; break;
case PARASITE_CMD_DUMPPAGES: case PARASITE_CMD_DUMPPAGES:
return dump_pages((parasite_args_cmd_dumppages_t *)args); return dump_pages((struct parasite_dump_pages_args *)args);
break; break;
case PARASITE_CMD_DUMP_SIGACTS: case PARASITE_CMD_DUMP_SIGACTS:
return dump_sigact((parasite_args_cmd_dumpsigacts_t *)args); return dump_sigact((struct parasite_dump_file_args *)args);
break; break;
default: default:
sys_write_msg("Unknown command to parasite\n"); sys_write_msg("Unknown command to parasite\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment