[CRIU] [PATCH 04/15] shmem: don't include restorer.h in shmem.c

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


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/bug.h      |  1 +
 include/restorer.h | 40 +---------------------------------------
 include/shmem.h    | 40 ++++++++++++++++++++++++++++++++++++++++
 shmem.c            |  1 -
 4 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/include/bug.h b/include/bug.h
index 920abda..8330fed 100644
--- a/include/bug.h
+++ b/include/bug.h
@@ -3,6 +3,7 @@
 
 #include <signal.h>
 
+#include "compiler.h"
 #include "log.h"
 
 #ifndef BUG_ON_HANDLER
diff --git a/include/restorer.h b/include/restorer.h
index 247ac2b..f810d81 100644
--- a/include/restorer.h
+++ b/include/restorer.h
@@ -15,6 +15,7 @@
 #include "asm/restorer.h"
 
 #include "posix-timer.h"
+#include "shmem.h"
 #include "vdso.h"
 
 #include <time.h>
@@ -143,8 +144,6 @@ struct task_restore_core_args {
 	unsigned long			vdso_rt_parked_at;	/* safe place to keep vdso */
 } __aligned(sizeof(long));
 
-#define SHMEMS_SIZE	4096
-
 #define RESTORE_ALIGN_STACK(start, size)	\
 	(ALIGN((start) + (size) - sizeof(long), sizeof(long)))
 
@@ -153,28 +152,6 @@ static inline unsigned long restorer_stack(struct thread_restore_args *a)
 	return RESTORE_ALIGN_STACK((long)a->mem_zone.stack, RESTORE_STACK_SIZE);
 }
 
-/*
- * pid is a pid of a creater
- * start, end are used for open mapping
- * fd is a file discriptor, which is valid for creater,
- * it's opened in cr-restor, because pgoff may be non zero
- */
-
-struct shmem_info {
-	unsigned long	shmid;
-	unsigned long	start;
-	unsigned long	end;
-	unsigned long	size;
-	int		pid;
-	int		fd;
-	futex_t		lock;
-};
-
-struct shmems {
-	int			nr_shmems;
-	struct shmem_info	entries[0];
-};
-
 #define TASK_ENTRIES_SIZE 4096
 
 enum {
@@ -200,21 +177,6 @@ struct task_entries {
 	mutex_t	zombie_lock;
 };
 
-static always_inline struct shmem_info *
-find_shmem(struct shmems *shmems, unsigned long shmid)
-{
-	struct shmem_info *si;
-	int i;
-
-	for (i = 0; i < shmems->nr_shmems; i++) {
-		si = &shmems->entries[i];
-		if (si->shmid == shmid)
-			return si;
-	}
-
-	return NULL;
-}
-
 #define restore_finish_stage(__stage) ({				\
 		futex_dec_and_wake(&task_entries->nr_in_progress);	\
 		futex_wait_while(&task_entries->start, __stage);	\
diff --git a/include/shmem.h b/include/shmem.h
index f6ee3e2..b722982 100644
--- a/include/shmem.h
+++ b/include/shmem.h
@@ -1,8 +1,33 @@
 #ifndef __CR_SHMEM_H__
 #define __CR_SHMEM_H__
 
+#include "lock.h"
+
 #include "protobuf/vma.pb-c.h"
 
+#define SHMEMS_SIZE	4096
+
+/*
+ * pid is a pid of a creater
+ * start, end are used for open mapping
+ * fd is a file discriptor, which is valid for creater,
+ * it's opened in cr-restor, because pgoff may be non zero
+ */
+struct shmem_info {
+	unsigned long	shmid;
+	unsigned long	start;
+	unsigned long	end;
+	unsigned long	size;
+	int		pid;
+	int		fd;
+	futex_t		lock;
+};
+
+struct shmems {
+	int			nr_shmems;
+	struct shmem_info	entries[0];
+};
+
 int prepare_shmem_pid(int pid);
 int prepare_shmem_restore(void);
 void show_saved_shmems(void);
@@ -14,4 +39,19 @@ extern struct shmems *rst_shmems;
 int cr_dump_shmem(void);
 int add_shmem_area(pid_t pid, VmaEntry *vma);
 
+static always_inline struct shmem_info *
+find_shmem(struct shmems *shmems, unsigned long shmid)
+{
+	struct shmem_info *si;
+	int i;
+
+	for (i = 0; i < shmems->nr_shmems; i++) {
+		si = &shmems->entries[i];
+		if (si->shmid == shmid)
+			return si;
+	}
+
+	return NULL;
+}
+
 #endif /* __CR_SHMEM_H__ */
diff --git a/shmem.c b/shmem.c
index 769dc30..5778bf4 100644
--- a/shmem.c
+++ b/shmem.c
@@ -5,7 +5,6 @@
 #include "shmem.h"
 #include "image.h"
 #include "crtools.h"
-#include "restorer.h"
 #include "page-pipe.h"
 #include "page-xfer.h"
 #include "protobuf.h"
-- 
1.8.3.1



More information about the CRIU mailing list