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

Submitted by Cyrill Gorcunov on Oct. 12, 2017, 7:21 a.m.

Details

Message ID 1507792891-27221-3-git-send-email-gorcunov@virtuozzo.com
State New
Series "Adjust ploop device naming on migration"
Headers show

Commit Message

Cyrill Gorcunov Oct. 12, 2017, 7:21 a.m.
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@virtuozzo.com>
---
 criu/action-scripts.c | 7 +++++++
 1 file changed, 7 insertions(+)

Patch hide | download patch | download mbox

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;
 		}
 	}

Comments

Andrei Vagin Oct. 23, 2017, 10:30 p.m.
On Thu, Oct 12, 2017 at 10:21:30AM +0300, Cyrill Gorcunov wrote:
> 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@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];

Should it be declared in a block where it is initialized?

>  		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;
> +			}

I don't like the idea to transfer mnt_ns_roots for all scripts with
ENV_ROOTPID.

It has a meaning only for post-namespace

>  			env_set |= ENV_ROOTPID;
>  		}
>  	}
> -- 
> 2.7.5
> 
> _______________________________________________
> Devel mailing list
> Devel@openvz.org
> https://lists.openvz.org/mailman/listinfo/devel
Cyrill Gorcunov Oct. 24, 2017, 7:13 a.m.
On Mon, Oct 23, 2017 at 03:30:25PM -0700, Andrei Vagin wrote:
> > @@ -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];
> 
> Should it be declared in a block where it is initialized?

OK

> 
> >  		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;
> > +			}
> 
> I don't like the idea to transfer mnt_ns_roots for all scripts with
> ENV_ROOTPID.
> 
> It has a meaning only for post-namespace

Will rework.