From: Greg Price <price@mit.edu>
Date: Mon, 29 Sep 2008 00:16:05 +0000 (-0400)
Subject: sipb-xen-install deals with lvcreate, and some tweaks
X-Git-Tag: sipb-xen-autoinstaller/2.5~3
X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-autoinstaller.git/commitdiff_plain/a485b225bf3f1923002a6b89d57e436129b8553c

sipb-xen-install deals with lvcreate, and some tweaks

svn path=/trunk/packages/sipb-xen-autoinstaller/; revision=938
---

diff --git a/common/usr/sbin/sipb-xen-create-image b/common/usr/sbin/sipb-xen-create-image
index 997e12a..8b56ce9 100644
--- a/common/usr/sbin/sipb-xen-create-image
+++ b/common/usr/sbin/sipb-xen-create-image
@@ -2,13 +2,13 @@
 # Usage: no command-line args.
 # "arguments" come in environment:
 #  TARGET a device filename
-#  IMAGESIZE the desired filesystem size in megabytes (rest will be swap)
+#  FSSIZE the desired filesystem size in megabytes (rest will be swap)
 #  ARCH, DIST, MIRROR
 #  HOSTNAME, IP
 
 set -e
 
-echo ,"${IMAGESIZE}"$',L,*\n,,S\n;\n;' | sfdisk -uM -H 255 -S 63 "$TARGET"
+echo ,"${FSSIZE}"$',L,*\n,,S\n;\n;' | sfdisk -uM -H 255 -S 63 "$TARGET"
 
 kpartx -a "$TARGET"    # should be no-op in guest
 
@@ -16,6 +16,6 @@ xen-create-image --image-dev "${TARGET}1" --swap-dev "${TARGET}2" --fs ext3 --id
  --hostname "$HOSTNAME" --ip="$IP" --netmask=255.255.0.0 --gateway=18.181.0.1 \
  --arch "$ARCH" --dist "$DIST" --mirror "$MIRROR" --cache=yes
 
-kpartx -d $VOLUME
+kpartx -d "$TARGET"
 
 exit 0
diff --git a/guest/etc/init.d/rcS.sipb-xen b/guest/etc/init.d/rcS.sipb-xen
index ff605d6..103c195 100644
--- a/guest/etc/init.d/rcS.sipb-xen
+++ b/guest/etc/init.d/rcS.sipb-xen
@@ -14,7 +14,7 @@ for x in $(cat /proc/cmdline); do
 	export ARCH=${x#arch=}
 	;;
 	imagesize=*)
-	export IMAGESIZE=${x#imagesize=}
+	export FSSIZE=${x#imagesize=}
 	;;
 	noinstall)
 	exit 0
diff --git a/host/usr/sbin/sipb-xen-install b/host/usr/sbin/sipb-xen-install
index 81cea3f..6784e52 100644
--- a/host/usr/sbin/sipb-xen-install
+++ b/host/usr/sbin/sipb-xen-install
@@ -4,16 +4,20 @@
 # In particular, it may leave ${TARGET}1 mounted somewhere in tmp.
 # Unmount it, then kpartx -d $TARGET to clean up.
 
+set -e
+
 export PATH #WTF?
 
-LVNAME="$1"
+NAME="$1"
 export HOSTNAME="$2"
 export DIST="$3"
 export MIRROR="$4"
-export IMAGESIZE="$5"  # in megabytes
-export IP="$6"
+export FSSIZE="$5"    # in megabytes
+SWAPSIZE="$6"  # in megabytes
+export IP="$7"
 
 export ARCH=amd64
+VGNAME=xenvg
 
 #LVSIZE=`lvs --noheadings --units M --nosuffix -o Size /dev/xenvg/d_foobar_hda | sed 's/\..*//'`
 
@@ -21,7 +25,8 @@ if [ -z "$IP" ]; then
     IP=`host $HOSTNAME.xvm.mit.edu | sed 's/.* //' | head -n 1`
 fi
 
-export TARGET=/dev/mapper/xenvg-$(echo "$LVNAME" | sed -e 's/-/--/g')_hda
+/sbin/lvcreate -L $(($FSSIZE+$SWAPSIZE))M -n "${NAME}_hda" $VGNAME
 
-/usr/sbin/sipb-xen-create-image
+export TARGET=/dev/mapper/xenvg-"$(echo "${NAME}_hda" | sed -e 's/-/--/g')"
 
+/usr/sbin/sipb-xen-create-image