[CRIU] [RFC] mount: Add ability to c/r devtmpfs

Serge Hallyn serge.hallyn at ubuntu.com
Thu Oct 16 13:57:40 PDT 2014


Quoting Cyrill Gorcunov (gorcunov at openvz.org):
> Looking into experiments with OpenVZ kernel
> it seems plain tar over devtmpfs should be
> enough for a while. So here is a new option
> comes in "--devtmpfs-content".

Hi - so I'm pretty sure this is the case, but just want to make 100%
sure, and looking at the criu git HEAD didn't help me - when this
gets restore, it will be mounted as tmpfs right?  (not devtmpfs, I
hope?)

> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  crtools.c            |  5 +++++
>  include/cr_options.h |  1 +
>  lib/criu.c           |  6 ++++++
>  lib/criu.h           |  1 +
>  mount.c              | 16 ++++++++++++++++
>  protobuf/rpc.proto   |  1 +
>  6 files changed, 30 insertions(+)
> 
> diff --git a/crtools.c b/crtools.c
> index 0ac667cd8eda..196ac56a2502 100644
> --- a/crtools.c
> +++ b/crtools.c
> @@ -187,6 +187,7 @@ int main(int argc, char *argv[], char *envp[])
>  		{ "exec-cmd", no_argument, 0, 1059},
>  		{ "manage-cgroups", no_argument, 0, 1060},
>  		{ "cgroup-root", required_argument, 0, 1061},
> +		{ "devtmpfs-content", no_argument, 0, 1062},
>  		{ },
>  	};
>  
> @@ -392,6 +393,9 @@ int main(int argc, char *argv[], char *envp[])
>  					return -1;
>  			}
>  			break;
> +		case 1062:
> +			opts.devtmpfs_content = true;
> +			break;
>  		case 'M':
>  			{
>  				char *aux;
> @@ -604,6 +608,7 @@ usage:
>  "                        change the root cgroup the controller will be\n"
>  "                        installed into. No controller means that root is the\n"
>  "                        default for all controllers not specified.\n"
> +"  --devtmpfs-content    checkpoint/restore content of devtmpfs filesystem.\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 a9f9e92259e6..43d889c47ea7 100644
> --- a/include/cr_options.h
> +++ b/include/cr_options.h
> @@ -58,6 +58,7 @@ struct cr_options {
>  	char			*new_global_cg_root;
>  	struct list_head	new_cgroup_roots;
>  	bool			aufs;		/* auto-deteced, not via cli */
> +	bool			devtmpfs_content;
>  };
>  
>  extern struct cr_options opts;
> diff --git a/lib/criu.c b/lib/criu.c
> index ad419ba1a633..2fcc55fcc59d 100644
> --- a/lib/criu.c
> +++ b/lib/criu.c
> @@ -169,6 +169,12 @@ void criu_set_cpu_cap(unsigned int cap)
>  	opts->cpu_cap		= cap;
>  }
>  
> +void criu_set_devtmpfs_content(bool val)
> +{
> +	opts->has_devtmpfs_content	= true;
> +	opts->devtmpfs_content		= val;
> +}
> +
>  int criu_set_exec_cmd(int argc, char *argv[])
>  {
>  	int i;
> diff --git a/lib/criu.h b/lib/criu.h
> index 18f911eeaba6..b0cc633034ab 100644
> --- a/lib/criu.h
> +++ b/lib/criu.h
> @@ -46,6 +46,7 @@ void criu_set_link_remap(bool link_remap);
>  void criu_set_log_level(int log_level);
>  void criu_set_log_file(char *log_file);
>  void criu_set_cpu_cap(unsigned int cap);
> +void criu_set_devtmpfs_content(bool val);
>  void criu_set_root(char *root);
>  void criu_set_manage_cgroups(bool manage);
>  int criu_set_exec_cmd(int argc, char *argv[]);
> diff --git a/mount.c b/mount.c
> index a60c86e0f97b..d0dbdb31b791 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -729,6 +729,13 @@ out:
>  	return ret;
>  }
>  
> +static int devtmpfs_dump(struct mount_info *pm)
> +{
> +	if (!opts.devtmpfs_content)
> +		return 0;
> +	return tmpfs_dump(pm);
> +}
> +
>  static int tmpfs_restore(struct mount_info *pm)
>  {
>  	int ret;
> @@ -753,6 +760,13 @@ static int tmpfs_restore(struct mount_info *pm)
>  	return 0;
>  }
>  
> +static int devtmpfs_restore(struct mount_info *pm)
> +{
> +	if (!opts.devtmpfs_content)
> +		return 0;
> +	return tmpfs_restore(pm);
> +}
> +
>  static int binfmt_misc_dump(struct mount_info *pm)
>  {
>  	int fd, ret = -1;
> @@ -831,6 +845,8 @@ static struct fstype fstypes[] = {
>  	}, {
>  		.name = "devtmpfs",
>  		.code = FSTYPE__DEVTMPFS,
> +		.dump = devtmpfs_dump,
> +		.restore = devtmpfs_restore,
>  	}, {
>  		.name = "binfmt_misc",
>  		.code = FSTYPE__BINFMT_MISC,
> diff --git a/protobuf/rpc.proto b/protobuf/rpc.proto
> index d511512c5696..41e4b5706fa3 100644
> --- a/protobuf/rpc.proto
> +++ b/protobuf/rpc.proto
> @@ -55,6 +55,7 @@ message criu_opts {
>  	repeated cgroup_root		cg_root		= 25;
>  
>  	optional bool			rst_sibling	= 26; /* swrk only */
> +	optional bool			devtmpfs_content= 27;
>  }
>  
>  message criu_dump_resp {
> -- 
> 1.9.3
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list