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: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
Stanislav Kinsburskiy 2016-04-12 12:50:00 +03:00 committed by Pavel Emelyanov
parent 2ab599398d
commit 40b68eb405

View file

@ -29,6 +29,7 @@ int run_scripts(enum script_actions act)
int ret = 0;
char image_dir[PATH_MAX];
const char *action = action_names[act];
char root_item_pid[16];
pr_debug("Running %s scripts\n", action);
@ -46,6 +47,12 @@ int run_scripts(enum script_actions act)
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) {
if (script->path == SCRIPT_RPC_NOTIFY) {
pr_debug("\tRPC\n");