[CRIU] [PATCH 4/9] vma: Helper, that checks whether vma is dumped via parasite

Pavel Emelyanov xemul at parallels.com
Fri Mar 1 11:03:07 EST 2013


Signed-off-by: Pavel Emelyanov <xemul at parallels.com>

---
 cr-dump.c          | 31 +++++++++++++++++++++++++++++++
 include/crtools.h  |  1 +
 parasite-syscall.c | 26 +-------------------------
 3 files changed, 33 insertions(+), 25 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index f9032b1..f02e370 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -62,6 +62,37 @@
 static char loc_buf[PAGE_SIZE];
 static int pidns_proc = -1;
 
+bool privately_dump_vma(struct vma_area *vma)
+{
+	/*
+	 * The special areas are not dumped.
+	 */
+	if (!(vma->vma.status & VMA_AREA_REGULAR))
+		return false;
+
+	/* No dumps for file-shared mappings */
+	if (vma->vma.status & VMA_FILE_SHARED)
+		return false;
+
+	/* No dumps for SYSV IPC mappings */
+	if (vma->vma.status & VMA_AREA_SYSVIPC)
+		return false;
+
+	if (vma_area_is(vma, VMA_ANON_SHARED))
+		return false;
+
+	if (!vma_area_is(vma, VMA_ANON_PRIVATE) &&
+			!vma_area_is(vma, VMA_FILE_PRIVATE)) {
+		pr_warn("Unexpected VMA area found\n");
+		return false;
+	}
+
+	if (vma->vma.end > TASK_SIZE)
+		return false;
+
+	return true;
+}
+
 void free_mappings(struct vm_area_list *vma_area_list)
 {
 	struct vma_area *vma_area, *p;
diff --git a/include/crtools.h b/include/crtools.h
index 0bcac32..bd922e0 100644
--- a/include/crtools.h
+++ b/include/crtools.h
@@ -225,6 +225,7 @@ struct vm_area_list {
 
 int collect_mappings(pid_t pid, struct vm_area_list *vma_area_list);
 void free_mappings(struct vm_area_list *vma_area_list);
+bool privately_dump_vma(struct vma_area *vma);
 
 struct vma_area {
 	struct list_head	list;
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 066ed2e..5bfa12f 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -511,33 +511,9 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl, struct vm_area_list *vm
 	parasite_dumppages = parasite_args(ctl, struct parasite_dump_pages_args);
 
 	list_for_each_entry(vma_area, &vma_area_list->h, list) {
-
-		/*
-		 * The special areas are not dumped.
-		 */
-		if (!(vma_area->vma.status & VMA_AREA_REGULAR))
-			continue;
-
-		/* No dumps for file-shared mappings */
-		if (vma_area->vma.status & VMA_FILE_SHARED)
-			continue;
-
-		/* No dumps for SYSV IPC mappings */
-		if (vma_area->vma.status & VMA_AREA_SYSVIPC)
-			continue;
-
-		if (vma_area_is(vma_area, VMA_ANON_SHARED))
-			continue;
-
 		parasite_dumppages->vma_entry = vma_area->vma;
 
-		if (!vma_area_is(vma_area, VMA_ANON_PRIVATE) &&
-		    !vma_area_is(vma_area, VMA_FILE_PRIVATE)) {
-			pr_warn("Unexpected VMA area found\n");
-			continue;
-		}
-
-		if (vma_area->vma.end > TASK_SIZE)
+		if (!privately_dump_vma(vma_area))
 			continue;
 
 		ret = parasite_execute(PARASITE_CMD_DUMPPAGES, ctl);
-- 
1.7.11.7


More information about the CRIU mailing list