Revision: 5
http://lxm.svn.sourceforge.net/lxm/?rev=5&view=rev
Author: outchy
Date: 2007-11-12 14:30:00 -0800 (Mon, 12 Nov 2007)
Log Message:
-----------
additional checks before launching a VM: test if already launched and test of logical volumes as snapshot source of other snapshots
Modified Paths:
--------------
trunk/bash_scripts/lxmstart
Modified: trunk/bash_scripts/lxmstart
===================================================================
--- trunk/bash_scripts/lxmstart 2007-11-09 20:07:47 UTC (rev 4)
+++ trunk/bash_scripts/lxmstart 2007-11-12 22:30:00 UTC (rev 5)
@@ -13,14 +13,69 @@
for CONFDIR in $XENCONFPATH; do
if [ -f "$CONFDIR/$VMNAME" ]; then
echo "launching virtual machine $CONFDIR/$VMNAME"
+
+ xm list --long $VMNAME > /dev/null 2> /dev/null
+ if [ "$?" == "0" ]; then
+ echo "error virtual machine $VMNAME is already launched"
+ exit 1
+ fi
+
+ DISKLIST=`echo "disk" | python -i "$CONFDIR/$VMNAME" 2>/dev/null`
+ if [ ! "$?" == "0" ]; then
+ echo "error while probing disk list"
+ exit 1
+ fi
+
+ echo "disk list is $DISKLIST"
+ LVLIST=`echo "$DISKLIST" | awk "/\[/ {
+ sep1 = \"['\\\\\"]\"
+ sep2 = \",\"
+ sep3 = \":\"
+ split(\\\$0, a, sep1)
+ i = 2
+ while (i <= length(a)) {
+ split(a[i], b, sep2)
+ if ( b[3] == \"w\" ) {
+ c = index(b[2], \":cdrom\")
+ if (c == 0) {
+ split(b[1], d, sep3)
+ if (d[1] == \"phy\" ) {
+ print d[2]
+ }
+ }
+ }
+ i++
+ i++
+ }
+ }"`
+
+ echo "logical volume list is $LVLIST"
+
+ if [ ! -z "$LVLIST" ]; then
+ for LV in $LVLIST ; do
+ echo "checking logical volume: $LV"
+ LVPROP=`lvdisplay "$LV"`
+ if [ "$?" == "0" ]; then
+ # this is a logical volume, check if it sources some snapshots
+ LVSNAPSTATUS=`echo "$LVPROP" | grep "LV snapshot status" | grep "source of"`
+ if [ ! -z "$LVSNAPSTATUS" ]; then
+ echo "logical volume $LV sources a snapshot and thus cannot be launched with write access mode"
+ exit 1
+ fi
+ fi
+ done
+ fi
+
+ echo "check of logical volumes passed"
+
xm create $CONFDIR/$VMNAME
- if [ ! "$?" = "0" ]; then
+ if [ ! "$?" == "0" ]; then
echo "error while launching virtual machine $VMNAME"
exit 1
fi
# auto execute viewer
- if [ ! "$2" = "NODISPLAY" ]; then
+ if [ ! "$2" == "NODISPLAY" ]; then
lxmdisplay $VMNAME
fi
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|