All of this needs a rewrite/redesign, and that will be coming (details below), but for now
You can start 'non-ephemeral ephemeral' containers using lxc-start-ephemeral -o oldname -n newname --keep-data When you shut that down, the container stick around and can be restarted. Now lxc-clone will recognize such a container by the presence of the delta0/ which contains the read-write overlayfs layer. This means you can do incremental development of containers, i.e. lxc-create -t ubuntu -n r1 lxc-start-ephemeral --keep-data -o r1 -n r1-2 # make some changes, poweroff lxc-clone -o r1-2 -n r1-3 # make some changes... lxc-clone -o r1-3 -n r1-4 # etc... Now, as for design changes... from a higher level 1. lxc-clone should be re-written in c and exported through the api. 2. lxc-clone should support overlayfs and aufs 3. lxc-start-ephemeral should become a thin layer which clones a container, starts and stops and destroys it. at a lower level, 1. the api should support container->setup_mounts 2. lxc-clone should be written as a set of backend classes which can copy mounts to each other. So when you load a container which is lvm-backed, it creates a lvm backend class. That class instance can be converted into a loopback or qemu-nbd or directory backed class. A directory-backed class can be converted into a overlayfs or aufs backed class, which (a) uses the dirctory-backed class as the read-only base, and (b) pins the base container (so it can't be deleted until all snapshots are deleted). Signed-off-by: Serge Hallyn <serge.hal...@ubuntu.com> --- src/lxc/lxc-clone.in | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lxc/lxc-clone.in b/src/lxc/lxc-clone.in index 291db30..4c8acb4 100755 --- a/src/lxc/lxc-clone.in +++ b/src/lxc/lxc-clone.in @@ -251,6 +251,23 @@ elif which btrfs >/dev/null 2>&1 && btrfs subvolume list $oldroot >/dev/null 2>& # if oldroot is a btrfs subvolume, assume they want a snapshot btrfs subvolume snapshot "$oldroot" "$rootfs" 2>&1 || { echo "$(basename $0): btrfs snapshot failed" >&2; false; } echo "lxc.rootfs = $rootfs" >> "$lxc_path/$lxc_new/config" +elif [ -d $lxc_path/$lxc_orig/delta0 ]; then # this is a quasi-ephemeral container + if [ $container_running = "True" ]; then + echo "$(basename $0): container $lxc_orig is running." >&2 + cleanup + fi + rsync -Hax $lxc_path/$lxc_orig/delta0 $lxc_path/$lxc_new/ + touch $lxc_path/$lxc_new/configured + cp -f $lxc_path/$lxc_orig/pre-mount $lxc_path/$lxc_new/ + sed -i "s@$lxc_path/$lxc_orig@$lxc_path/$lxc_new@g" $lxc_path/$lxc_new/config + sed -i "s@$lxc_path/$lxc_orig@$lxc_path/$lxc_new@g" $lxc_path/$lxc_new/pre-mount + sed -i "s@LXC_NAME=\"$lxc_orig@LXC_NAME=\"$lxc_new@" $lxc_path/$lxc_new/pre-mount + # lxc-start-ephemeral will have updated /etc/hostname and such under the + # delta0, so just mounting the delta should suffice. + mkdir -p $rootfs + mount --bind $lxc_path/$lxc_new/delta0 $rootfs + mounted=1 + echo "lxc.rootfs = $rootfs" >> "$lxc_path/$lxc_new/config" else if [ $snapshot = "yes" ]; then echo "$(basename $0): cannot snapshot a directory" >&2 -- 1.8.1.2 ------------------------------------------------------------------------------ Own the Future-Intel® Level Up Game Demo Contest 2013 Rise to greatness in Intel's independent game demo contest. Compete for recognition, cash, and the chance to get your game on Steam. $5K grand prize plus 10 genre and skill prizes. Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d _______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel