[CRIU] [PATCH v4] cr-restore: set NS_PID environment variable before "post-resume" hook

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Tue Apr 12 02:50:38 PDT 2016


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 at virtuozzo.com>
---
 criu/action-scripts.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/criu/action-scripts.c b/criu/action-scripts.c
index b1f7952..a6a11bf 100644
--- a/criu/action-scripts.c
+++ b/criu/action-scripts.c
@@ -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");



More information about the CRIU mailing list