[lxc-devel] [PATCH RFC] yet another problem with new overlay fs

Serge Hallyn serge.hallyn at ubuntu.com
Mon Jan 19 05:06:55 UTC 2015


It turns out that the new upstream overlay fs requires that the delta
and work dirs be under the same mount.  So create a $lxcpath/tmpfs
and create delta0 and work0 under that.  If the user asks for a
tmpfs that'll be mounted under $lxcpath/tmpfs and workdir and delta0
both created under that.

This isn't heavily tested.  But if fixes mounting of 'overlay' fs
for me.

It's "not backward compatible", since it moves delta0, but that
shouldn't matter since ephemeral containers are either destroyed
on exit, or re-started with lxc-start.

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 src/lxc/lxc-start-ephemeral.in | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/lxc/lxc-start-ephemeral.in b/src/lxc/lxc-start-ephemeral.in
index 36e2579..66abe56 100644
--- a/src/lxc/lxc-start-ephemeral.in
+++ b/src/lxc/lxc-start-ephemeral.in
@@ -166,6 +166,7 @@ dest = lxc.Container(os.path.basename(dest_path), args.lxcpath)
 dest.load_config(orig.config_file_name)
 dest.set_config_item("lxc.utsname", dest.name)
 dest.set_config_item("lxc.rootfs", os.path.join(dest_path, "rootfs"))
+print("setting rootfs to .%s.", os.path.join(dest_path, "rootfs"))
 for nic in dest.network:
     if hasattr(nic, 'hwaddr'):
         nic.hwaddr = randomMAC()
@@ -238,34 +239,32 @@ LXC_NAME="%s"
 
     count = 0
     for entry in overlay_dirs:
-        target = "%s/delta%s" % (dest_path, count)
-        workdir = "%s/work%s" % (dest_path, count)
-        fd.write("mkdir -p %s %s\n" % (target, entry[1]))
+        deltdir = "%s/delta%s" % (tmpdir, count)
+        workdir = "%s/work%s" % (tmpdir, count)
+        fd.write("mkdir -p %s %s\n" % (deltdir, entry[1]))
         if have_new_overlay:
             fd.write("mkdir -p %s\n" % workdir)
 
         if args.storage_type == "tmpfs":
-            fd.write("mount -n -t tmpfs -o mode=0755 none %s\n" % (target))
-            if have_new_overlay:
-                fd.write("mount -n -t tmpfs -o mode=0755 none %s\n" % (workdir))
+            fd.write("mount -n -t tmpfs -o mode=0755 none %s\n" % (tmpdir))
+            fd.write("mkdir %s\n" % deltdir)
+            fd.write("mkdir %s\n" % workdir)
 
-        fd.write("getfacl -a %s | setfacl --set-file=- %s || true\n" % (entry[0], target))
+        fd.write("getfacl -a %s | setfacl --set-file=- %s || true\n" % (entry[0], deltdir))
         fd.write("getfacl -a %s | setfacl --set-file=- %s || true\n" % (entry[0], entry[1]))
-        if have_new_overlay:
-            fd.write("getfacl -a %s | setfacl --set-file=- %s || true\n" % (entry[0], workdir))
 
         if args.union_type == "overlayfs":
             if have_new_overlay:
                 fd.write("mount -n -t overlay"
                      " -oupperdir=%s,lowerdir=%s,workdir=%s none %s\n" % (
-                         target,
+                         deltdir,
                          entry[0],
                          workdir,
                          entry[1]))
             else:
                 fd.write("mount -n -t overlayfs"
                      " -oupperdir=%s,lowerdir=%s none %s\n" % (
-                         target,
+                         deltdir,
                          entry[0],
                          entry[1]))
         elif args.union_type == "aufs":
@@ -275,7 +274,7 @@ LXC_NAME="%s"
 
             fd.write("mount -n -t aufs "
                      "-o br=%s=rw:%s=ro,noplink,xino=%s none %s\n" % (
-                         target,
+                         deltdir,
                          entry[0],
                          xino_path,
                          entry[1]))
-- 
2.1.0



More information about the lxc-devel mailing list