=== modified file 'lava_dispatcher/client/base.py'
--- lava_dispatcher/client/base.py	2012-08-15 14:34:54 +0000
+++ lava_dispatcher/client/base.py	2012-08-23 15:33:00 +0000
@@ -415,7 +415,8 @@
         logging.info("Boot the test image")
 
         self._boot_linaro_image()
-        self.in_test_shell(300)
+        timeout = self.config.getint("boot_linaro_timeout", 300)
+        self.in_test_shell(timeout)
         # set PS1 to include return value of last command
         # Details: system PS1 is set in /etc/bash.bashrc and user PS1 is set in
         # /root/.bashrc, it is

=== modified file 'lava_dispatcher/client/fastmodel.py'
--- lava_dispatcher/client/fastmodel.py	2012-08-10 15:25:36 +0000
+++ lava_dispatcher/client/fastmodel.py	2012-08-23 15:00:18 +0000
@@ -31,7 +31,7 @@
 import time
 
 from lava_dispatcher.client.base import (
-    CommandRunner,
+    TesterCommandRunner,
     LavaClient,
     )
 from lava_dispatcher.client.lmc_utils import (
@@ -170,12 +170,6 @@
 
         self._customize_ubuntu()
 
-    def _close_sim_proc(self):
-        self._sim_proc.close(True)
-
-    def _close_serial_proc(self):
-        self.proc.close(True)
-
     def _fix_perms(self):
         ''' The directory created for the image download/creation gets created
         with tempfile.mkdtemp which grants permission only to the creator of
@@ -216,19 +210,28 @@
 
     def _stop(self):
         if self.proc is not None:
+            logging.info("performing sync on target filesystem")
+            r = TesterCommandRunner(self)
+            r.run("sync", timeout=10, failok=True)
             self.proc.close()
+            self.proc = None
         if self._sim_proc is not None:
             self._sim_proc.close()
+            self._sim_proc = None
+
+    def _create_rtsm_ostream(self, ofile):
+        '''the RTSM binary uses the windows code page(cp1252), but the
+        dashboard and celery needs data with a utf-8 encoding'''
+        return codecs.EncodedFile(ofile, 'cp1252', 'utf-8')
+
 
     def _drain_sim_proc(self):
         '''pexpect will continue to get data for the simproc process. We need
         to keep this pipe drained so that it won't get full and then stop block
         the process from continuing to execute'''
 
-        # NOTE: the RTSM binary uses the windows code page(cp1252), but the
-        # dashboard needs this with a utf-8 encoding
         f = cStringIO.StringIO()
-        self._sim_proc.logfile = codecs.EncodedFile(f, 'cp1252', 'utf-8')
+        self._sim_proc.logfile = self._create_rtsm_ostream(f)
         _pexpect_drain(self._sim_proc).start()
 
     def _boot_linaro_image(self):
@@ -237,11 +240,6 @@
         self._fix_perms()
         sim_cmd = self._get_sim_cmd()
 
-        logging.info('ensuring ADB port is ready')
-        while logging_system("sh -c 'netstat -an | grep 5555.*TIME_WAIT'") == 0:
-            logging.info ("waiting for TIME_WAIT 5555 socket to finish")
-            time.sleep(3)
-
         # the simulator proc only has stdout/stderr about the simulator
         # we hook up into a telnet port which emulates a serial console
         logging.info('launching fastmodel with command %r' % sim_cmd)
@@ -249,7 +247,7 @@
             sim_cmd,
             logfile=self.sio,
             timeout=1200)
-        atexit.register(self._close_sim_proc)
+        atexit.register(self._stop)
         self._sim_proc.expect(self.PORT_PATTERN, timeout=300)
         self._serial_port = self._sim_proc.match.groups()[0]
         logging.info('serial console port on: %s' % self._serial_port)
@@ -264,12 +262,18 @@
         logging.info('simulator is started connecting to serial port')
         self.proc = logging_spawn(
             'telnet localhost %s' % self._serial_port,
-            logfile=self.sio,
+            logfile=self._create_rtsm_ostream(self.sio),
             timeout=90)
-        atexit.register(self._close_serial_proc)
+        atexit.register(self._stop)
 
     def _boot_linaro_android_image(self):
-        ''' booting android or ubuntu style images don't differ for FastModel'''
+        ''' booting android or ubuntu style images don't differ much'''
+
+        logging.info('ensuring ADB port is ready')
+        while logging_system("sh -c 'netstat -an | grep 5555.*TIME_WAIT'") == 0:
+            logging.info ("waiting for TIME_WAIT 5555 socket to finish")
+            time.sleep(3)
+
         self._boot_linaro_image()
 
     def reliable_session(self):

=== modified file 'lava_dispatcher/default-config/lava-dispatcher/device-types/fastmodel.conf'
--- lava_dispatcher/default-config/lava-dispatcher/device-types/fastmodel.conf	2012-08-14 09:30:52 +0000
+++ lava_dispatcher/default-config/lava-dispatcher/device-types/fastmodel.conf	2012-08-23 15:33:00 +0000
@@ -8,5 +8,8 @@
 # fm takes longer than other android images do
 disablesuspend_timeout = 500
 
+# how long ubuntu takes to boot to prompt
+boot_linaro_timeout = 500
+
 # if you do dhcp on boot, adb will not work (asac) on fastmodels
 enable_network_after_boot_android = 0

=== modified file 'lava_dispatcher/utils.py'
--- lava_dispatcher/utils.py	2012-07-22 01:42:10 +0000
+++ lava_dispatcher/utils.py	2012-08-24 14:14:27 +0000
@@ -22,6 +22,7 @@
 import errno
 import logging
 import os
+import select
 import sys
 import shutil
 import urlparse
@@ -106,7 +107,12 @@
         try:
             self._spawn__interact_copy(escape_character=chr(29))
         except:
-            logging.warn(sys.exc_info())
+            einfo = sys.exc_info()
+            # since we blindly read this from a thread, it will always wind up
+            # dying with a select error. we should still make note of other
+            # exceptions that might happen
+            if not isinstance(einfo[1], select.error):
+                logging.warn("error while draining pexpect buffers: %r", einfo)
             pass
 
 # XXX Duplication: we should reuse lava-test TestArtifacts

