Commit c597baa8 by Dwight Engen Committed by Stéphane Graber

fix mounts not propagating back to root mntns during create and clone

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. Signed-off-by: 's avatarDwight Engen <dwight.engen@oracle.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent f88bfaa3
...@@ -2387,6 +2387,12 @@ static int rsync_rootfs(struct rsync_data *data) ...@@ -2387,6 +2387,12 @@ static int rsync_rootfs(struct rsync_data *data)
SYSERROR("unshare CLONE_NEWNS"); SYSERROR("unshare CLONE_NEWNS");
return -1; 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 not a snapshot, copy the fs.
if (orig->ops->mount(orig) < 0) { if (orig->ops->mount(orig) < 0) {
......
...@@ -913,7 +913,7 @@ static bool create_run_template(struct lxc_container *c, char *tpath, bool quiet ...@@ -913,7 +913,7 @@ static bool create_run_template(struct lxc_container *c, char *tpath, bool quiet
exit(1); exit(1);
} }
if (detect_shared_rootfs()) { 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"); SYSERROR("Failed to make / rslave to run template");
ERROR("Continuing..."); ERROR("Continuing...");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment