qemu-patch-raspberry4/python/qemu
John Snow 193bf1c061 python/machine.py: split shutdown into hard and soft flavors
This is done primarily to avoid the 'bare except' pattern, which
suppresses all exceptions during shutdown and can obscure errors.

Replace this with a pattern that isolates the different kind of shutdown
paradigms (_hard_shutdown and _soft_shutdown), and a new fallback shutdown
handler (_do_shutdown) that gracefully attempts one before the other.

This split now also ensures that no matter what happens,
_post_shutdown() is always invoked.

shutdown() changes in behavior such that if it attempts to do a graceful
shutdown and is unable to, it will now always raise an exception to
indicate this. This can be avoided by the test writer in three ways:

1. If the VM is expected to have already exited or is in the process of
exiting, wait() can be used instead of shutdown() to clean up resources
instead. This helps avoid race conditions in shutdown.

2. If a test writer is expecting graceful shutdown to fail, shutdown
should be called in a try...except block.

3. If the test writer has no interest in performing a graceful shutdown
at all, kill() can be used instead.

Handling shutdown in this way makes it much more explicit which type of
shutdown we want and allows the library to report problems with this
process.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Tested-by: Cleber Rosa <crosa@redhat.com>
Message-Id: <20200710050649.32434-11-jsnow@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2020-07-14 22:22:22 +02:00
..
.flake8 python/qemu: delint; add flake8 config 2020-05-31 18:25:30 +02:00
__init__.py python/qemu: Remove unneeded imports in __init__ 2019-12-16 18:39:51 -05:00
accel.py python/qemu: delint; add flake8 config 2020-05-31 18:25:30 +02:00
console_socket.py python/qemu: Add ConsoleSocket for optional use in QEMUMachine 2020-07-11 15:53:00 +01:00
machine.py python/machine.py: split shutdown into hard and soft flavors 2020-07-14 22:22:22 +02:00
pylintrc python/qemu: delint and add pylintrc 2020-05-31 18:25:30 +02:00
qmp.py python/qemu/qmp: assert sockfile is not None 2020-05-31 18:25:31 +02:00
qtest.py python/qemu/qtest: Check before accessing _qtest 2020-05-31 18:25:31 +02:00