[CRIU] [PATCH 3/6] actions: Add rpc notify with separate call

Pavel Emelyanov xemul at virtuozzo.com
Thu Apr 21 05:56:24 PDT 2016


This lets us clean the action-script.c eventually.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/action-scripts.c         | 21 +++++++++++++++++++--
 criu/cr-service.c             |  3 +--
 criu/crtools.c                |  2 +-
 criu/include/action-scripts.h |  5 ++---
 4 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/criu/action-scripts.c b/criu/action-scripts.c
index 691085f..4529767 100644
--- a/criu/action-scripts.c
+++ b/criu/action-scripts.c
@@ -32,6 +32,8 @@ struct script {
 
 static LIST_HEAD(scripts);
 
+#define SCRIPT_RPC_NOTIFY	(char *)0x1
+
 int run_scripts(enum script_actions act)
 {
 	struct script *script;
@@ -80,7 +82,7 @@ int run_scripts(enum script_actions act)
 	return ret;
 }
 
-int add_script(char *path, int arg)
+int add_script(char *path)
 {
 	struct script *script;
 
@@ -89,7 +91,22 @@ int add_script(char *path, int arg)
 		return 1;
 
 	script->path = path;
-	script->arg = arg;
+	script->arg = 0;
+	list_add(&script->node, &scripts);
+
+	return 0;
+}
+
+int add_rpc_notify(int sk)
+{
+	struct script *script;
+
+	script = xmalloc(sizeof(struct script));
+	if (script == NULL)
+		return 1;
+
+	script->path = SCRIPT_RPC_NOTIFY;
+	script->arg = sk;
 	list_add(&script->node, &scripts);
 
 	return 0;
diff --git a/criu/cr-service.c b/criu/cr-service.c
index ae4f0b5..219a986 100644
--- a/criu/cr-service.c
+++ b/criu/cr-service.c
@@ -361,8 +361,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
 		}
 	}
 
-	if (req->notify_scripts &&
-			add_script(SCRIPT_RPC_NOTIFY, sk))
+	if (req->notify_scripts && add_rpc_notify(sk))
 		goto err;
 
 	for (i = 0; i < req->n_veths; i++) {
diff --git a/criu/crtools.c b/criu/crtools.c
index de1f00c..7a0f977 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -465,7 +465,7 @@ int main(int argc, char *argv[], char *envp[])
 			}
 			break;
 		case 1049:
-			if (add_script(optarg, 0))
+			if (add_script(optarg))
 				return 1;
 
 			break;
diff --git a/criu/include/action-scripts.h b/criu/include/action-scripts.h
index e12fb0c..4d56300 100644
--- a/criu/include/action-scripts.h
+++ b/criu/include/action-scripts.h
@@ -1,8 +1,6 @@
 #ifndef __CR_ACTION_SCRIPTS_H__
 #define __CR_ACTION_SCRIPTS_H__
 
-#define SCRIPT_RPC_NOTIFY	(char *)0x1
-
 enum script_actions {
 	ACT_PRE_DUMP		= 0,
 	ACT_POST_DUMP		= 1,
@@ -17,7 +15,8 @@ enum script_actions {
 	ACT_MAX
 };
 
-extern int add_script(char *path, int arg);
+extern int add_script(char *path);
+extern int add_rpc_notify(int sk);
 extern int run_scripts(enum script_actions);
 extern int send_criu_rpc_script(enum script_actions act, char *name, int arg);
 
-- 
2.1.4



More information about the CRIU mailing list