[CRIU] [PATCH 2/4] mount: add support for external block devices

Pavel Emelyanov xemul at virtuozzo.com
Tue Apr 19 22:04:19 PDT 2016


On 04/19/2016 05:59 PM, Andrew Vagin wrote:
> On Tue, Apr 19, 2016 at 01:19:48PM +0300, Pavel Emelyanov wrote:
>> On 04/19/2016 03:44 AM, Andrew Vagin wrote:
>>> On Mon, Apr 18, 2016 at 07:36:52PM +0300, Pavel Emelyanov wrote:
>>>> On 04/15/2016 01:19 AM, Andrey Vagin wrote:
>>>>> From: Andrew Vagin <avagin at virtuozzo.com>
>>>>>
>>>>> It works like enable-fs, in this case we allow to mount a specified block device.
>>>>>
>>>>> Options:
>>>>> dump:		--external mnt[MAJOR:MINOR]
>>>>> restore:	--mnt-ext-map mnt[MAJOR:MINOR]:DEVPATH
>>>>
>>>> We don't have --mnt-ext-map option :\
>>>
>>> I mean --ext-mount-map
>>>>
>>>> Please, explain what the option arguments mean.
>>
>> Please, explain what the option arguments mean.
> 
> We save major and minor numbers for each mount, then on restore
> we can say that DEVPATH should be mounted instead of the origin device.

OK. It looks like you're trying to screw up the --ext-mount-map option.
Can we make the --external one work on both sides instead?

> For external devices, we call mount() with options, file system and
> flags which have been parsed from mountinfo during dump. The behaviour
> is the same with enabled file systems, but we can change the source
> argument.
> 
> int mount(const char *source, const char *target,
>                  const char *filesystemtype, unsigned long mountflags,
>                  const void *data);
> 
> 
>>
>>>>> https://jira.sw.ru/browse/PSBM-39381
>>>>>
>>>>> Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
>>>>> ---
>>>>>  criu/crtools.c    |  1 +
>>>>>  criu/mount.c      | 11 +++++++++++
>>>>>  criu/proc_parse.c | 10 ++++++++++
>>>>>  3 files changed, 22 insertions(+)
>>>>>
>>>>> diff --git a/criu/crtools.c b/criu/crtools.c
>>>>> index 02a24e7..3598b1b 100644
>>>>> --- a/criu/crtools.c
>>>>> +++ b/criu/crtools.c
>>>>> @@ -882,6 +882,7 @@ usage:
>>>>>  "                        Formats of RES:\n"
>>>>>  "                            tty[rdev:dev]\n"
>>>>>  "                            file[mnt_id:inode]\n"
>>>>> +"                            mnt[MAJOR/MINOR]\n"
>>>>>  "  --inherit-fd fd[<num>]:<existing>\n"
>>>>>  "                        Inherit file descriptors. This allows to treat file descriptor\n"
>>>>>  "                        <num> as being already opened via <existing> one and instead of\n"
>>>>> diff --git a/criu/mount.c b/criu/mount.c
>>>>> index f57b10c..85eeeda 100644
>>>>> --- a/criu/mount.c
>>>>> +++ b/criu/mount.c
>>>>> @@ -1818,6 +1818,8 @@ static struct fstype *__find_fstype_by_name(char *fst, bool force_auto)
>>>>>  {
>>>>>  	int i;
>>>>>  
>>>>> +	if (fst == (void *) FSTYPE__AUTO)
>>>>> +		return &fstypes[1];
>>>>>  	/*
>>>>>  	 * This fn is required for two things.
>>>>>  	 * 1st -- to check supported filesystems (as just mounting
>>>>> @@ -2091,6 +2093,15 @@ static char *resolve_source(struct mount_info *mi)
>>>>>  
>>>>>  	if (mi->fstype->code == FSTYPE__AUTO) {
>>>>>  		struct stat st;
>>>>> +		char devstr[64];
>>>>> +		struct ext_mount *key;
>>>>> +
>>>>> +		snprintf(devstr, sizeof(devstr), "mnt[%d/%d]",
>>>>> +				kdev_major(mi->s_dev), kdev_minor(mi->s_dev));
>>>>> +
>>>>> +		key = ext_mount_lookup(devstr);
>>>>> +		if (key)
>>>>> +			return key->val;
>>>>>  
>>>>>  		if (!stat(mi->source, &st) && S_ISBLK(st.st_mode) &&
>>>>>  		    major(st.st_rdev) == kdev_major(mi->s_dev) &&
>>>>> diff --git a/criu/proc_parse.c b/criu/proc_parse.c
>>>>> index 2dd8dc4..55f0f5e 100644
>>>>> --- a/criu/proc_parse.c
>>>>> +++ b/criu/proc_parse.c
>>>>> @@ -1292,6 +1292,16 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname)
>>>>>  
>>>>>  	new->fstype = find_fstype_by_name(*fsname);
>>>>>  
>>>>> +	if (new->fstype->code == FSTYPE__UNSUPPORTED) {
>>>>> +		char devstr[64];
>>>>> +
>>>>> +		snprintf(devstr, sizeof(devstr), "mnt[%d/%d]",
>>>>> +				kdev_major(new->s_dev),  kdev_minor(new->s_dev));
>>>>> +
>>>>> +		if (external_lookup_id(devstr))
>>>>> +			new->fstype = find_fstype_by_name((void *)FSTYPE__AUTO);
>>>>> +	}
>>>>> +
>>>>>  	new->options = xmalloc(strlen(opt) + 1);
>>>>>  	if (!new->options)
>>>>>  		goto err;
>>>>>
>>>>
>>> .
>>>
>>
> .
> 



More information about the CRIU mailing list