From: Serge Hallyn <serge.hal...@ubuntu.com> Note we still need the function to detect a MS_SHARED /, bc if we detect that then we need to umount the chroot tmpfs mount which lxc-start created, whose mount was forwarded to the host mounts namespace.
Signed-off-by: Serge Hallyn <serge.hal...@ubuntu.com> Acked-by: Stéphane Graber <stgra...@ubuntu.com> --- src/lxc/conf.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 945c3b8..09cfa9f 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -1163,13 +1163,6 @@ static int setup_rootfs(struct lxc_conf *conf) return -1; } - if (detect_shared_rootfs()) { - if (chroot_into_slave(conf)) { - ERROR("Failed to chroot into slave /"); - return -1; - } - } - if (mount_rootfs(rootfs->path, rootfs->mount)) { ERROR("failed to mount rootfs"); return -1; @@ -1180,17 +1173,33 @@ static int setup_rootfs(struct lxc_conf *conf) return 0; } -int setup_pivot_root(const struct lxc_rootfs *rootfs) +static int setup_pivot_root(struct lxc_conf *conf) { + const struct lxc_rootfs *rootfs = &conf->rootfs; + if (!rootfs->path) return 0; - if (setup_rootfs_pivot_root(rootfs->mount, rootfs->pivot)) { + if (setup_rootfs_pivot_root(rootfs->mount, rootfs->pivot) == 0) + return 0; + + if (errno != EINVAL) { ERROR("failed to setup pivot root"); return -1; } - return 0; + INFO("pivot_root failed. Trying pivot_root under custom chroot."); + + if (chroot_into_slave(conf)) { + ERROR("Failed to chroot into slave /"); + return -1; + } + + if (setup_rootfs_pivot_root(rootfs->mount, rootfs->pivot) == 0) + return 0; + + ERROR("failed to setup pivot root"); + return -1; } static int setup_pts(int pts) @@ -2649,7 +2658,7 @@ int lxc_setup(const char *name, struct lxc_conf *lxc_conf) } #endif - if (setup_pivot_root(&lxc_conf->rootfs)) { + if (setup_pivot_root(lxc_conf)) { ERROR("failed to set rootfs for '%s'", name); return -1; } -- 1.8.0 ------------------------------------------------------------------------------ Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS and more. Get SQL Server skills now (including 2012) with LearnDevNow - 200+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only - learn more at: http://p.sf.net/sfu/learnmore_122512 _______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel