diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 641: force finishing of emulated devices

Message ID 20130725021926.2458.29002.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Antonio Terceiro July 25, 2013, 2:19 a.m. UTC
------------------------------------------------------------
revno: 641
committer: Antonio Terceiro <antonio.terceiro@linaro.org>
branch nick: kill-fastmodel-process
timestamp: Wed 2013-07-24 11:04:25 -0300
message:
  force finishing of emulated devices
  
  With both fastmodels and QEMU we have the risk of leaving runaway processes
  after a job finishes, what may block resources and impact future usage of the
  same (virtual) device (and it just wrong). This commit generalizes the solution
  I found before for QEMU and applies it to fastmodels as well.
modified:
  lava_dispatcher/device/fastmodel.py
  lava_dispatcher/device/qemu.py
  lava_dispatcher/utils.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/device/fastmodel.py'
--- lava_dispatcher/device/fastmodel.py	2013-07-16 16:04:31 +0000
+++ lava_dispatcher/device/fastmodel.py	2013-07-24 14:04:25 +0000
@@ -46,6 +46,7 @@ 
     ensure_directory,
     extract_targz,
     DrainConsoleOutput,
+    finalize_process,
 )
 
 
@@ -244,9 +245,8 @@ 
 
     def power_off(self, proc):
         super(FastModelTarget, self).power_off(proc)
-        if self._sim_proc is not None:
-            self._sim_proc.close()
-            self._sim_proc = None
+        finalize_process(self._sim_proc)
+        self._sim_proc = None
 
     def _create_rtsm_ostream(self, ofile):
         """the RTSM binary uses the windows code page(cp1252), but the

=== modified file 'lava_dispatcher/device/qemu.py'
--- lava_dispatcher/device/qemu.py	2013-07-16 16:03:32 +0000
+++ lava_dispatcher/device/qemu.py	2013-07-24 14:04:25 +0000
@@ -36,6 +36,7 @@ 
 from lava_dispatcher.utils import (
     ensure_directory,
     extract_targz,
+    finalize_process,
 )
 
 
@@ -77,9 +78,7 @@ 
         return proc
 
     def power_off(self, proc):
-        if proc:
-            proc.kill(9)
-            proc.close()
+        finalize_process(proc)
 
     def get_device_version(self):
         try:

=== modified file 'lava_dispatcher/utils.py'
--- lava_dispatcher/utils.py	2013-07-16 16:09:56 +0000
+++ lava_dispatcher/utils.py	2013-07-24 14:04:25 +0000
@@ -270,3 +270,9 @@ 
             "{time.tm_hour:02}:{time.tm_min:02}:{time.tm_sec:02}Z").format(
                 test_id=test_name,
                 time=datetime.datetime.utcnow().timetuple())
+
+def finalize_process(proc):
+    print("*** finalize_process ***")
+    if proc:
+        proc.kill(9)
+        proc.close()