[CRIU] [PATCH 41/78] infect: Remove parasite.h from infect.c

Cyrill Gorcunov gorcunov at openvz.org
Mon Nov 7 08:36:26 PST 2016


From: Pavel Emelyanov <xemul at virtuozzo.com>

This header describes CRIU parasite code, it has nothing
to do with infect, so remove it.

To do this we need to:

* Detach infect RPC commands from criu-parasite ones
* Move parasite_init_args and parasite_unmap_args into infect
* Move PARASITE_AREA_MIN into infect
* Hiding PARASITE_STACK_SIZE-s in infect
* Hiding parasite symbols resolvers in infect

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/include/infect-rpc.h | 39 +++++++++++++++++++++++++++++++++++++++
 criu/include/infect.h     |  2 ++
 criu/include/parasite.h   | 42 ++----------------------------------------
 criu/infect-rpc.c         |  4 +++-
 criu/infect.c             | 12 +++++++++++-
 5 files changed, 57 insertions(+), 42 deletions(-)

diff --git a/criu/include/infect-rpc.h b/criu/include/infect-rpc.h
index fd03a096721a..e03c8f136704 100644
--- a/criu/include/infect-rpc.h
+++ b/criu/include/infect-rpc.h
@@ -1,5 +1,10 @@
 #ifndef __COMPEL_INFECT_RPC_H__
 #define __COMPEL_INFECT_RPC_H__
+
+#include <sys/socket.h>
+#include <sys/un.h>
+
+struct parasite_ctl;
 extern int compel_rpc_sync(unsigned int cmd, struct parasite_ctl *ctl);
 extern int compel_rpc_call(unsigned int cmd, struct parasite_ctl *ctl);
 extern int compel_rpc_call_sync(unsigned int cmd, struct parasite_ctl *ctl);
@@ -17,4 +22,38 @@ struct ctl_msg {
 #define ctl_msg_ack(_cmd, _err)	\
 	(struct ctl_msg){.cmd = _cmd, .ack = _cmd, .err = _err, }
 
+/*
+ * NOTE: each command's args should be arch-independed sized.
+ * If you want to use one of the standard types, declare
+ * alternative type for compatible tasks in parasite-compat.h
+ */
+enum {
+	PARASITE_CMD_IDLE		= 0,
+	PARASITE_CMD_ACK,
+
+	PARASITE_CMD_INIT_DAEMON,
+	PARASITE_CMD_UNMAP,
+
+	/*
+	 * This must be greater than INITs.
+	 */
+	PARASITE_CMD_FINI,
+
+	PARASITE_USER_CMDS,
+};
+
+struct parasite_init_args {
+	s32				h_addr_len;
+	struct sockaddr_un		h_addr;
+	s32				log_level;
+	u64				sigreturn_addr;
+	u64				sigframe; /* pointer to sigframe */
+	futex_t				daemon_connected;
+};
+
+struct parasite_unmap_args {
+	u64		parasite_start;
+	u64		parasite_len;
+};
+
 #endif
diff --git a/criu/include/infect.h b/criu/include/infect.h
index 46d4691dfac9..6d4c5d392850 100644
--- a/criu/include/infect.h
+++ b/criu/include/infect.h
@@ -4,6 +4,8 @@
 #include "types.h"
 #include "compel/include/uapi/ksigset.h"
 
+#define PARASITE_START_AREA_MIN	(4096)
+
 extern int compel_stop_task(int pid);
 
 struct seize_task_status {
diff --git a/criu/include/parasite.h b/criu/include/parasite.h
index f7daa095371f..37734c7e8411 100644
--- a/criu/include/parasite.h
+++ b/criu/include/parasite.h
@@ -1,9 +1,6 @@
 #ifndef __CR_PARASITE_H__
 #define __CR_PARASITE_H__
 
-#define PARASITE_STACK_SIZE	(16 << 10)
-#define PARASITE_START_AREA_MIN	(4096)
-
 #define PARASITE_MAX_SIZE	(64 << 10)
 
 #ifndef __ASSEMBLY__
@@ -16,30 +13,15 @@
 #include "image.h"
 #include "util-pie.h"
 #include "lock.h"
+#include "infect-rpc.h"
 
 #include "images/vma.pb-c.h"
 #include "images/tty.pb-c.h"
 
 #define __head __used __section(.head.text)
 
-/*
- * NOTE: each command's args should be arch-independed sized.
- * If you want to use one of the standard types, declare
- * alternative type for compatible tasks in parasite-compat.h
- */
 enum {
-	PARASITE_CMD_IDLE		= 0,
-	PARASITE_CMD_ACK,
-
-	PARASITE_CMD_INIT_DAEMON,
-	PARASITE_CMD_DUMP_THREAD,
-	PARASITE_CMD_UNMAP,
-
-	/*
-	 * This must be greater than INITs.
-	 */
-	PARASITE_CMD_FINI,
-
+	PARASITE_CMD_DUMP_THREAD = PARASITE_USER_CMDS,
 	PARASITE_CMD_MPROTECT_VMAS,
 	PARASITE_CMD_DUMPPAGES,
 
@@ -57,20 +39,6 @@ enum {
 	PARASITE_CMD_MAX,
 };
 
-struct parasite_init_args {
-	s32				h_addr_len;
-	struct sockaddr_un		h_addr;
-	s32				log_level;
-	u64				sigreturn_addr;
-	u64				sigframe; /* pointer to sigframe */
-	futex_t				daemon_connected;
-};
-
-struct parasite_unmap_args {
-	u64		parasite_start;
-	u64		parasite_len;
-};
-
 struct parasite_vma_entry
 {
 	u64		start;
@@ -257,12 +225,6 @@ struct parasite_dump_cgroup_args {
 	char contents[1 << 12];
 };
 
-/* the parasite prefix is added by gen_offsets.sh */
-#define __pblob_offset(ptype, symbol)					\
-	parasite_ ## ptype ## _blob_offset__ ## symbol
-#define parasite_sym(pblob, ptype, symbol)				\
-	((void *)(pblob) + __pblob_offset(ptype, symbol))
-
 #endif /* !__ASSEMBLY__ */
 
 #include "parasite-compat.h"
diff --git a/criu/infect-rpc.c b/criu/infect-rpc.c
index 51b9132ca077..73d963def166 100644
--- a/criu/infect-rpc.c
+++ b/criu/infect-rpc.c
@@ -1,7 +1,9 @@
 #include "xmalloc.h"
 #include "types.h"
-#include "parasite.h"
 #include "parasite-syscall.h"
+#include "log.h"
+#include "common/bug.h"
+#include "lock.h"
 #include "infect.h"
 #include "infect-priv.h"
 #include "infect-rpc.h"
diff --git a/criu/infect.c b/criu/infect.c
index 3c1b220d9d07..90a10493c3a6 100644
--- a/criu/infect.c
+++ b/criu/infect.c
@@ -11,7 +11,6 @@
 #include "asm/parasite-syscall.h"
 #include "asm/dump.h"
 #include "restorer.h"
-#include "parasite.h"
 #include "parasite-syscall.h"
 #include "pie-relocs.h"
 #include "parasite-blob.h"
@@ -20,6 +19,11 @@
 #include "infect-rpc.h"
 #include "infect-priv.h"
 
+#define UNIX_PATH_MAX (sizeof(struct sockaddr_un) - \
+			(size_t)((struct sockaddr_un *) 0)->sun_path)
+
+#define PARASITE_STACK_SIZE	(16 << 10)
+
 #define PTRACE_EVENT_STOP	128
 
 #ifndef SECCOMP_MODE_DISABLED
@@ -721,6 +725,12 @@ int compel_map_exchange(struct parasite_ctl *ctl, unsigned long size)
 	return ret;
 }
 
+/* the parasite prefix is added by gen_offsets.sh */
+#define __pblob_offset(ptype, symbol)					\
+	parasite_ ## ptype ## _blob_offset__ ## symbol
+#define parasite_sym(pblob, ptype, symbol)				\
+	((void *)(pblob) + __pblob_offset(ptype, symbol))
+
 #define init_parasite_ctl(ctl, blob_type)				\
 	do {								\
 	memcpy(ctl->local_map, parasite_##blob_type##_blob,		\
-- 
2.7.4



More information about the CRIU mailing list