Pull request
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE+ber27ys35W+dsvQfe+BBqr8OQ4FAmGUTcIACgkQfe+BBqr8 OQ6rvBAAqj2+TqbRcYbBGGCdxbIG7no6GvXGAElfBGZGfDhfn0QY8FelYn4tDwBg 6QBMgNQSzDDSIs47dFZaLPE1yifZ4XqKA3Gg7B9ll5wT/qwbyv5NJOXyLEImtvrh 9lxWddEzNX8FwlArCAHTEWdgkt6O2eHMcT/uk08Ik9RPYAk5ePZLU4awc0VFhDv8 uHDGtgOy8QrpIWORZC3CbVxx/onhxBj24wq5x+3FmDpYIZvI2SFAwKrk/bsJD3X7 BMtNJ5KXRrpvZH6Qkz/xUS/8frAreOeV7EN3EdB31VX60LnUbuYXxAer/vSBT1LR VALxcm+xHJLW38xhgzcWO/Z/PFGyj3R/M2xvsX+SucG93FbVqdNspUkTBIFVIxkv BMpfIRvsiUgBZt2CX70eKs9wmwPwG8w8kcoTqmaSkf8kvVX8xqA19k+U3j/67dkV mn3YQj5ub5Zh024t4yMmMcNGxPWUd29nXLm2RerEA27IDRgrDMfjUZj6HJNB9Gfm 4h/Ij0nPTkxjNCtNvEh0mvzjrpLCVHdrR7RkomLxOZDYFMoTD+Kyw2apn4AuAu/7 ba0BW4bvs+048q2XW8AfprUaZ8wJQy+ALteZOOrq7rvgBR7iXYjPoHtir5Jqptzw 4NHMNihF+fYVELuuWEJLAMkViA/nhMHxOiHprpcdRMQFaClt5iM= =2l59 -----END PGP SIGNATURE----- Merge tag 'python-pull-request' of https://gitlab.com/jsnow/qemu into staging Pull request # gpg: Signature made Wed 17 Nov 2021 01:33:06 AM CET # gpg: using RSA key F9B7ABDBBCACDF95BE76CBD07DEF8106AAFC390E # gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>" [full] * tag 'python-pull-request' of https://gitlab.com/jsnow/qemu: scripts/device-crash-test: hide tracebacks for QMP connect errors scripts/device-crash-test: don't emit AQMP connection errors to stdout scripts/device-crash-test: simplify Exception handling python/aqmp: fix ConnectError string method python/aqmp: Fix disconnect during capabilities negotiation Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
commit
8d5fcb1990
|
@ -79,7 +79,11 @@ class ConnectError(AQMPError):
|
||||||
self.exc: Exception = exc
|
self.exc: Exception = exc
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"{self.error_message}: {self.exc!s}"
|
cause = str(self.exc)
|
||||||
|
if not cause:
|
||||||
|
# If there's no error string, use the exception name.
|
||||||
|
cause = exception_summary(self.exc)
|
||||||
|
return f"{self.error_message}: {cause}"
|
||||||
|
|
||||||
|
|
||||||
class StateError(AQMPError):
|
class StateError(AQMPError):
|
||||||
|
@ -623,13 +627,21 @@ class AsyncProtocol(Generic[T]):
|
||||||
def _done(task: Optional['asyncio.Future[Any]']) -> bool:
|
def _done(task: Optional['asyncio.Future[Any]']) -> bool:
|
||||||
return task is not None and task.done()
|
return task is not None and task.done()
|
||||||
|
|
||||||
# NB: We can't rely on _bh_tasks being done() here, it may not
|
# Are we already in an error pathway? If either of the tasks are
|
||||||
# yet have had a chance to run and gather itself.
|
# already done, or if we have no tasks but a reader/writer; we
|
||||||
|
# must be.
|
||||||
|
#
|
||||||
|
# NB: We can't use _bh_tasks to check for premature task
|
||||||
|
# completion, because it may not yet have had a chance to run
|
||||||
|
# and gather itself.
|
||||||
tasks = tuple(filter(None, (self._writer_task, self._reader_task)))
|
tasks = tuple(filter(None, (self._writer_task, self._reader_task)))
|
||||||
error_pathway = _done(self._reader_task) or _done(self._writer_task)
|
error_pathway = _done(self._reader_task) or _done(self._writer_task)
|
||||||
|
if not tasks:
|
||||||
|
error_pathway |= bool(self._reader) or bool(self._writer)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Try to flush the writer, if possible:
|
# Try to flush the writer, if possible.
|
||||||
|
# This *may* cause an error and force us over into the error path.
|
||||||
if not error_pathway:
|
if not error_pathway:
|
||||||
await self._bh_flush_writer()
|
await self._bh_flush_writer()
|
||||||
except BaseException as err:
|
except BaseException as err:
|
||||||
|
@ -639,7 +651,7 @@ class AsyncProtocol(Generic[T]):
|
||||||
self.logger.debug("%s:\n%s\n", emsg, pretty_traceback())
|
self.logger.debug("%s:\n%s\n", emsg, pretty_traceback())
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
# Cancel any still-running tasks:
|
# Cancel any still-running tasks (Won't raise):
|
||||||
if self._writer_task is not None and not self._writer_task.done():
|
if self._writer_task is not None and not self._writer_task.done():
|
||||||
self.logger.debug("Cancelling writer task.")
|
self.logger.debug("Cancelling writer task.")
|
||||||
self._writer_task.cancel()
|
self._writer_task.cancel()
|
||||||
|
@ -652,7 +664,7 @@ class AsyncProtocol(Generic[T]):
|
||||||
self.logger.debug("Waiting for tasks to complete ...")
|
self.logger.debug("Waiting for tasks to complete ...")
|
||||||
await asyncio.wait(tasks)
|
await asyncio.wait(tasks)
|
||||||
|
|
||||||
# Lastly, close the stream itself. (May raise):
|
# Lastly, close the stream itself. (*May raise*!):
|
||||||
await self._bh_close_stream(error_pathway)
|
await self._bh_close_stream(error_pathway)
|
||||||
self.logger.debug("Disconnected.")
|
self.logger.debug("Disconnected.")
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ from itertools import chain
|
||||||
|
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python'))
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python'))
|
||||||
from qemu.machine import QEMUMachine
|
from qemu.machine import QEMUMachine
|
||||||
|
from qemu.aqmp import ConnectError
|
||||||
|
|
||||||
logger = logging.getLogger('device-crash-test')
|
logger = logging.getLogger('device-crash-test')
|
||||||
dbg = logger.debug
|
dbg = logger.debug
|
||||||
|
@ -317,9 +318,7 @@ class QemuBinaryInfo(object):
|
||||||
try:
|
try:
|
||||||
vm.launch()
|
vm.launch()
|
||||||
mi['runnable'] = True
|
mi['runnable'] = True
|
||||||
except KeyboardInterrupt:
|
except Exception:
|
||||||
raise
|
|
||||||
except:
|
|
||||||
dbg("exception trying to run binary=%s machine=%s", self.binary, machine, exc_info=sys.exc_info())
|
dbg("exception trying to run binary=%s machine=%s", self.binary, machine, exc_info=sys.exc_info())
|
||||||
dbg("log: %r", vm.get_log())
|
dbg("log: %r", vm.get_log())
|
||||||
mi['runnable'] = False
|
mi['runnable'] = False
|
||||||
|
@ -357,12 +356,12 @@ def checkOneCase(args, testcase):
|
||||||
dbg("will launch QEMU: %s", cmdline)
|
dbg("will launch QEMU: %s", cmdline)
|
||||||
vm = QEMUMachine(binary=binary, args=args)
|
vm = QEMUMachine(binary=binary, args=args)
|
||||||
|
|
||||||
|
exc = None
|
||||||
exc_traceback = None
|
exc_traceback = None
|
||||||
try:
|
try:
|
||||||
vm.launch()
|
vm.launch()
|
||||||
except KeyboardInterrupt:
|
except Exception as this_exc:
|
||||||
raise
|
exc = this_exc
|
||||||
except:
|
|
||||||
exc_traceback = traceback.format_exc()
|
exc_traceback = traceback.format_exc()
|
||||||
dbg("Exception while running test case")
|
dbg("Exception while running test case")
|
||||||
finally:
|
finally:
|
||||||
|
@ -370,8 +369,9 @@ def checkOneCase(args, testcase):
|
||||||
ec = vm.exitcode()
|
ec = vm.exitcode()
|
||||||
log = vm.get_log()
|
log = vm.get_log()
|
||||||
|
|
||||||
if exc_traceback is not None or ec != 0:
|
if exc is not None or ec != 0:
|
||||||
return {'exc_traceback':exc_traceback,
|
return {'exc': exc,
|
||||||
|
'exc_traceback':exc_traceback,
|
||||||
'exitcode':ec,
|
'exitcode':ec,
|
||||||
'log':log,
|
'log':log,
|
||||||
'testcase':testcase,
|
'testcase':testcase,
|
||||||
|
@ -459,6 +459,17 @@ def logFailure(f, level):
|
||||||
for l in f['log'].strip().split('\n'):
|
for l in f['log'].strip().split('\n'):
|
||||||
logger.log(level, "log: %s", l)
|
logger.log(level, "log: %s", l)
|
||||||
logger.log(level, "exit code: %r", f['exitcode'])
|
logger.log(level, "exit code: %r", f['exitcode'])
|
||||||
|
|
||||||
|
# If the Exception is merely a QMP connect error,
|
||||||
|
# reduce the logging level for its traceback to
|
||||||
|
# improve visual clarity.
|
||||||
|
if isinstance(f.get('exc'), ConnectError):
|
||||||
|
logger.log(level, "%s.%s: %s",
|
||||||
|
type(f['exc']).__module__,
|
||||||
|
type(f['exc']).__qualname__,
|
||||||
|
str(f['exc']))
|
||||||
|
level = logging.DEBUG
|
||||||
|
|
||||||
if f['exc_traceback']:
|
if f['exc_traceback']:
|
||||||
logger.log(level, "exception:")
|
logger.log(level, "exception:")
|
||||||
for l in f['exc_traceback'].split('\n'):
|
for l in f['exc_traceback'].split('\n'):
|
||||||
|
@ -503,6 +514,12 @@ def main():
|
||||||
lvl = logging.WARN
|
lvl = logging.WARN
|
||||||
logging.basicConfig(stream=sys.stdout, level=lvl, format='%(levelname)s: %(message)s')
|
logging.basicConfig(stream=sys.stdout, level=lvl, format='%(levelname)s: %(message)s')
|
||||||
|
|
||||||
|
if not args.debug:
|
||||||
|
# Async QMP, when in use, is chatty about connection failures.
|
||||||
|
# This script knowingly generates a ton of connection errors.
|
||||||
|
# Silence this logger.
|
||||||
|
logging.getLogger('qemu.aqmp.qmp_client').setLevel(logging.CRITICAL)
|
||||||
|
|
||||||
fatal_failures = []
|
fatal_failures = []
|
||||||
wl_stats = {}
|
wl_stats = {}
|
||||||
skipped = 0
|
skipped = 0
|
||||||
|
|
Loading…
Reference in New Issue