[CRIU] [PATCH 74/78] infect-rpc: Split into priv and uapi parts
Cyrill Gorcunov
gorcunov at openvz.org
Mon Nov 7 08:36:59 PST 2016
From: Pavel Emelyanov <xemul at virtuozzo.com>
Some pieces from infect-rpc are used by criu's pie code
which will soon be moved into compel std plugin itself,
so prepare for this.
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/include/infect-rpc.h | 46 +------------------------------------------
criu/include/rpc-pie-priv.h | 48 +++++++++++++++++++++++++++++++++++++++++++++
criu/infect-rpc.c | 3 +++
criu/infect.c | 1 +
criu/pie/infect.c | 1 +
5 files changed, 54 insertions(+), 45 deletions(-)
create mode 100644 criu/include/rpc-pie-priv.h
diff --git a/criu/include/infect-rpc.h b/criu/include/infect-rpc.h
index 1e34d83410f4..5f6cf684e8a5 100644
--- a/criu/include/infect-rpc.h
+++ b/criu/include/infect-rpc.h
@@ -11,50 +11,6 @@ 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);
extern int compel_rpc_sock(struct parasite_ctl *ctl);
-struct ctl_msg {
- uint32_t cmd; /* command itself */
- uint32_t ack; /* ack on command */
- int32_t err; /* error code on reply */
-};
-
-#define ctl_msg_cmd(_cmd) \
- (struct ctl_msg){.cmd = _cmd, }
-
-#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 {
- int32_t h_addr_len;
- struct sockaddr_un h_addr;
- int32_t log_level;
- uint64_t sigreturn_addr;
- uint64_t sigframe; /* pointer to sigframe */
- futex_t daemon_connected;
-};
-
-struct parasite_unmap_args {
- uint64_t parasite_start;
- uint64_t parasite_len;
-};
+#define PARASITE_USER_CMDS 64
#endif
diff --git a/criu/include/rpc-pie-priv.h b/criu/include/rpc-pie-priv.h
new file mode 100644
index 000000000000..3d9091159737
--- /dev/null
+++ b/criu/include/rpc-pie-priv.h
@@ -0,0 +1,48 @@
+#ifndef __COMPEL_RPC_H__
+#define __COMPEL_RPC_H__
+struct ctl_msg {
+ uint32_t cmd; /* command itself */
+ uint32_t ack; /* ack on command */
+ int32_t err; /* error code on reply */
+};
+
+#define ctl_msg_cmd(_cmd) \
+ (struct ctl_msg){.cmd = _cmd, }
+
+#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_END_CMDS,
+};
+
+struct parasite_init_args {
+ int32_t h_addr_len;
+ struct sockaddr_un h_addr;
+ int32_t log_level;
+ uint64_t sigreturn_addr;
+ uint64_t sigframe; /* pointer to sigframe */
+ futex_t daemon_connected;
+};
+
+struct parasite_unmap_args {
+ uint64_t parasite_start;
+ uint64_t parasite_len;
+};
+#endif
diff --git a/criu/infect-rpc.c b/criu/infect-rpc.c
index 0994bcb35a0a..265a4ad2f699 100644
--- a/criu/infect-rpc.c
+++ b/criu/infect-rpc.c
@@ -6,11 +6,14 @@
#include "infect.h"
#include "infect-priv.h"
#include "infect-rpc.h"
+#include "rpc-pie-priv.h"
static int __parasite_send_cmd(int sockfd, struct ctl_msg *m)
{
int ret;
+ BUILD_BUG_ON(PARASITE_USER_CMDS < __PARASITE_END_CMDS);
+
ret = send(sockfd, m, sizeof(*m), 0);
if (ret == -1) {
pr_perror("Failed to send command %d to daemon", m->cmd);
diff --git a/criu/infect.c b/criu/infect.c
index 94338c398ff8..8f8f6020a456 100644
--- a/criu/infect.c
+++ b/criu/infect.c
@@ -27,6 +27,7 @@
#include "infect-rpc.h"
#include "infect-priv.h"
#include "infect-util.h"
+#include "rpc-pie-priv.h"
#define UNIX_PATH_MAX (sizeof(struct sockaddr_un) - \
(size_t)((struct sockaddr_un *) 0)->sun_path)
diff --git a/criu/pie/infect.c b/criu/pie/infect.c
index 303b60b68ceb..d94fdaafc7af 100644
--- a/criu/pie/infect.c
+++ b/criu/pie/infect.c
@@ -8,6 +8,7 @@
#include "sigframe.h"
#include "infect-rpc.h"
#include "infect-pie.h"
+#include "rpc-pie-priv.h"
static int tsock = -1;
--
2.7.4
More information about the CRIU
mailing list