From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>, Marcel Apfelbaum <marcel@redhat.com>
Subject: [Qemu-devel] [PATCH 1/3] qemu.py: Always save QEMU exit code
Date: Wed, 22 Mar 2017 13:00:50 -0300 [thread overview]
Message-ID: <20170322160052.2820-2-ehabkost@redhat.com> (raw)
In-Reply-To: <20170322160052.2820-1-ehabkost@redhat.com>
Instead of saving the QEMU exit code only if shutdown() gets
called, move it to _post_shutdown(), so it gets saved even if the
launch() method has failed.
Add a exitcode() method that scripts can use to query the QEMU
exit code.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
scripts/qemu.py | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/scripts/qemu.py b/scripts/qemu.py
index 6d1b6230b7..c9f35b97f5 100644
--- a/scripts/qemu.py
+++ b/scripts/qemu.py
@@ -39,6 +39,7 @@ class QEMUMachine(object):
self._iolog = None
self._socket_scm_helper = socket_scm_helper
self._debug = debug
+ self._exitcode = None
# This can be used to add an unused monitor instance.
def add_monitor_telnet(self, ip, port):
@@ -116,6 +117,9 @@ class QEMUMachine(object):
if not isinstance(self._monitor_address, tuple):
self._remove_if_exists(self._monitor_address)
self._remove_if_exists(self._qemu_log_path)
+ self._exitcode = self._popen.wait()
+ if self._exitcode < 0:
+ sys.stderr.write('qemu received signal %i: %s\n' % (-self._exitcode, ' '.join(self._args)))
def launch(self):
'''Launch the VM and establish a QMP connection'''
@@ -135,6 +139,9 @@ class QEMUMachine(object):
self._popen = None
raise
+ def exitcode(self):
+ return self._exitcode
+
def shutdown(self):
'''Terminate the VM and clean up'''
if not self._popen is None:
@@ -144,9 +151,6 @@ class QEMUMachine(object):
except:
self._popen.kill()
- exitcode = self._popen.wait()
- if exitcode < 0:
- sys.stderr.write('qemu received signal %i: %s\n' % (-exitcode, ' '.join(self._args)))
self._load_io_log()
self._post_shutdown()
self._popen = None
--
2.11.0.259.g40922b1
next prev parent reply other threads:[~2017-03-22 16:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-22 16:00 [Qemu-devel] [PATCH 0/3] script for crash-testing -device Eduardo Habkost
2017-03-22 16:00 ` Eduardo Habkost [this message]
2017-03-22 16:00 ` [Qemu-devel] [PATCH 2/3] qtest.py: Support QTEST_LOG environment variable Eduardo Habkost
2017-03-22 16:00 ` [Qemu-devel] [PATCH 3/3] scripts: Test script to look for -device crashes Eduardo Habkost
2017-03-22 19:13 ` [Qemu-devel] [PATCH 0/3] script for crash-testing -device Eduardo Habkost
2017-03-23 15:43 ` Thomas Huth
2017-03-23 20:12 ` Eduardo Habkost
2017-03-24 12:42 ` Marcel Apfelbaum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170322160052.2820-2-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=armbru@redhat.com \
--cc=marcel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).