diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/qemu.py | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/scripts/qemu.py b/scripts/qemu.py index f80b008f7f..8d3d24dd2b 100644 --- a/scripts/qemu.py +++ b/scripts/qemu.py @@ -13,12 +13,22 @@ # import errno +import logging import os import sys import subprocess import qmp.qmp +LOG = logging.getLogger(__name__) + + +class QEMUMachineError(Exception): + """ + Exception called when an error in QEMUMachine happens. + """ + + class MonitorResponseError(qmp.qmp.QMPError): ''' Represents erroneous QMP monitor reply @@ -107,18 +117,21 @@ class QEMUMachine(object): # In iotest.py, the qmp should always use unix socket. assert self._qmp.is_scm_available() if self._socket_scm_helper is None: - print >>sys.stderr, "No path to socket_scm_helper set" - return -1 + raise QEMUMachineError("No path to socket_scm_helper set") if not os.path.exists(self._socket_scm_helper): - print >>sys.stderr, "%s does not exist" % self._socket_scm_helper - return -1 + raise QEMUMachineError("%s does not exist" % + self._socket_scm_helper) fd_param = ["%s" % self._socket_scm_helper, "%d" % self._qmp.get_sock_fd(), "%s" % fd_file_path] devnull = open('/dev/null', 'rb') - proc = subprocess.Popen(fd_param, stdin=devnull, stdout=sys.stdout, - stderr=sys.stderr) - return proc.wait() + proc = subprocess.Popen(fd_param, stdin=devnull, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + output = proc.communicate()[0] + if output: + LOG.debug(output) + + return proc.returncode @staticmethod def _remove_if_exists(path): @@ -202,8 +215,8 @@ class QEMUMachine(object): exitcode = self._popen.wait() if exitcode < 0: - sys.stderr.write('qemu received signal %i: %s\n' - % (-exitcode, ' '.join(self._args))) + LOG.warn('qemu received signal %i: %s', -exitcode, + ' '.join(self._args)) self._load_io_log() self._post_shutdown() |