This reworks the mount logic for lxc-start-ephemeral to be as follow:
 - Any real (non-bind) entry gets copied to the target fstab
 - Any bind-mount from a virtual fs gets copied to the target fstab
 - Any remaining bind-mount if confirmed to be valid gets setup as an
   overlay.

Extra bind-mounts passed through the -b option are mounted by the
pre-mount script and don't need processing by the fstab generator.

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 src/lxc/lxc-start-ephemeral.in | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/lxc/lxc-start-ephemeral.in b/src/lxc/lxc-start-ephemeral.in
index af8da80..0f0c398 100644
--- a/src/lxc/lxc-start-ephemeral.in
+++ b/src/lxc/lxc-start-ephemeral.in
@@ -164,30 +164,32 @@ if orig.get_config_item("lxc.mount"):
                 line.replace(orig.get_config_item("lxc.rootfs"),
                              dest.get_config_item("lxc.rootfs"))
 
-                # Skip any line that's not a bind mount
                 fields = line.split()
+
+                # Skip invalid entries
                 if len(fields) < 4:
+                    continue
+
+                # Non-bind mounts are kept as-is
+                if "bind" not in fields[3]:
                     dest_fd.write("%s\n" % line)
                     continue
 
-                if fields[2] != "bind" and "bind" not in fields[3]:
+                # Bind mounts of virtual filesystems are also kept as-is
+                src_path = fields[0].split("/")
+                if len(src_path) > 1 and src_path[1] in ("proc", "sys"):
                     dest_fd.write("%s\n" % line)
                     continue
 
-                # Process any remaining line
+                # Skip invalid mount points
                 dest_mount = os.path.abspath(os.path.join("%s/rootfs/" % (
                                              dest_path), fields[1]))
 
-                if dest_mount == os.path.abspath("%s/rootfs/%s" % (
-                                                 dest_path, args.bdir)):
-
-                    dest_fd.write("%s\n" % line)
-                    continue
-
                 if "%s/rootfs/" % dest_path not in dest_mount:
                     print(_("Skipping mount entry '%s' as it's outside "
                             "of the container rootfs.") % line)
 
+                # Setup an overlay for anything remaining
                 overlay_dirs += [(fields[0], dest_mount)]
 
 # Generate pre-mount script
-- 
1.8.3.2


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel

Reply via email to