[CRIU] [PATCH] mnt: disable the use of pivot_root in case of ramdisk

Andrew Vagin avagin at odin.com
Thu Oct 29 03:55:08 PDT 2015


On Mon, Oct 26, 2015 at 11:01:11PM +0100, Ismaël FEZZAZ wrote:
> Signed-off-by: Ismael Fezzaz <i.fezzaz at gmail.com>
> ---
>  crtools.c            |  5 +++++
>  include/cr_options.h |  1 +
>  mount.c              | 19 +++++++++++++++++++
>  3 files changed, 25 insertions(+)
> 
> diff --git a/crtools.c b/crtools.c
> index d3812a1..6d60421 100644
> --- a/crtools.c
> +++ b/crtools.c
> @@ -253,6 +253,7 @@ int main(int argc, char *argv[], char *envp[])
>          { "freeze-cgroup",        required_argument,    0, 1068 },
>          { "ghost-limit",        required_argument,    0, 1069 },
>          { "irmap-scan-path",        required_argument,    0, 1070 },
> +        { "ramdisk",            no_argument,        0, 1071 },
>          { },
>      };
> 
> @@ -498,6 +499,9 @@ int main(int argc, char *argv[], char *envp[])
>              if (irmap_scan_path_add(optarg))
>                  return -1;
>              break;
> +        case 10701:
> +            opts.ramdisk = true;
> +            break;
>          case 'M':
>              {
>                  char *aux;
> @@ -747,6 +751,7 @@ usage:
>  "  --enable-fs FSNAMES   a comma separated list of filesystem names
> or \"all\".\n"
>  "                        force criu to (try to) dump/restore these
> filesystem's\n"
>  "                        mountpoints even if fs is not supported.\n"
> +"  --ramdisk             disable 'pivot_root'.\n"
>  "\n"
>  "* Logging:\n"
>  "  -o|--log-file FILE    log file name\n"
> diff --git a/include/cr_options.h b/include/cr_options.h
> index eac7283..eb89076 100644
> --- a/include/cr_options.h
> +++ b/include/cr_options.h
> @@ -95,6 +95,7 @@ struct cr_options {
>      bool            overlayfs;
>      size_t            ghost_limit;
>      struct list_head    irmap_scan_paths;
> +    bool            ramdisk;
>  };
> 
>  extern struct cr_options opts;
> diff --git a/mount.c b/mount.c
> index aea9807..b8f1b26 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -2246,6 +2246,25 @@ static int cr_pivot_root(char *root)
>          }
>      }
> 
> +    if (opts.ramdisk) {
> +        if (mount(".", "/", NULL, MS_MOVE, NULL)) {

How do you test this code? Can you try to execute our tests?
./test/zdtm.sh ns/user/static/env00

This command execute only one test in a container. And you can execute
./test/zdtm.sh without arguments to execute all tests.

I think the previous mount will fail if a target process lives in a
separate userns, because this mount will be locked.

Thanks a lot.

> +            pr_perror("moving . to / failed");
> +            return -1;
> +        }
> +
> +        if (chroot(".")) {
> +            pr_perror("chroot . failed");
> +            return -1;
> +        }
> +
> +        if (chdir("/")) {
> +            pr_perror("chdir / failed");
> +            return -1;
> +        }
> +
> +        return 0;
> +    }
> +
>      if (mkdtemp(put_root) == NULL) {
>          pr_perror("Can't create a temporary directory");
>          return -1;
> -- 
> 1.9.1
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list