diff -r f70d5c01be7f heartbeat/VirtualDomain
--- a/heartbeat/VirtualDomain	Mon Dec 28 13:04:29 2009 +0900
+++ b/heartbeat/VirtualDomain	Mon Dec 28 13:41:48 2009 +0900
@@ -124,10 +124,16 @@
     # in production, instead let the script figure out the domain name
     # from the config file. You have been warned.
     if [ -z "$DOMAIN_NAME" ]; then
-	virsh ${VIRSH_OPTIONS} define ${OCF_RESKEY_config} \
-	    | sed -e 's/Domain \(.*\) defined from .*$/\1/' \
-	    > $STATEFILE \
-	    || return $OCF_ERR_GENERIC
+	defines=`virsh ${VIRSH_OPTIONS} define ${OCF_RESKEY_config}`
+	if [ $? -ne 0 ]; then
+		ocf_log error "Failed command : virsh ${VIRSH_OPTIONS} define ${OCF_RESKEY_config}"
+		return $OCF_ERR_GENERIC
+	fi
+	echo $defines | sed -e 's/Domain \(.*\) defined from .*$/\1/' > $STATEFILE 
+	if [ $? -ne 0 ]; then
+		ocf_log error "Failed in generation of $STATEFILE."
+		return $OCF_ERR_GENERIC
+	fi
     else
 	ocf_log warn "Domain name ${DOMAIN_NAME} already defined, overriding configuration file ${OCF_RESKEY_config}. You should do this for testing only."
     fi
@@ -238,6 +244,7 @@
 			    # Domain is still running, keep
 			    # waiting (until shutdown_timeout
 			    # expires)
+				ocf_log debug "${DOMAIN_NAME} still hasn't stopped yet. Waiting..."
 			    sleep 1
 			    ;;
 			*)
@@ -372,7 +379,11 @@
 if [ $OCF_RESKEY_config -nt $STATEFILE ]; then
     VirtualDomain_Define || exit $?
 fi
-DOMAIN_NAME=`cat $STATEFILE 2>/dev/null` || exit $OCF_ERR_GENERIC
+DOMAIN_NAME=`cat $STATEFILE 2>/dev/null`
+if [ $? -ne 0 ]; then
+    ocf_log err "Cannot get $STATEFILE."
+    exit $OCF_ERR_GENERIC
+fi 
 if [ -z $DOMAIN_NAME ]; then
     ocf_log err "$STATEFILE is empty. This is unexpected. Cannot determine domain name."
     exit $OCF_ERR_GENERIC
