Commit 40b68eb4 authored by Stanislav Kinsburskiy's avatar Stanislav Kinsburskiy Committed by Pavel Emelyanov

cr-restore: set NS_PID environment variable before "post-resume" hook

The only one (so far) "post-resume" script needs some pid to join its
namespaces. Let it be containers root.

v4:
1) Enviroonment setup has been was moved to run_scripts
2) Environment variable NS_PID was renamed to CRTOOLS_INIT_PID
Signed-off-by: 's avatarStanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 2ab59939
...@@ -29,6 +29,7 @@ int run_scripts(enum script_actions act) ...@@ -29,6 +29,7 @@ int run_scripts(enum script_actions act)
int ret = 0; int ret = 0;
char image_dir[PATH_MAX]; char image_dir[PATH_MAX];
const char *action = action_names[act]; const char *action = action_names[act];
char root_item_pid[16];
pr_debug("Running %s scripts\n", action); pr_debug("Running %s scripts\n", action);
...@@ -46,6 +47,12 @@ int run_scripts(enum script_actions act) ...@@ -46,6 +47,12 @@ int run_scripts(enum script_actions act)
return -1; return -1;
} }
snprintf(root_item_pid, sizeof(root_item_pid), "%d", root_item->pid.real);
if (setenv("CRTOOLS_INIT_PID", root_item_pid, 1)) {
pr_perror("Can't set CRTOOLS_INIT_PID=%s", root_item_pid);
return -1;
}
list_for_each_entry(script, &opts.scripts, node) { list_for_each_entry(script, &opts.scripts, node) {
if (script->path == SCRIPT_RPC_NOTIFY) { if (script->path == SCRIPT_RPC_NOTIFY) {
pr_debug("\tRPC\n"); pr_debug("\tRPC\n");
......
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