[CRIU] [PATCH v2 3/3] cr-restore: set NS_PID environment variable before "post-resume" hook
Stanislav Kinsburskiy
skinsbursky at virtuozzo.com
Wed Apr 6 03:09:06 PDT 2016
The only one (so far) "post-resume" script needs some pid to join its
namespaces. Let it be containers root.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
criu/cr-restore.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 2b11b71..834d606 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1995,6 +1995,7 @@ static int restore_root_task(struct pstree_item *init)
enum trace_flags flag = TRACE_ALL;
int ret, fd, mnt_ns_fd = -1;
int clean_remaps = 1;
+ char root_item_pid[16];
ret = run_scripts(ACT_PRE_RESTORE);
if (ret != 0) {
@@ -2198,6 +2199,13 @@ static int restore_root_task(struct pstree_item *init)
if (!opts.restore_detach && !opts.exec_cmd)
wait(NULL);
+ snprintf(root_item_pid, sizeof(root_item_pid), "%d", root_item->pid.real);
+
+ if (setenv("NS_PID", root_item_pid, 1)) {
+ pr_perror("Can't set NS_PID=%s", root_item_pid);
+ return -1;
+ }
+
ret = run_scripts(ACT_POST_RESUME);
if (ret != 0)
pr_err("Post-resume script ret code %d\n", ret);
More information about the CRIU
mailing list