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

Andrei Vagin avagin at gmail.com
Tue Oct 24 01:30:25 MSK 2017


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

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 at openvz.org
> https://lists.openvz.org/mailman/listinfo/devel


More information about the Devel mailing list