[CRIU] [PATCH 4/5] mount: Make auto options into --external mnt

Pavel Emelyanov xemul at virtuozzo.com
Thu Oct 27 01:10:18 PDT 2016


On 10/27/2016 01:01 AM, Andrei Vagin wrote:
> On Tue, Oct 25, 2016 at 06:27:39PM +0300, Pavel Emelyanov wrote:
>> The syntax for --ext-mount-map auto is
>>
>> --external mnt[]{:ms}
>>
>> where optional 'm' means --enable-external-masters and optional
>> 's' means --enable-external-sharing.
> 
> We need to describe these options somewhere (usage, man, docs)

There's already usage test in this patch (minimal), there's an
article on the wiki (with yet empty "auto" section) and yes, man
pages are to be updated before this gets in into master.

>>
>> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
>>
>> ---
>>  criu/crtools.c       | 12 +-----------
>>  criu/external.c      |  6 ++++++
>>  criu/include/mount.h |  1 +
>>  criu/mount.c         | 21 +++++++++++++++++++++
>>  4 files changed, 29 insertions(+), 11 deletions(-)
>>
>> diff --git a/criu/crtools.c b/criu/crtools.c
>> index 8e35e67..026aa45 100644
>> --- a/criu/crtools.c
>> +++ b/criu/crtools.c
>> @@ -634,11 +634,6 @@ int main(int argc, char *argv[], char *envp[])
>>  		return 1;
>>  	}
>>  
>> -	if (!opts.autodetect_ext_mounts && (opts.enable_external_masters || opts.enable_external_sharing)) {
>> -		pr_msg("must specify --ext-mount-map auto with --enable-external-{sharing|masters}");
>> -		return 1;
>> -	}
>> -
>>  	if (opts.work_dir == NULL)
>>  		opts.work_dir = imgs_dir;
>>  
>> @@ -851,6 +846,7 @@ usage:
>>  "                            dev[maj:min]:VAL\n"
>>  "                            unix[ino]\n"
>>  "                            mnt[MOUNTPOINT]:COOKIE\n"
>> +"                            mnt[]{:AUTO_OPTIONS}\n"
>>  "                        Formats of RES on restore:\n"
>>  "                            dev[VAL]:DEVPATH\n"
>>  "                            veth[IFNAME]:OUTNAME{@BRIDGE}\n"
>> @@ -872,12 +868,6 @@ usage:
>>  "  --force-irmap         force resolving names for inotify/fsnotify watches\n"
>>  "  --irmap-scan-path FILE\n"
>>  "                        add a path the irmap hints to scan\n"
>> -"  -M|--ext-mount-map auto\n"
>> -"                        attempt to autodetect external mount mappings\n"
>> -"  --enable-external-sharing\n"
>> -"                        allow autoresolving mounts with external sharing\n"
>> -"  --enable-external-masters\n"
>> -"                        allow autoresolving mounts with external masters\n"
>>  "  --manage-cgroups [m]  dump/restore process' cgroups; argument can be one of\n"
>>  "                        'none', 'props', 'soft' (default), 'full' or 'strict'\n"
>>  "  --cgroup-root [controller:]/newroot\n"
>> diff --git a/criu/external.c b/criu/external.c
>> index 98547c5..6f2d5e9 100644
>> --- a/criu/external.c
>> +++ b/criu/external.c
>> @@ -2,6 +2,7 @@
>>  #include "common/list.h"
>>  #include "cr_options.h"
>>  #include "xmalloc.h"
>> +#include "mount.h"
>>  #include "external.h"
>>  #include "util.h"
>>  
>> @@ -21,6 +22,11 @@ int add_external(char *key)
>>  		return -1;
>>  	}
>>  
>> +	if (strstartswith(key, "mnt[]")) {
>> +		xfree(ext);
>> +		return ext_mount_parse_auto(key + 5);
>> +	}
>> +
>>  	list_add(&ext->node, &opts.external);
>>  
>>  	return 0;
>> diff --git a/criu/include/mount.h b/criu/include/mount.h
>> index c9a958a..798aa3e 100644
>> --- a/criu/include/mount.h
>> +++ b/criu/include/mount.h
>> @@ -105,6 +105,7 @@ extern int depopulate_roots_yard(int mntns_root, bool clean_remaps);
>>  
>>  extern int rst_get_mnt_root(int mnt_id, char *path, int plen);
>>  extern int ext_mount_add(char *key, char *val);
>> +extern int ext_mount_parse_auto(char *key);
>>  extern int mntns_maybe_create_roots(void);
>>  extern int read_mnt_ns_img(void);
>>  extern void cleanup_mnt_ns(void);
>> diff --git a/criu/mount.c b/criu/mount.c
>> index e3f33a4..30e7788 100644
>> --- a/criu/mount.c
>> +++ b/criu/mount.c
>> @@ -66,6 +66,27 @@ int ext_mount_add(char *key, char *val)
>>  	return add_external(e_str);
>>  }
>>  
>> +int ext_mount_parse_auto(char *key)
>> +{
>> +	opts.autodetect_ext_mounts = true;
>> +
>> +	if (*key == ':') {
>> +		while (1) {
>> +			key++;
>> +			if (*key == '\0')
>> +				break;
>> +			else if (*key == 'm')
>> +				opts.enable_external_masters = true;
>> +			else if (*key == 's')
>> +				opts.enable_external_sharing = true;
>> +			else
>> +				return -1;
>> +		}
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>>  /* Lookup ext_mount by key field */
>>  static char *ext_mount_lookup(char *key)
>>  {
>> -- 
>> 2.5.0
>>
>> _______________________________________________
>> CRIU mailing list
>> CRIU at openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu
> .
> 



More information about the CRIU mailing list