[CRIU] [PATCH 5/6] actions: Move shell scripts into helper
Pavel Emelyanov
xemul at virtuozzo.com
Thu Apr 21 05:57:05 PDT 2016
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/action-scripts.c | 41 +++++++++++++++++++++++++++--------------
1 file changed, 27 insertions(+), 14 deletions(-)
diff --git a/criu/action-scripts.c b/criu/action-scripts.c
index bd5c094..01c6a02 100644
--- a/criu/action-scripts.c
+++ b/criu/action-scripts.c
@@ -39,25 +39,13 @@ static int scripts_mode = SCRIPTS_NONE;
static int rpc_sk;
static LIST_HEAD(scripts);
-int run_scripts(enum script_actions act)
+static int run_shell_scripts(const char *action)
{
- struct script *script;
int ret = 0;
+ struct script *script;
char image_dir[PATH_MAX];
- const char *action = action_names[act];
char root_item_pid[16];
- pr_debug("Running %s scripts\n", action);
-
- if (scripts_mode == SCRIPTS_NONE)
- return 0;
-
- if (scripts_mode == SCRIPTS_RPC) {
- pr_debug("\tRPC\n");
- ret = send_criu_rpc_script(act, (char *)action, rpc_sk);
- goto out;
- }
-
if (setenv("CRTOOLS_SCRIPT_ACTION", action, 1)) {
pr_perror("Can't set CRTOOLS_SCRIPT_ACTION=%s", action);
return -1;
@@ -84,6 +72,31 @@ int run_scripts(enum script_actions act)
unsetenv("CRTOOLS_SCRIPT_ACTION");
+ return ret;
+}
+
+int run_scripts(enum script_actions act)
+{
+ int ret = 0;
+ const char *action = action_names[act];
+
+ pr_debug("Running %s scripts\n", action);
+
+ if (scripts_mode == SCRIPTS_NONE)
+ return 0;
+
+ if (scripts_mode == SCRIPTS_RPC) {
+ pr_debug("\tRPC\n");
+ ret = send_criu_rpc_script(act, (char *)action, rpc_sk);
+ goto out;
+ }
+
+ if (scripts_mode == SCRIPTS_SHELL) {
+ ret = run_shell_scripts(action);
+ goto out;
+ }
+
+ BUG();
out:
if (ret)
pr_err("One of more action scripts failed\n");
--
2.1.4
More information about the CRIU
mailing list