[lxc-devel] [PATCH 1/1] lxc-start: don't re-try to mount rootfs if we already did so
Stéphane Graber
stgraber at ubuntu.com
Mon Oct 27 20:34:27 UTC 2014
On Tue, Oct 14, 2014 at 11:04:35AM +0000, Serge Hallyn wrote:
> 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>
Acked-by: Stéphane Graber <stgraber 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
>
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20141027/ca830ae5/attachment.sig>
More information about the lxc-devel
mailing list