fine-grain kill of qemus - new step list_all_qemus
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 14 Feb 2008 13:15:53 +0000 (13:15 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 14 Feb 2008 13:15:53 +0000 (13:15 +0000)
system/TestMain.py
system/TestPlc.py
system/qemu_kill.sh

index b06f14a..1458b89 100755 (executable)
@@ -27,7 +27,8 @@ class TestMain:
                      'check_tcp' ]
     other_steps = [ 'fresh_install', 'stop', 
                     'clean_sites', 'clean_nodes', 'clean_slices', 'clean_keys',
-                    'kill_qemus', 'stop_nodes' ,  'db_dump' , 'db_restore',
+                    'list_all_qemus', 'kill_qemus', 'stop_nodes' ,  
+                    'db_dump' , 'db_restore',
                     'standby_1 through 20',
                     ]
     default_build_url = "http://svn.planet-lab.org/svn/build/trunk"
index cb3a11b..5381444 100644 (file)
@@ -163,9 +163,20 @@ class TestPlc:
             TestBox(box).kill_all_qemus()
         return True
 
+    # make this a valid step
+    def list_all_qemus(self,options):
+        for (box,nodes) in self.gather_hostBoxes().iteritems():
+           # push the script
+           TestBox(box).copy("qemu_kill.sh")   
+            # this is the brute force version, kill all qemus on that host box
+            TestBox(box).run("./qemu_kill.sh -l")
+        return True
+
     # kill only the right qemus
     def kill_qemus(self,options):
         for (box,nodes) in self.gather_hostBoxes().iteritems():
+           # push the script
+           TestBox(box).copy("qemu_kill.sh")   
             # the fine-grain version
             for node in nodes:
                 node.kill_qemu()
index ad1a01f..d2c1fc1 100755 (executable)
@@ -2,17 +2,36 @@
 COMMAND=$(basename $0)
 
 hostname=$1; shift
-pids="$(ps $(pgrep qemu) | grep $hostname | awk '{print $1;}')"
+
+# -l option 
+if [ "$hostname" = "-l" ] ; then
+    echo $COMMAND - listing qemu processes on $(hostname)
+    pids="$(pgrep -x qemu) $(pgrep -x start-qemu-node)"
+    [ -n "$(echo $pids)" ] && ps $pids
+    exit 0
+fi
+
+# locate only the actual qemu 
+qemu_pids="$(pgrep -x start-qemu-node) $(pgrep -x qemu)"
+
+if [ -z "$(echo $qemu_pids)" ] ; then
+    echo $COMMAND - no qemu found on $(hostname)
+    exit 0
+fi
+
+pids="$(ps $qemu_pids | grep $hostname | awk '{print $1;}')"
 
 if [ -z "$pids" ] ; then
     echo $COMMAND: no qemu instance for $hostname found on $(hostname)
-else
-    echo Killing $pids
-    kill $pids
-    sleep 2
-    if [ -n "$(ps $pids)" ] ; then
-       echo Killing -9 $pids
-       kill -9 $pids
-    fi
-    echo Done
+    exit 0
 fi
+
+echo Killing $pids
+kill $pids
+(sleep 1; 
+ if ps $pids &> /dev/null ; then
+     echo still alive - killing -9 $pids
+     kill -9 $pids
+ fi ) &
+echo Done
+exit 0