[CRIU] [PATCH 2/2] headers: Move vma_priv into vma.h

Cyrill Gorcunov gorcunov at openvz.org
Wed Feb 25 07:42:40 PST 2015


This allows us to reuse this helper on both
sides: dump and restore.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-dump.c          | 34 ++++------------------------------
 include/restorer.h |  4 ----
 include/vma.h      |  6 ++++++
 3 files changed, 10 insertions(+), 34 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index cc524558989a..922dc602abe5 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -84,37 +84,11 @@ static char loc_buf[PAGE_SIZE];
 bool privately_dump_vma(struct vma_area *vma)
 {
 	/*
-	 * The special areas are not dumped.
+	 * We only dump contents for regular areas which
+	 * lay inside user address space and consists of
+	 * private data.
 	 */
-	if (!(vma->e->status & VMA_AREA_REGULAR))
-		return false;
-
-	/* No dumps for file-shared mappings */
-	if (vma->e->status & VMA_FILE_SHARED)
-		return false;
-
-	/* No dumps for SYSV IPC mappings */
-	if (vma->e->status & VMA_AREA_SYSVIPC)
-		return false;
-
-#ifdef CONFIG_VDSO
-	/* No dumps for vDSO VVAR data */
-	if (vma->e->status & VMA_AREA_VVAR)
-		return false;
-#endif
-	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->e->end > TASK_SIZE)
-		return false;
-
-	return true;
+	return (vma_priv(vma->e) && vma->e->end <= TASK_SIZE);
 }
 
 static void close_vma_file(struct vma_area *vma)
diff --git a/include/restorer.h b/include/restorer.h
index 746810583477..ded084a522df 100644
--- a/include/restorer.h
+++ b/include/restorer.h
@@ -197,8 +197,4 @@ enum {
 /* the restorer_blob_offset__ prefix is added by gen_offsets.sh */
 #define restorer_sym(rblob, name)	((void *)(rblob) + restorer_blob_offset__##name)
 
-#define vma_priv(vma) ((vma_entry_is(vma, VMA_AREA_REGULAR)) &&	\
-			(vma_entry_is(vma, VMA_ANON_PRIVATE) || \
-			vma_entry_is(vma, VMA_FILE_PRIVATE)))
-
 #endif /* __CR_RESTORER_H__ */
diff --git a/include/vma.h b/include/vma.h
index 878658cae342..b09ef37f8814 100644
--- a/include/vma.h
+++ b/include/vma.h
@@ -76,6 +76,12 @@ extern bool privately_dump_vma(struct vma_area *vma);
 #define vma_entry_is(vma, s)		(((vma)->status & (s)) == (s))
 #define vma_entry_len(vma)		((vma)->end - (vma)->start)
 
+/* Test if the area contents should be dumped/restored */
+#define vma_priv(vma)					\
+	(vma_entry_is(vma, VMA_AREA_REGULAR) &&		\
+	 (vma_entry_is(vma, VMA_ANON_PRIVATE) ||	\
+	  vma_entry_is(vma, VMA_FILE_PRIVATE)))
+
 /*
  * vma_premmaped_start() can be used only in restorer.
  * In other cases vma_area->premmaped_addr must be used.
-- 
1.9.3



More information about the CRIU mailing list