[lxc-devel] [PATCH] restore lxc.mount/ lxc.mount.entry functionality

Rainer Weikusat rweikusat at mssgmbh.com
Thu Nov 4 18:02:00 UTC 2010


The lxc_setup-routine in conf.c tries to configure the filesystem
namespace for a new container by first recursively bind-mounting the
directory which is supposed to become the root filesystem of the
container to the 'rootfs mount point' and then adding whatever other
mounts have been requested in the configuration file being used to the
original filesystem location of the nascent container root
filesystem. At least for Linux 2.6.35.7 (and .4), this doesn't work
because the MS_REC flag only affects submounts which already existed
at the time of the bind mount, not new ones which come into existence
afterwards. The patch moves the setup_rootfs call in lxc_setup behind
the two 'setup additional mounts' calls which fixes this problem (at
least for me).

Signed-off-by: Rainer Weikusat (rweikusat at mssgmbh.com)
---
diff -pur lxc/src/lxc/conf.c lxc.patched/src/lxc/conf.c
--- lxc/src/lxc/conf.c	2010-11-04 18:10:08.000000000 +0100
+++ lxc.patched/src/lxc/conf.c	2010-11-04 18:32:24.000000000 +0100
@@ -1597,11 +1597,6 @@ int lxc_setup(const char *name, struct l
 		return -1;
 	}
 
-	if (setup_rootfs(&lxc_conf->rootfs)) {
-		ERROR("failed to setup rootfs for '%s'", name);
-		return -1;
-	}
-
 	if (setup_mount(lxc_conf->fstab)) {
 		ERROR("failed to setup the mounts for '%s'", name);
 		return -1;
@@ -1611,6 +1606,11 @@ int lxc_setup(const char *name, struct l
 		ERROR("failed to setup the mount entries for '%s'", name);
 		return -1;
 	}
+	
+	if (setup_rootfs(&lxc_conf->rootfs)) {
+		ERROR("failed to setup rootfs for '%s'", name);
+		return -1;
+	}
 
 	if (setup_cgroup(name, &lxc_conf->cgroup)) {
 		ERROR("failed to setup the cgroups for '%s'", name);




More information about the lxc-devel mailing list