Commit 1b544845 authored by Pavel Emelyanov's avatar Pavel Emelyanov

parasite: Split parasite cure routine into local and remote parts

For pre-dump we'll need to cure the target task(s), but keep the
parasite_ctl (for its local args mapping) for memory image write.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 6161208a
......@@ -54,6 +54,8 @@ extern int parasite_drain_fds_seized(struct parasite_ctl *ctl,
extern int parasite_get_proc_fd_seized(struct parasite_ctl *ctl);
struct pstree_item;
extern int parasite_cure_remote(struct parasite_ctl *ctl, struct pstree_item *item);
extern int parasite_cure_local(struct parasite_ctl *ctl);
extern int parasite_cure_seized(struct parasite_ctl *ctl, struct pstree_item *item);
extern struct parasite_ctl *parasite_infect_seized(pid_t pid,
struct pstree_item *item,
......
......@@ -582,7 +582,7 @@ int parasite_fini_threads_seized(struct parasite_ctl *ctl, struct pstree_item *i
return ret;
}
int parasite_cure_seized(struct parasite_ctl *ctl, struct pstree_item *item)
int parasite_cure_remote(struct parasite_ctl *ctl, struct pstree_item *item)
{
int ret = 0;
......@@ -601,13 +601,6 @@ int parasite_cure_seized(struct parasite_ctl *ctl, struct pstree_item *item)
}
}
if (ctl->local_map) {
if (munmap(ctl->local_map, ctl->map_length)) {
pr_err("munmap failed (pid: %d)\n", ctl->pid.real);
ret = -1;
}
}
if (ptrace_poke_area(ctl->pid.real, (void *)ctl->code_orig,
(void *)ctl->syscall_ip, sizeof(ctl->code_orig))) {
pr_err("Can't restore syscall blob (pid: %d)\n", ctl->pid.real);
......@@ -619,10 +612,35 @@ int parasite_cure_seized(struct parasite_ctl *ctl, struct pstree_item *item)
ret = -1;
}
return ret;
}
int parasite_cure_local(struct parasite_ctl *ctl)
{
int ret = 0;
if (ctl->local_map) {
if (munmap(ctl->local_map, ctl->map_length)) {
pr_err("munmap failed (pid: %d)\n", ctl->pid.real);
ret = -1;
}
}
free(ctl);
return ret;
}
int parasite_cure_seized(struct parasite_ctl *ctl, struct pstree_item *item)
{
int ret;
ret = parasite_cure_remote(ctl, item);
if (!ret)
ret = parasite_cure_local(ctl);
return ret;
}
struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct vm_area_list *vma_area_list)
{
struct parasite_ctl *ctl = NULL;
......
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