[CRIU] [PATCH 08/12] mounts: bind mount one root for all namespaces
Andrey Vagin
avagin at openvz.org
Fri Jan 10 05:50:02 PST 2014
Currently we support nested mount namespaces, only if all of them have
the same root.
crtools doesn't mount root, so it should be bind-mounted for all
namespaces.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
mount.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/mount.c b/mount.c
index 0db86d8..1eed6c9 100644
--- a/mount.c
+++ b/mount.c
@@ -228,6 +228,12 @@ static struct mount_info *mnt_build_ids_tree(struct mount_info *list)
m->mnt_id, m->parent_mnt_id, m->mountpoint,
root ? "found" : "not found");
if (root && m->is_root) {
+ if (!mounts_equal(root, m, true) ||
+ (strcmp(root->root, m->root))) {
+ pr_err("Nested mount namespaces with different roots are not supported yet");
+ return NULL;
+ }
+
/* root of a sub mount namespace*/
p = root;
} else
@@ -1022,9 +1028,10 @@ static int propagate_mount(struct mount_info *mi)
skip:
/*
* FIXME Currently non-root mounts can be restored
- * only if a proper root mount exists
+ * only if a proper root mount exists.
+ * Here is one exception for sub-roots. Roots of all mntns are the same.
*/
- if (fsroot_mounted(mi))
+ if (mi->parent == NULL || fsroot_mounted(mi))
list_for_each_entry(t, &mi->mnt_bind, mnt_bind) {
if (t->bind)
continue;
@@ -1170,8 +1177,11 @@ static int do_mount_one(struct mount_info *mi)
{
int ret;
- if (!mi->parent)
- return 0;
+ if (!mi->parent) {
+ mi->mounted = true;
+ ret = restore_shared_options(mi, 0, mi->shared_id, 0);
+ goto propagate;
+ }
if (mi->mounted)
return 0;
@@ -1188,6 +1198,7 @@ static int do_mount_one(struct mount_info *mi)
else
ret = do_bind_mount(mi);
+propagate:
if (ret == 0 && propagate_mount(mi))
return -1;
--
1.8.3.1
More information about the CRIU
mailing list