[lxc-devel] [PATCH] use vg and zfsroot defaults in lxc-create, and ignore spaces

Serge Hallyn serge.hallyn at ubuntu.com
Mon Apr 29 14:16:59 UTC 2013


add vg and zfsroot options to lxc.functions and use in lxc-create

also make sure to drop spaces between = and variable in lxc.conf

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 src/lxc/lxc-create.in    |    3 ++-
 src/lxc/lxc.functions.in |   20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/lxc/lxc-create.in b/src/lxc/lxc-create.in
index 3367a89..48c7a1e 100644
--- a/src/lxc/lxc-create.in
+++ b/src/lxc/lxc-create.in
@@ -134,7 +134,8 @@ optarg_check() {
 backingstore=_unset
 fstype=ext4
 fssize=500M
-vgname=lxc
+vgname=$lxc_vg
+zfsroot=$lxc_zfsroot
 custom_rootfs=""
 
 while [ $# -gt 0 ]; do
diff --git a/src/lxc/lxc.functions.in b/src/lxc/lxc.functions.in
index aa5717d..416267f 100644
--- a/src/lxc/lxc.functions.in
+++ b/src/lxc/lxc.functions.in
@@ -34,4 +34,24 @@ get_default_lxcpath() {
 	fi
 }
 
+get_default_vg() {
+	LXC_VG=$(grep -v "^#" "$globalconf" 2>/dev/null | grep "[ \t]*lvm_vg[ \t]*=") || true
+	if [ -n "$LXC_VG" ]; then
+		echo $LXC_VG | awk -F= '{ print $2 }'
+	else
+		echo "lxc"
+	fi
+}
+
+get_default_zfsroot() {
+	LXC_ZFSROOT=$(grep -v "^#" "$globalconf" 2>/dev/null | grep "[ \t]*zfsroot[ \t]*=") || true
+	if [ -n "$LXC_ZFSROOT" ]; then
+		echo $LXC_ZFSROOT | awk -F= '{ print $2 }'
+	else
+		echo "tank/lxc"
+	fi
+}
+
 lxc_path=`get_default_lxcpath`
+lxc_vg=`get_default_vg`
+lxc_zfsroot=`get_default_zfsroot`
-- 
1.7.9.5





More information about the lxc-devel mailing list