[CRIU] [PATCH 3/3] scripts: Use numeric action val in RPC notifications

Pavel Emelyanov xemul at parallels.com
Wed Sep 3 12:44:03 PDT 2014


Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 action-scripts.c         |  2 +-
 cr-service.c             | 10 +++++++---
 include/action-scripts.h |  1 +
 include/cr-service.h     |  1 -
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/action-scripts.c b/action-scripts.c
index c247ca9..19920f1 100644
--- a/action-scripts.c
+++ b/action-scripts.c
@@ -42,7 +42,7 @@ int run_scripts(enum script_actions act)
 	list_for_each_entry(script, &opts.scripts, node) {
 		if (script->path == SCRIPT_RPC_NOTIFY) {
 			pr_debug("\tRPC\n");
-			ret |= send_criu_rpc_script(action, script->arg);
+			ret |= send_criu_rpc_script(act, action, script->arg);
 		} else {
 			pr_debug("\t[%s]\n", script->path);
 			ret |= system(script->path);
diff --git a/cr-service.c b/cr-service.c
index ca741a0..d1d4325 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -129,7 +129,7 @@ int send_criu_restore_resp(int socket_fd, bool success, int pid)
 	return send_criu_msg(socket_fd, &msg);
 }
 
-int send_criu_rpc_script(char *script, int fd)
+int send_criu_rpc_script(enum script_actions act, char *name, int fd)
 {
 	int ret;
 	CriuResp msg = CRIU_RESP__INIT;
@@ -139,9 +139,10 @@ int send_criu_rpc_script(char *script, int fd)
 	msg.type = CRIU_REQ_TYPE__NOTIFY;
 	msg.success = true;
 	msg.notify = &cn;
-	cn.script = script;
+	cn.script = name;
 
-	if (!strcmp(script, "setup-namespaces")) {
+	switch (act) {
+	case ACT_SETUP_NS:
 		/*
 		 * FIXME pid is required only once on
 		 * restore. Need some more sane way of
@@ -149,6 +150,9 @@ int send_criu_rpc_script(char *script, int fd)
 		 */
 		cn.has_pid = true;
 		cn.pid = root_item->pid.real;
+		break;
+	default:
+		break;
 	}
 
 	ret = send_criu_msg(fd, &msg);
diff --git a/include/action-scripts.h b/include/action-scripts.h
index d8b4724..f7aceaf 100644
--- a/include/action-scripts.h
+++ b/include/action-scripts.h
@@ -19,5 +19,6 @@ enum script_actions {
 
 extern int add_script(char *path, int arg);
 extern int run_scripts(enum script_actions);
+extern int send_criu_rpc_script(enum script_actions act, char *name, int arg);
 
 #endif /* __CR_ACTION_SCRIPTS_H__ */
diff --git a/include/cr-service.h b/include/cr-service.h
index eadc0c3..621cedbe 100644
--- a/include/cr-service.h
+++ b/include/cr-service.h
@@ -7,7 +7,6 @@ extern int cr_service(bool deamon_mode);
 int cr_service_work(int sk);
 
 extern int send_criu_dump_resp(int socket_fd, bool success, bool restored);
-extern int send_criu_rpc_script(char *name, int arg);
 
 extern struct _cr_service_client *cr_service_client;
 extern unsigned int service_sk_ino;
-- 
1.8.4.2




More information about the CRIU mailing list