[CRIU] [PATCH 3/3] devmap: mountpoint -- Allow to open mountpoint for mapped devices

Pavel Emelyanov xemul at parallels.com
Wed Nov 25 01:15:03 PST 2015


On 11/24/2015 01:12 PM, Cyrill Gorcunov wrote:
> The mountpoint images are carrying former device IDs which
> might be changed if restore procedure is happening on
> another device (say we're migrating to new environment).
> So don't fail in such case if mappings are provided.
> 
> https://jira.sw.ru/PSBM-41357
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  mount.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/mount.c b/mount.c
> index 562d6ca5c3f3..6e8023399a5e 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -63,6 +63,22 @@ static struct ext_mount *ext_mount_lookup(char *key)
>  	return NULL;
>  }
>  
> +static bool devmap_match(unsigned int from, unsigned int to,
> +			struct cr_options *opts)
> +{
> +	if (opts->devmap) {
> +		size_t i;
> +
> +		for (i = 0; i < opts->nr_devmap; i += 2) {
> +			if (opts->devmap[i + 0] == from &&
> +			    opts->devmap[i + 1] == to)
> +				return true;
> +		}
> +	}
> +
> +	return false;
> +}
> +
>  /*
>   * Single linked list of mount points get from proc/images
>   */
> @@ -1031,7 +1047,7 @@ int __open_mountpoint(struct mount_info *pm, int mnt_fd)
>  	}
>  
>  	dev = phys_stat_resolve_dev(pm->nsid, st.st_dev, pm->ns_mountpoint + 1);
> -	if (dev != pm->s_dev) {
> +	if (dev != pm->s_dev && !devmap_match(dev, pm->s_dev, &opts)) {

Do we have only one place that compares devices on restore?

>  		pr_err("The file system %#x (%#x) %s %s is inaccessible\n",
>  		       pm->s_dev, (int)dev, pm->fstype->name, pm->ns_mountpoint);
>  		goto err;
> 



More information about the CRIU mailing list