[Devel] [PATCH criu 2/3] action-scripts: Export mount namespace roots via CRIU_MNT_NS_ROOTS

Cyrill Gorcunov gorcunov at gmail.com
Thu Oct 12 10:21:30 MSK 2017


In particular we need to process filesystem to restore
ploop device migration, thus export roots and the script
can use CRTOOLS_INIT_PID together with nsenter to step
into prepared file systems and whatever needed.

https://jira.sw.ru/browse/PSBM-71861

Signed-off-by: Cyrill Gorcunov <gorcunov 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 a07f560..137980c 100644
--- a/criu/action-scripts.c
+++ b/criu/action-scripts.c
@@ -16,6 +16,7 @@
 #include <sys/un.h>
 #include <sys/socket.h>
 #include "common/scm.h"
+#include "mount.h"
 #include "spfs.h"
 
 static const char *action_names[ACT_MAX] = {
@@ -76,6 +77,7 @@ static int run_shell_scripts(const char *action)
 		return -1;
 
 	if (!(env_set & ENV_ROOTPID) && root_item) {
+		char mnt_ns_roots[PATH_MAX];
 		int pid;
 		char root_item_pid[16];
 
@@ -86,6 +88,11 @@ static int run_shell_scripts(const char *action)
 				pr_perror("Can't set CRTOOLS_INIT_PID=%s", root_item_pid);
 				return -1;
 			}
+			export_mnt_ns_roots(mnt_ns_roots, sizeof(mnt_ns_roots));
+			if (setenv("CRIU_MNT_NS_ROOTS", mnt_ns_roots, 1)) {
+				pr_perror("Can't set CRIU_MNT_ROOTS=%s", mnt_ns_roots);
+				return -1;
+			}
 			env_set |= ENV_ROOTPID;
 		}
 	}
-- 
2.7.5



More information about the Devel mailing list