Commit 17d44de9 authored by Pavel Emelyanov's avatar Pavel Emelyanov

scripts: Use numeric script names

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 069bdd96
...@@ -11,11 +11,20 @@ ...@@ -11,11 +11,20 @@
#include "cr-service.h" #include "cr-service.h"
#include "action-scripts.h" #include "action-scripts.h"
int run_scripts(char *action) static char *action_names[] = {
[ ACT_POST_DUMP ] = "post-dump",
[ ACT_POST_RESTORE ] = "post-restore",
[ ACT_NET_LOCK ] = "network-lock",
[ ACT_NET_UNLOCK ] = "network-unlock",
[ ACT_SETUP_NS ] = "setup-namespaces",
};
int run_scripts(enum script_actions act)
{ {
struct script *script; struct script *script;
int ret = 0; int ret = 0;
char image_dir[PATH_MAX]; char image_dir[PATH_MAX];
char *action = action_names[act];
pr_debug("Running %s scripts\n", action); pr_debug("Running %s scripts\n", action);
......
...@@ -1873,7 +1873,7 @@ err: ...@@ -1873,7 +1873,7 @@ err:
* Thus ask user via script if we're to break * Thus ask user via script if we're to break
* checkpoint. * checkpoint.
*/ */
post_dump_ret = run_scripts("post-dump"); post_dump_ret = run_scripts(ACT_POST_DUMP);
if (post_dump_ret) { if (post_dump_ret) {
post_dump_ret = WEXITSTATUS(post_dump_ret); post_dump_ret = WEXITSTATUS(post_dump_ret);
pr_info("Post dump script passed with %d\n", post_dump_ret); pr_info("Post dump script passed with %d\n", post_dump_ret);
......
...@@ -1680,7 +1680,7 @@ static int restore_root_task(struct pstree_item *init) ...@@ -1680,7 +1680,7 @@ static int restore_root_task(struct pstree_item *init)
if (ret) if (ret)
goto out; goto out;
ret = run_scripts("setup-namespaces"); ret = run_scripts(ACT_SETUP_NS);
if (ret) if (ret)
goto out; goto out;
...@@ -1700,7 +1700,7 @@ static int restore_root_task(struct pstree_item *init) ...@@ -1700,7 +1700,7 @@ static int restore_root_task(struct pstree_item *init)
if (ret < 0) if (ret < 0)
goto out_kill; goto out_kill;
ret = run_scripts("post-restore"); ret = run_scripts(ACT_POST_RESTORE);
if (ret != 0) { if (ret != 0) {
pr_err("Aborting restore due to script ret code %d\n", ret); pr_err("Aborting restore due to script ret code %d\n", ret);
timing_stop(TIME_RESTORE); timing_stop(TIME_RESTORE);
......
...@@ -9,6 +9,15 @@ struct script { ...@@ -9,6 +9,15 @@ struct script {
#define SCRIPT_RPC_NOTIFY (char *)0x1 #define SCRIPT_RPC_NOTIFY (char *)0x1
enum script_actions {
ACT_POST_DUMP,
ACT_POST_RESTORE,
ACT_NET_LOCK,
ACT_NET_UNLOCK,
ACT_SETUP_NS,
};
extern int add_script(char *path, int arg); extern int add_script(char *path, int arg);
extern int run_scripts(char *action); extern int run_scripts(enum script_actions);
#endif /* __CR_ACTION_SCRIPTS_H__ */ #endif /* __CR_ACTION_SCRIPTS_H__ */
...@@ -592,7 +592,7 @@ int network_lock(void) ...@@ -592,7 +592,7 @@ int network_lock(void)
if (!(root_ns_mask & CLONE_NEWNET)) if (!(root_ns_mask & CLONE_NEWNET))
return 0; return 0;
return run_scripts("network-lock"); return run_scripts(ACT_NET_LOCK);
} }
void network_unlock(void) void network_unlock(void)
...@@ -603,7 +603,7 @@ void network_unlock(void) ...@@ -603,7 +603,7 @@ void network_unlock(void)
rst_unlock_tcp_connections(); rst_unlock_tcp_connections();
if (root_ns_mask & CLONE_NEWNET) if (root_ns_mask & CLONE_NEWNET)
run_scripts("network-unlock"); run_scripts(ACT_NET_UNLOCK);
} }
int veth_pair_add(char *in, char *out) int veth_pair_add(char *in, char *out)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment