Commit 47ee663b by Serge Hallyn Committed by Stéphane Graber

lxc-start-ephemeral: handle the overlayfs workdir option (v2)

We fixed this some time ago for basic lxc-start, but never did lxc-start-ephemeral. Since the lxc-start patches were pushed, Miklos has given us a way to detect whether we need the workdir= option. So the bdev.c code could be simplified to check for "overlay\n" in /proc/filesystems just as lxc-start-ephemeral does. This patch doesn't do that. Changelog (v2): 1. use 'overlay' fstype for new overlay upstream module 2. avoid using unneeded readlines(). Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 4633d675
...@@ -200,6 +200,14 @@ if orig.get_config_item("lxc.mount"): ...@@ -200,6 +200,14 @@ if orig.get_config_item("lxc.mount"):
# Setup an overlay for anything remaining # Setup an overlay for anything remaining
overlay_dirs += [(fields[0], dest_mount)] overlay_dirs += [(fields[0], dest_mount)]
# do we have the new overlay fs which requires workdir, or the older
# overlayfs which does not?
have_new_overlay = False
with open("/proc/filesystems", "r") as fd:
for line in fd:
if line == "nodev\toverlay\n":
have_new_overlay = True
# Generate pre-mount script # Generate pre-mount script
with open(os.path.join(dest_path, "pre-mount"), "w+") as fd: with open(os.path.join(dest_path, "pre-mount"), "w+") as fd:
os.fchmod(fd.fileno(), 0o755) os.fchmod(fd.fileno(), 0o755)
...@@ -212,13 +220,26 @@ LXC_NAME="%s" ...@@ -212,13 +220,26 @@ LXC_NAME="%s"
count = 0 count = 0
for entry in overlay_dirs: for entry in overlay_dirs:
target = "%s/delta%s" % (dest_path, count) target = "%s/delta%s" % (dest_path, count)
workdir = "%s/work%s" % (dest_path, count)
fd.write("mkdir -p %s %s\n" % (target, entry[1])) fd.write("mkdir -p %s %s\n" % (target, entry[1]))
if have_new_overlay:
fd.write("mkdir -p %s\n" % workdir)
if args.storage_type == "tmpfs": if args.storage_type == "tmpfs":
fd.write("mount -n -t tmpfs -o mode=0755 none %s\n" % (target)) 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))
if args.union_type == "overlayfs": if args.union_type == "overlayfs":
fd.write("mount -n -t overlayfs" if have_new_overlay:
fd.write("mount -n -t overlay"
" -oupperdir=%s,lowerdir=%s,workdir=%s none %s\n" % (
target,
entry[0],
workdir,
entry[1]))
else:
fd.write("mount -n -t overlayfs"
" -oupperdir=%s,lowerdir=%s none %s\n" % ( " -oupperdir=%s,lowerdir=%s none %s\n" % (
target, target,
entry[0], entry[0],
......
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