[CRIU] [PATCH v5 1/3] mount: save ext_real_root for external mounts
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Wed Mar 22 02:19:59 PDT 2017
need it to check if we can bindmount from external mount
note: when migrating from criu with patch to criu without,
external mount mapping won't work, we do not support it.
https://jira.sw.ru/browse/PSBM-46753
v2: s/real_root/ext_real_root/
v4: add comment
v5: use ext_key field for mapping, put NO_ROOT_MOUNT in root
for old externals for which we do not have it.
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
criu/mount.c | 32 +++++++++++++++++++++++---------
images/mnt.proto | 2 ++
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/criu/mount.c b/criu/mount.c
index 6e5a4c6..4b8f5fb 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -35,6 +35,7 @@
* debugging.
*/
#define AUTODETECTED_MOUNT "CRIU:AUTOGENERATED"
+#define NO_ROOT_MOUNT "CRIU:NO_ROOT"
#define MS_PROPAGATE (MS_SHARED | MS_PRIVATE | MS_UNBINDABLE | MS_SLAVE)
#undef LOG_PREFIX
@@ -1328,17 +1329,14 @@ static int dump_one_mountpoint(struct mount_info *pm, struct cr_img *img)
me.internal_sharing = true;
}
- if (pm->external) {
+ if (pm->external)
/*
* For external mount points dump the mapping's
- * value instead of root. See collect_mnt_from_image
+ * value, see collect_mnt_from_image -> get_mp_root
* for reverse mapping details.
*/
- me.root = pm->external;
- me.has_ext_mount = true;
- me.ext_mount = true;
- } else
- me.root = pm->root;
+ me.ext_key = pm->external;
+ me.root = pm->root;
if (pb_write_one(img, &me, PB_MNT))
return -1;
@@ -2445,11 +2443,27 @@ static int get_mp_root(MntEntry *me, struct mount_info *mi)
{
char *ext = NULL;
+ BUG_ON(me->ext_mount && me->ext_key);
+
+ /* Forward compatibility fixup */
+ if (me->ext_mount) {
+ me->ext_key = me->root;
+ /*
+ * Puting the id of external mount which is provided by user,
+ * to ->root can confuse mnt_is_external and other functions
+ * which expect to see the path in the file system to the root
+ * of these mount (mounts_equal, mnt_build_ids_tree,
+ * find_wider_shared, find_fsroot_mount_for,
+ * find_best_external_match, etc.)
+ */
+ me->root = NO_ROOT_MOUNT;
+ }
+
mi->root = xstrdup(me->root);
if (!mi->root)
return -1;
- if (!me->ext_mount)
+ if (!me->ext_key)
goto out;
/*
@@ -2457,7 +2471,7 @@ static int get_mp_root(MntEntry *me, struct mount_info *mi)
* from the command line and put into root's place
*/
- ext = ext_mount_lookup(me->root);
+ ext = ext_mount_lookup(me->ext_key);
if (!ext) {
if (!opts.autodetect_ext_mounts) {
pr_err("No mapping for %s mountpoint\n", me->mountpoint);
diff --git a/images/mnt.proto b/images/mnt.proto
index 50cd8af..4160acb 100644
--- a/images/mnt.proto
+++ b/images/mnt.proto
@@ -53,4 +53,6 @@ message mnt_entry {
optional bool deleted = 16;
optional uint32 sb_flags = 17 [(criu).hex = true];
+ /* user defined mapping for external mount */
+ optional string ext_key = 18;
}
--
2.9.3
More information about the CRIU
mailing list