[CRIU] [PATCH 10/15] crtools: move all stuff about vma together

Andrey Vagin avagin at openvz.org
Mon Nov 4 22:00:32 PST 2013


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 arch/arm/vdso-pie.c |  1 +
 arch/x86/vdso-pie.c |  1 +
 arch/x86/vdso.c     |  2 +-
 cr-dump.c           |  1 +
 cr-exec.c           |  1 +
 cr-restore.c        |  1 +
 include/crtools.h   | 34 ----------------------------------
 include/image.h     |  4 ----
 include/sk-queue.h  |  5 -----
 include/vma.h       | 41 +++++++++++++++++++++++++++++++++++++++++
 mem.c               |  1 +
 parasite-syscall.c  |  1 +
 pie/restorer.c      |  1 +
 proc_parse.c        |  1 +
 shmem.c             |  2 ++
 sk-packet.c         |  2 +-
 util.c              |  2 ++
 17 files changed, 56 insertions(+), 45 deletions(-)
 create mode 100644 include/vma.h

diff --git a/arch/arm/vdso-pie.c b/arch/arm/vdso-pie.c
index ed7413c..1f094cb 100644
--- a/arch/arm/vdso-pie.c
+++ b/arch/arm/vdso-pie.c
@@ -1,6 +1,7 @@
 #include <sys/types.h>
 
 #include "vdso.h"
+#include "vma.h"
 #include "log.h"
 
 #ifdef LOG_PREFIX
diff --git a/arch/x86/vdso-pie.c b/arch/x86/vdso-pie.c
index 778e84a..c96360b 100644
--- a/arch/x86/vdso-pie.c
+++ b/arch/x86/vdso-pie.c
@@ -15,6 +15,7 @@
 #include "compiler.h"
 #include "crtools.h"
 #include "vdso.h"
+#include "vma.h"
 #include "log.h"
 
 #ifdef LOG_PREFIX
diff --git a/arch/x86/vdso.c b/arch/x86/vdso.c
index d879eef..1beac24 100644
--- a/arch/x86/vdso.c
+++ b/arch/x86/vdso.c
@@ -15,12 +15,12 @@
 #include "parasite-syscall.h"
 #include "parasite.h"
 #include "compiler.h"
-#include "crtools.h"
 #include "kerndat.h"
 #include "vdso.h"
 #include "util.h"
 #include "log.h"
 #include "mem.h"
+#include "vma.h"
 
 #ifdef LOG_PREFIX
 # undef LOG_PREFIX
diff --git a/cr-dump.c b/cr-dump.c
index 8666f7e..68c80d6 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -66,6 +66,7 @@
 #include "page-pipe.h"
 #include "posix-timer.h"
 #include "vdso.h"
+#include "vma.h"
 #include "cr-service.h"
 
 #include "asm/dump.h"
diff --git a/cr-exec.c b/cr-exec.c
index 1bf616b..c333816 100644
--- a/cr-exec.c
+++ b/cr-exec.c
@@ -3,6 +3,7 @@
 #include "crtools.h"
 #include "ptrace.h"
 #include "parasite-syscall.h"
+#include "vma.h"
 
 struct syscall_exec_desc {
 	char *name;
diff --git a/cr-restore.c b/cr-restore.c
index fab01d5..fe8fdab 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -63,6 +63,7 @@
 #include "vdso.h"
 #include "stats.h"
 #include "tun.h"
+#include "vma.h"
 #include "kerndat.h"
 
 #include "parasite-syscall.h"
diff --git a/include/crtools.h b/include/crtools.h
index a48e785..87b6f3e 100644
--- a/include/crtools.h
+++ b/include/crtools.h
@@ -111,34 +111,6 @@ struct cr_fdset *cr_glob_fdset_open(int mode);
 
 void close_cr_fdset(struct cr_fdset **cr_fdset);
 
-struct vm_area_list {
-	struct list_head	h;
-	unsigned		nr;
-	unsigned long		priv_size; /* nr of pages in private VMAs */
-	unsigned long		longest; /* nr of pages in longest VMA */
-};
-
-#define VM_AREA_LIST(name)	struct vm_area_list name = { .h = LIST_HEAD_INIT(name.h), .nr = 0, }
-
-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;
-	VmaEntry		vma;
-
-	union {
-		int		vm_file_fd;
-		int		vm_socket_id;
-	};
-	unsigned long		*page_bitmap;  /* existent pages */
-	unsigned long		*ppage_bitmap; /* parent's existent pages */
-};
-
-#define vma_area_is(vma_area, s)	vma_entry_is(&((vma_area)->vma), s)
-#define vma_area_len(vma_area)		vma_entry_len(&((vma_area)->vma))
-
 struct fdt {
 	int			nr;		/* How many tasks share this fd table */
 	pid_t			pid;		/* Who should restore this fd table */
@@ -171,12 +143,6 @@ struct rst_info {
 	};
 };
 
-static inline int in_vma_area(struct vma_area *vma, unsigned long addr)
-{
-	return addr >= (unsigned long)vma->vma.start &&
-		addr < (unsigned long)vma->vma.end;
-}
-
 /*
  * When we have to restore a shared resource, we mush select which
  * task should do it, and make other(s) wait for it. In order to
diff --git a/include/image.h b/include/image.h
index 862aaf0..cd2da87 100644
--- a/include/image.h
+++ b/include/image.h
@@ -49,10 +49,6 @@
 #define VMA_AREA_SYSVIPC	(1 <<  10)
 #define VMA_AREA_SOCKET		(1 <<  11)
 
-#define vma_premmaped_start(vma) ((vma)->shmid)
-#define vma_entry_is(vma, s)	(((vma)->status & (s)) == (s))
-#define vma_entry_len(vma)	((vma)->end - (vma)->start)
-
 #define CR_CAP_SIZE	2
 
 #define TASK_COMM_LEN 16
diff --git a/include/sk-queue.h b/include/sk-queue.h
index 4a82571..9044de0 100644
--- a/include/sk-queue.h
+++ b/include/sk-queue.h
@@ -1,11 +1,6 @@
 #ifndef __CR_SK_QUEUE_H__
 #define __CR_SK_QUEUE_H__
 
-#include "asm/types.h"
-#include "list.h"
-#include "crtools.h"
-#include "image.h"
-
 extern int read_sk_queues(void);
 extern int dump_sk_queue(int sock_fd, int sock_id);
 extern int restore_sk_queue(int fd, unsigned int peer_id);
diff --git a/include/vma.h b/include/vma.h
new file mode 100644
index 0000000..e85fc46
--- /dev/null
+++ b/include/vma.h
@@ -0,0 +1,41 @@
+#ifndef __CR_VMA_H__
+#define __CR_VMA_H__
+
+struct vm_area_list {
+	struct list_head	h;
+	unsigned		nr;
+	unsigned long		priv_size; /* nr of pages in private VMAs */
+	unsigned long		longest; /* nr of pages in longest VMA */
+};
+
+#define VM_AREA_LIST(name)	struct vm_area_list name = { .h = LIST_HEAD_INIT(name.h), .nr = 0, }
+
+struct vma_area {
+	struct list_head	list;
+	VmaEntry		vma;
+
+	union {
+		int		vm_file_fd;
+		int		vm_socket_id;
+	};
+	unsigned long		*page_bitmap;  /* existent pages */
+	unsigned long		*ppage_bitmap; /* parent's existent pages */
+};
+
+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);
+
+#define vma_area_is(vma_area, s)	vma_entry_is(&((vma_area)->vma), s)
+#define vma_area_len(vma_area)		vma_entry_len(&((vma_area)->vma))
+#define vma_premmaped_start(vma)	((vma)->shmid)
+#define vma_entry_is(vma, s)		(((vma)->status & (s)) == (s))
+#define vma_entry_len(vma)		((vma)->end - (vma)->start)
+
+static inline int in_vma_area(struct vma_area *vma, unsigned long addr)
+{
+	return addr >= (unsigned long)vma->vma.start &&
+		addr < (unsigned long)vma->vma.end;
+}
+
+#endif
diff --git a/mem.c b/mem.c
index 5d53ed1..bebd938 100644
--- a/mem.c
+++ b/mem.c
@@ -13,6 +13,7 @@
 #include "log.h"
 #include "kerndat.h"
 #include "stats.h"
+#include "vma.h"
 
 #include "protobuf.h"
 #include "protobuf/pagemap.pb-c.h"
diff --git a/parasite-syscall.c b/parasite-syscall.c
index 05aaf07..9c1071b 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -25,6 +25,7 @@
 #include "posix-timer.h"
 #include "net.h"
 #include "mem.h"
+#include "vma.h"
 #include "proc_parse.h"
 
 #include <string.h>
diff --git a/pie/restorer.c b/pie/restorer.c
index 6937223..3f93109 100644
--- a/pie/restorer.c
+++ b/pie/restorer.c
@@ -20,6 +20,7 @@
 #include "util.h"
 #include "image.h"
 #include "sk-inet.h"
+#include "vma.h"
 
 #include "crtools.h"
 #include "lock.h"
diff --git a/proc_parse.c b/proc_parse.c
index ea59cf7..a333716 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -21,6 +21,7 @@
 #include "posix-timer.h"
 #include "kerndat.h"
 #include "vdso.h"
+#include "vma.h"
 
 #include "proc_parse.h"
 #include "protobuf.h"
diff --git a/shmem.c b/shmem.c
index 5778bf4..eb24203 100644
--- a/shmem.c
+++ b/shmem.c
@@ -7,6 +7,8 @@
 #include "crtools.h"
 #include "page-pipe.h"
 #include "page-xfer.h"
+#include "vma.h"
+
 #include "protobuf.h"
 #include "protobuf/pagemap.pb-c.h"
 
diff --git a/sk-packet.c b/sk-packet.c
index aa64056..dcc7af3 100644
--- a/sk-packet.c
+++ b/sk-packet.c
@@ -4,13 +4,13 @@
 #include <linux/rtnetlink.h>
 #include <unistd.h>
 #include <string.h>
-#include "crtools.h"
 #include "asm/types.h"
 #include "files.h"
 #include "sockets.h"
 #include "libnetlink.h"
 #include "sk-packet.h"
 #include "packet_diag.h"
+#include "vma.h"
 
 #include "protobuf.h"
 #include "protobuf/packet-sock.pb-c.h"
diff --git a/util.c b/util.c
index 26798cc..9b0792d 100644
--- a/util.c
+++ b/util.c
@@ -35,6 +35,8 @@
 #include "asm/types.h"
 #include "list.h"
 #include "util.h"
+#include "image.h"
+#include "vma.h"
 
 #include "crtools.h"
 #include "servicefd.h"
-- 
1.8.3.1



More information about the CRIU mailing list