Description: maintain size of lvm snapshot in lxc-clone
 When creating a container as lvm snapshot, use the original size unless
 user explicitly overrides it.
 It's all well and good to day "use lvextend if you run out of space", but
 in the meantime applications may become corrupted...
 This will be forwarded.
Author: Serge Hallyn <serge.hallyn@ubuntu.com>
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/939765
Forwarded: no

Index: lxc/src/lxc/lxc-clone.in
===================================================================
--- lxc.orig/src/lxc/lxc-clone.in	2012-02-23 16:21:13.750796000 -0600
+++ lxc/src/lxc/lxc-clone.in	2012-02-23 16:44:03.587583210 -0600
@@ -43,7 +43,8 @@
 lxc_path=/var/lib/lxc
 bindir=/usr/bin
 snapshot=no
-lxc_size=2G
+lxc_defsize=2G
+lxc_size=_unset
 lxc_vg=lxc
 
 getopt=$(getopt -o $shortoptions --longoptions  $longoptions -- "$@")
@@ -191,6 +192,9 @@
 		exit 1
 	fi
 	# ok, create a snapshot of the lvm device
+	if [ $lxc_size = "_unset" ]; then
+		lxc_size=`lvdisplay $oldroot | grep Size | awk '{ print $3 $4 }'`
+	fi
 	lvcreate -s -L $lxc_size -n $lxc_new /dev/$lxc_vg/$lxc_orig || cleanup
 	echo "lxc.rootfs = /dev/$lxc_vg/$lxc_new" >> $lxc_path/$lxc_new/config
 	# and mount it so we can tweak it
