attempt to avoid remote qemus from hanging
Thierry Parmentelat [Wed, 2 Apr 2008 06:31:27 +0000 (06:31 +0000)]
system/TestBox.py
system/TestNode.py
system/TestSsh.py
system/template-qemu/kill-qemu-node
system/template-qemu/start-qemu-node

index 35de00c..5c25fcd 100644 (file)
@@ -5,6 +5,7 @@ import os.path
 import utils
 from TestSsh import TestSsh
 
+# xxx this should probably inherit TestSsh
 class TestBox:
 
     def __init__(self,hostname,buildname,key=None):
@@ -26,9 +27,9 @@ class TestBox:
             return True
         return False
     
-    def run_in_buildname (self,command):
+    def run_in_buildname (self,command,background=False):
         utils.header("Running command %s on testbox %s"%(command,self.hostname()))
-        return self.test_ssh.run_in_buildname (command)
+        return self.test_ssh.run_in_buildname (command,background)
 
     # should use rsync instead
     def copy (self,local_file,recursive=False):
@@ -37,8 +38,8 @@ class TestBox:
     def clean_dir (self,dirname):
         return self.test_ssh.clean_dir(dirname)
 
-    def mkdir (self,direname):
-        return self.test_ssh.mkdir(direname)
+    def mkdir (self,dirname):
+        return self.test_ssh.mkdir(dirname)
 
     def kill_all_qemus(self):
         self.run_in_buildname("template-qemu/kill-qemu-node")
index 0624269..2bc232a 100644 (file)
@@ -157,7 +157,8 @@ class TestNode:
         utils.header("Starting qemu node %s on %s"%(self.name(),test_box.hostname()))
 
         test_box.run_in_buildname("qemu-%s/env-qemu start >> nodeslogs/%s.log"%(self.name(),self.name()))
-        test_box.run_in_buildname("qemu-%s/start-qemu-node 2>&1 >> nodeslogs/%s.log &"%(self.name(),self.name()))
+        # kick it off in background, as it would otherwise hang
+        test_box.run_in_buildname("qemu-%s/start-qemu-node 2>&1 >> nodeslogs/%s.log &"%(self.name(),self.name()),True)
 
     def list_qemu (self):
         utils.header("Listing qemu for host %s on box %s"%(self.name(),self.test_box().hostname()))
index 603b63e..d504422 100644 (file)
@@ -58,8 +58,11 @@ class TestSsh:
         ssh_command += "%s %s" %(self.hostname,TestSsh.backslash_shell_specials(command))
         return ssh_command
 
-    def run(self, command):
-        return utils.system(self.actual_command(command))
+    def run(self, command,background=False):
+        local_command = self.actual_command(command)
+        if background:
+            local_command += " &"
+        return utils.system(local_command)
 
     def clean_dir (self,dirname):
         if self.is_local():
@@ -87,11 +90,11 @@ class TestSsh:
             self.mkdir()
             self.buildname_created=True
 
-    def run_in_buildname (self,command):
+    def run_in_buildname (self,command, background=False):
         if self.is_local():
             return utils.system(command)
         self.create_buildname_once()
-        return self.run("cd %s ; %s"%(self.buildname,command))
+        return self.run("cd %s ; %s"%(self.buildname,command),background)
 
     def copy (self,local_file,recursive=False):
         if self.is_local():
index 27a2317..0ac501e 100755 (executable)
@@ -17,7 +17,7 @@ function list_pids () {
     if [[ -n "$hostnames" ]] ; then
        for hostname in $hostnames; do
            nodedir=qemu-$hostname
-           cat $nodedir/qemu.pid $nodedir/shell.pid 2> /dev/null
+           cat $nodedir/qemu.pid 2> /dev/null
        done
     else
        pgrep qemu
@@ -40,7 +40,6 @@ function kill_pids () {
        for hostname in $hostnames; do
            nodedir=qemu-$hostname
            kill_from_file $nodedir/qemu.pid
-           kill_from_file $nodedir/shell.pid
        done
     else
        echo Killing all processes mathing qemu
index 377ff5f..b138531 100755 (executable)
@@ -39,6 +39,5 @@ rm -f qemu.pid
 
 #Command for running the Qemu Emulator
 ARGS="-boot d  -net nic,macaddr=${MACADDR} -net $TAP, -cdrom ${NODE_ISO} -hda ${HDA} -m ${RAM} -nographic  -pidfile qemu.pid"
-echo $$ > shell.pid
 echo "Running $QEMU $ARGS < /dev/null"
 exec $QEMU $ARGS < /dev/null