Commit 7defe3c7 authored by Wez's avatar Wez Committed by Commit Bot

Fix qemu_target.py to kill QEMU process on failure.

Previously if QEMU ran but neither exited prematurely, nor did the
guest ever become connectible via SSH, then the QEMU sub-process would
be left running after the runner script exited.

Bug: 877194
Change-Id: Id50fa44e11987f69afc469d73adc445b5066b7a5
Reviewed-on: https://chromium-review.googlesource.com/1187543
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585709}
parent 38ccb261
...@@ -51,8 +51,9 @@ class QemuTarget(target.Target): ...@@ -51,8 +51,9 @@ class QemuTarget(target.Target):
# Used by the context manager to ensure that QEMU is killed when the Python # Used by the context manager to ensure that QEMU is killed when the Python
# process exits. # process exits.
def __exit__(self, exc_type, exc_val, exc_tb): def __exit__(self, exc_type, exc_val, exc_tb):
if self.IsStarted(): if self._IsQemuStillRunning():
self.Shutdown() logging.info('Shutting down QEMU.')
self._qemu_process.kill()
def Start(self): def Start(self):
qemu_path = os.path.join(QEMU_ROOT, 'bin', qemu_path = os.path.join(QEMU_ROOT, 'bin',
...@@ -154,10 +155,6 @@ class QemuTarget(target.Target): ...@@ -154,10 +155,6 @@ class QemuTarget(target.Target):
stdout=stdout, stderr=stderr) stdout=stdout, stderr=stderr)
self._WaitUntilReady(); self._WaitUntilReady();
def Shutdown(self):
logging.info('Shutting down QEMU.')
self._qemu_process.kill()
def _IsQemuStillRunning(self): def _IsQemuStillRunning(self):
return os.waitpid(self._qemu_process.pid, os.WNOHANG)[0] == 0 return os.waitpid(self._qemu_process.pid, os.WNOHANG)[0] == 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment