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

Cyrill Gorcunov gorcunov at gmail.com
Tue Nov 24 14:18:49 PST 2015


On Tue, Nov 24, 2015 at 01:12:20PM +0300, 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>

There were a typo. Fix attached.
-------------- next part --------------
>From 803d5b81c3d4e86e64e5d510b448f95ae1c5f779 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Tue, 24 Nov 2015 11:48:16 +0300
Subject: [PATCH] devmap: mountpoint -- Allow to open mountpoint for mapped
 devices

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

v2: Fix order typo in devmap_match call

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..f967c498990b 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(pm->s_dev, dev, &opts)) {
 		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;
-- 
2.5.0



More information about the CRIU mailing list