[CRIU] [PATCH 5/9] parasite: add simplified version of parasite_prep_ctl

Andrey Vagin avagin at openvz.org
Thu Sep 12 09:24:37 EDT 2013


The simplified version of parasite_prep_ctl doesn't search a place for
system call code, which is injected for mapping a parasite blob.

It will be used for unmaping a restorer blob and this blob will contain
all required code for unmapping itself.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/parasite-syscall.h |  1 +
 parasite-syscall.c         | 21 +++++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h
index 3515a30..cb07cb0 100644
--- a/include/parasite-syscall.h
+++ b/include/parasite-syscall.h
@@ -115,4 +115,5 @@ extern int parasite_fixup_vdso(struct parasite_ctl *ctl, pid_t pid,
 			       struct vm_area_list *vma_area_list);
 
 extern int parasite_stop_on_syscall(int tasks, int sys_nr);
+extern struct parasite_ctl *__parasite_prep_ctl(pid_t pid);
 #endif /* __CR_PARASITE_SYSCALL_H__ */
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 14ec058..baec7bb 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -887,10 +887,9 @@ int parasite_cure_seized(struct parasite_ctl *ctl)
 	return ret;
 }
 
-struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct vm_area_list *vma_area_list)
+struct parasite_ctl *__parasite_prep_ctl(pid_t pid)
 {
 	struct parasite_ctl *ctl = NULL;
-	struct vma_area *vma_area;
 
 	if (!arch_can_dump_task(pid))
 		goto err;
@@ -905,6 +904,7 @@ struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct vm_area_list *vma_area_
 	}
 
 	ctl->tsock = -1;
+	ctl->pid.real	= pid;
 
 	if (ptrace(PTRACE_GETSIGMASK, pid, sizeof(k_rtsigset_t), &ctl->sig_blocked)) {
 		pr_perror("ptrace doesn't support PTRACE_GETSIGMASK\n");
@@ -916,6 +916,21 @@ struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct vm_area_list *vma_area_
 		goto err;
 	}
 
+	return ctl;
+err:
+	xfree(ctl);
+	return NULL;
+}
+
+struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct vm_area_list *vma_area_list)
+{
+	struct vma_area *vma_area;
+	struct parasite_ctl *ctl;
+
+	ctl = __parasite_prep_ctl(pid);
+	if (ctl == NULL)
+		return NULL;
+
 	vma_area = get_vma_by_ip(&vma_area_list->h, REG_IP(ctl->regs_orig));
 	if (!vma_area) {
 		pr_err("No suitable VMA found to run parasite "
@@ -923,8 +938,6 @@ struct parasite_ctl *parasite_prep_ctl(pid_t pid, struct vm_area_list *vma_area_
 		goto err;
 	}
 
-	ctl->pid.real	= pid;
-	ctl->pid.virt	= 0;
 	ctl->syscall_ip	= vma_area->vma.start;
 
 	return ctl;
-- 
1.8.3.1



More information about the CRIU mailing list