[CRIU] [PATCH vv 3/3] cr-restore: set NS_PID environment variable before "post-resume" hook
Stanislav Kinsburskiy
skinsbursky at virtuozzo.com
Thu Apr 7 02:59:42 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 10e8097..382c0a7 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) {
@@ -2195,6 +2196,13 @@ static int restore_root_task(struct pstree_item *init)
write_stats(RESTORE_STATS);
+ 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