Commit fded9a00 authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Pavel Emelyanov

mount: save ext_real_root for external mounts

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.

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: 's avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 9b2acbe4
......@@ -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
......@@ -1329,17 +1330,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;
......@@ -2446,11 +2444,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;
/*
......@@ -2458,7 +2472,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);
......
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment