[CRIU] [PATCH 6/7] parasite: Remove struct pid from parasite_ctl
Pavel Emelyanov
xemul at virtuozzo.com
Wed Sep 28 00:42:49 PDT 2016
Only real pid is used internally now.
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/arch/x86/crtools.c | 2 +-
criu/cr-dump.c | 4 ++--
criu/include/parasite-syscall.h | 2 +-
criu/parasite-syscall.c | 25 ++++++++++++-------------
4 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/criu/arch/x86/crtools.c b/criu/arch/x86/crtools.c
index 543a77e..2f9e2f8 100644
--- a/criu/arch/x86/crtools.c
+++ b/criu/arch/x86/crtools.c
@@ -634,7 +634,7 @@ void *mmap_seized(struct parasite_ctl *ctl,
if (IS_ERR_VALUE(map)) {
if (map == -EACCES && (prot & PROT_WRITE) && (prot & PROT_EXEC))
pr_warn("mmap(PROT_WRITE | PROT_EXEC) failed for %d, "
- "check selinux execmem policy\n", ctl->pid.real);
+ "check selinux execmem policy\n", ctl->rpid);
return NULL;
}
diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index a2611ee..b3a3b7c 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -1174,7 +1174,7 @@ static int pre_dump_one_task(struct pstree_item *item)
goto err_cure;
}
- parasite_ctl->pid.virt = item->pid.virt = misc.pid;
+ item->pid.virt = misc.pid;
mdc.pre_dump = true;
mdc.lazy = false;
@@ -1304,7 +1304,7 @@ static int dump_one_task(struct pstree_item *item)
goto err_cure_imgset;
}
- parasite_ctl->pid.virt = item->pid.virt = misc.pid;
+ item->pid.virt = misc.pid;
pstree_insert_pid(item->pid.virt, &item->pid);
item->sid = misc.sid;
item->pgid = misc.pgid;
diff --git a/criu/include/parasite-syscall.h b/criu/include/parasite-syscall.h
index ba6cf1c..77649d7 100644
--- a/criu/include/parasite-syscall.h
+++ b/criu/include/parasite-syscall.h
@@ -42,7 +42,7 @@ struct infect_ctx {
/* parasite control block */
struct parasite_ctl {
- struct pid pid;
+ int rpid; /* Real pid of the victim */
void *remote_map;
void *local_map;
void *sigreturn_addr; /* A place for the breakpoint */
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index c8dad01..fa83209 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -214,7 +214,7 @@ err:
int __parasite_execute_syscall(struct parasite_ctl *ctl,
user_regs_struct_t *regs, const char *code_syscall)
{
- pid_t pid = ctl->pid.real;
+ pid_t pid = ctl->rpid;
int err;
u8 code_orig[BUILTIN_SYSCALL_SIZE];
@@ -235,7 +235,7 @@ int __parasite_execute_syscall(struct parasite_ctl *ctl,
if (ptrace_poke_area(pid, (void *)code_orig,
(void *)ctl->ictx.syscall_ip, sizeof(code_orig))) {
- pr_err("Can't restore syscall blob (pid: %d)\n", ctl->pid.real);
+ pr_err("Can't restore syscall blob (pid: %d)\n", ctl->rpid);
err = -1;
}
@@ -506,7 +506,7 @@ static int accept_tsock(struct parasite_ctl *ctl)
static int parasite_init_daemon(struct parasite_ctl *ctl)
{
struct parasite_init_args *args;
- pid_t pid = ctl->pid.real;
+ pid_t pid = ctl->rpid;
user_regs_struct_t regs;
struct ctl_msg m = { };
@@ -962,7 +962,7 @@ static bool task_in_parasite(struct parasite_ctl *ctl, user_regs_struct_t *regs)
static int parasite_fini_seized(struct parasite_ctl *ctl)
{
- pid_t pid = ctl->pid.real;
+ pid_t pid = ctl->rpid;
user_regs_struct_t regs;
int status, ret = 0;
enum trace_flags flag;
@@ -1199,7 +1199,7 @@ int parasite_cure_local(struct parasite_ctl *ctl)
if (ctl->local_map) {
if (munmap(ctl->local_map, ctl->map_length)) {
- pr_err("munmap failed (pid: %d)\n", ctl->pid.real);
+ pr_err("munmap failed (pid: %d)\n", ctl->rpid);
ret = -1;
}
}
@@ -1227,7 +1227,7 @@ int parasite_cure_seized(struct parasite_ctl *ctl)
int parasite_unmap(struct parasite_ctl *ctl, unsigned long addr)
{
user_regs_struct_t regs = ctl->orig.regs;
- pid_t pid = ctl->pid.real;
+ pid_t pid = ctl->rpid;
int ret = -1;
ret = parasite_run(pid, PTRACE_SYSCALL, addr, ctl->rstack, ®s, &ctl->orig);
@@ -1265,8 +1265,7 @@ struct parasite_ctl *parasite_prep_ctl(pid_t pid)
if (get_thread_ctx(pid, &ctl->orig))
goto err;
- ctl->pid.real = pid;
- ctl->pid.virt = 0;
+ ctl->rpid = pid;
return ctl;
@@ -1283,13 +1282,13 @@ static int parasite_mmap_exchange(struct parasite_ctl *ctl, unsigned long size)
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_ANONYMOUS | MAP_SHARED, -1, 0);
if (!ctl->remote_map) {
- pr_err("Can't allocate memory for parasite blob (pid: %d)\n", ctl->pid.real);
+ pr_err("Can't allocate memory for parasite blob (pid: %d)\n", ctl->rpid);
return -1;
}
ctl->map_length = round_up(size, page_size());
- fd = open_proc_rw(ctl->pid.real, "map_files/%p-%p",
+ fd = open_proc_rw(ctl->rpid, "map_files/%p-%p",
ctl->remote_map, ctl->remote_map + ctl->map_length);
if (fd < 0)
return -1;
@@ -1311,7 +1310,7 @@ static int parasite_memfd_exchange(struct parasite_ctl *ctl, unsigned long size)
{
void *where = (void *)ctl->ictx.syscall_ip + BUILTIN_SYSCALL_SIZE;
u8 orig_code[MEMFD_FNAME_SZ] = MEMFD_FNAME;
- pid_t pid = ctl->pid.real;
+ pid_t pid = ctl->rpid;
unsigned long sret = -ENOSYS;
int ret, fd, lfd;
bool __maybe_unused compat_task = !seized_native(ctl);
@@ -1348,7 +1347,7 @@ static int parasite_memfd_exchange(struct parasite_ctl *ctl, unsigned long size)
return fd;
ctl->map_length = round_up(size, page_size());
- lfd = open_proc_rw(ctl->pid.real, "fd/%d", fd);
+ lfd = open_proc_rw(ctl->rpid, "fd/%d", fd);
if (lfd < 0)
goto err_cure;
@@ -1423,7 +1422,7 @@ void parasite_ensure_args_size(unsigned long sz)
static int parasite_start_daemon(struct parasite_ctl *ctl)
{
- pid_t pid = ctl->pid.real;
+ pid_t pid = ctl->rpid;
struct infect_ctx *ictx = &ctl->ictx;
/*
--
2.5.0
More information about the CRIU
mailing list