diff -r bce0f5e5e6ab lib/plugins/stonith/external/libvirt
--- a/lib/plugins/stonith/external/libvirt	Mon Feb 27 11:01:12 2012 +0100
+++ b/lib/plugins/stonith/external/libvirt	Fri Jun 01 14:50:40 2012 +0900
@@ -34,7 +34,9 @@
         return 0
     fi
 
-    if echo "$out" | grep -i 'Domain is already active' > /dev/null 2>&1
+    $VIRSH -c $hypervisor_uri dominfo $domain_id |\
+        grep "^State:" | grep -q -e "running" -e "idle" 2>&1
+    if [ $? -eq 0 ]
     then
         ha_log.sh notice "Domain $domain_id is already active"
         return 0
@@ -58,7 +60,9 @@
         return 0
     fi
 
-    if echo "$out" | grep -i 'domain is not running' > /dev/null 2>&1
+    $VIRSH -c $hypervisor_uri dominfo $domain_id |\
+        grep "^State:" | grep -q "shut off"  2>&1
+    if [ $? -eq 0 ]
     then
         ha_log.sh notice "Domain $domain_id is already stopped"
         return 2
