[lxc-devel] [PATCH] fix mounts not propagating back to root mntns during create and clone

Serge Hallyn serge.hallyn at ubuntu.com
Wed Feb 19 23:44:59 UTC 2014


Quoting Dwight Engen (dwight.engen at oracle.com):
> Systems based on systemd mount the root shared by default. We don't want
> mounts done during creation by templates nor those done internally by
> bdev during rsync based clones to propagate to the root mntns.
> 
> The create case already had the right check, but the mount call was
> missing "/", so it was failing.

What's weird is I thought I saw this (the "" in target) and fixed it a
few days ago...  I'm losing my mind.

> Signed-off-by: Dwight Engen <dwight.engen at oracle.com>

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

This might also be a problem in lxc-attach in the remount_sys_proc
case, in detect_fs() in bdev.c, in clone_update_rootfs(), and in
lxc-usernsexec.

> ---
>  src/lxc/bdev.c         | 6 ++++++
>  src/lxc/lxccontainer.c | 2 +-
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c
> index 67fe72b..ab1c87b 100644
> --- a/src/lxc/bdev.c
> +++ b/src/lxc/bdev.c
> @@ -2387,6 +2387,12 @@ static int rsync_rootfs(struct rsync_data *data)
>  		SYSERROR("unshare CLONE_NEWNS");
>  		return -1;
>  	}
> +	if (detect_shared_rootfs()) {
> +		if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL)) {
> +			SYSERROR("Failed to make / rslave to run rsync");
> +			ERROR("Continuing...");
> +		}
> +	}
>  
>  	// If not a snapshot, copy the fs.
>  	if (orig->ops->mount(orig) < 0) {
> diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
> index b8b11d6..0d89d11 100644
> --- a/src/lxc/lxccontainer.c
> +++ b/src/lxc/lxccontainer.c
> @@ -913,7 +913,7 @@ static bool create_run_template(struct lxc_container *c, char *tpath, bool quiet
>  				exit(1);
>  			}
>  			if (detect_shared_rootfs()) {
> -				if (mount("", "", NULL, MS_SLAVE|MS_REC, 0)) {
> +				if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL)) {
>  					SYSERROR("Failed to make / rslave to run template");
>  					ERROR("Continuing...");
>  				}
> -- 
> 1.8.3.1
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list