[lxc-devel] [PATCH 1/1] lxc-start: don't re-try to mount rootfs if we already did so
Serge Hallyn
serge.hallyn at ubuntu.com
Tue Oct 14 11:04:35 UTC 2014
If we are root using a user namespace and are mounting a blockdev as rootfs,
then we do this before unsharing the userns, because we are not allowed to
do it in a userns. But after unsharing the userns, we unconditionally
retried mounting the rootfs, resulting in failure. stop that.
Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
src/lxc/conf.c | 3 ++-
src/lxc/conf.h | 1 +
src/lxc/start.c | 1 +
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index e493899..4f22f1e 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -3891,7 +3891,7 @@ void tmp_proc_unmount(struct lxc_conf *lxc_conf)
}
}
-static void remount_all_slave(void)
+void remount_all_slave(void)
{
/* walk /proc/mounts and change any shared entries to slave */
FILE *f = fopen("/proc/self/mountinfo", "r");
@@ -3986,6 +3986,7 @@ int do_rootfs_setup(struct lxc_conf *conf, const char *name, const char *lxcpath
ERROR("Failed to bind-mount container / onto itself");
return false;
}
+ return true;
}
remount_all_slave();
diff --git a/src/lxc/conf.h b/src/lxc/conf.h
index 97d9f91..d0565f2 100644
--- a/src/lxc/conf.h
+++ b/src/lxc/conf.h
@@ -414,5 +414,6 @@ extern int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data);
extern int parse_mntopts(const char *mntopts, unsigned long *mntflags,
char **mntdata);
extern void tmp_proc_unmount(struct lxc_conf *lxc_conf);
+void remount_all_slave(void);
extern void suggest_default_idmap(void);
#endif
diff --git a/src/lxc/start.c b/src/lxc/start.c
index 6fbe81c..b71af37 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -1074,6 +1074,7 @@ int __lxc_start(const char *name, struct lxc_conf *conf,
ERROR("Error unsharing mounts");
goto out_fini_nonet;
}
+ remount_all_slave();
if (do_rootfs_setup(conf, name, lxcpath) < 0) {
ERROR("Error setting up rootfs mount as root before spawn");
goto out_fini_nonet;
--
2.1.0
More information about the lxc-devel
mailing list