[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/25] python/qemu/machine: add kill() method
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 08/25] python/qemu/machine: add kill() method |
Date: |
Sun, 31 May 2020 18:38:29 +0200 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Add method to hard-kill vm, without any quit commands.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Message-Id: <20200217150246.29180-19-vsementsov@virtuozzo.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
python/qemu/machine.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index b9a98e2c86..d2f531f1b4 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -342,7 +342,7 @@ def wait(self):
self._load_io_log()
self._post_shutdown()
- def shutdown(self, has_quit=False):
+ def shutdown(self, has_quit=False, hard=False):
"""
Terminate the VM and clean up
"""
@@ -354,7 +354,9 @@ def shutdown(self, has_quit=False):
self._console_socket = None
if self.is_running():
- if self._qmp:
+ if hard:
+ self._popen.kill()
+ elif self._qmp:
try:
if not has_quit:
self._qmp.cmd('quit')
@@ -368,7 +370,8 @@ def shutdown(self, has_quit=False):
self._post_shutdown()
exitcode = self.exitcode()
- if exitcode is not None and exitcode < 0:
+ if exitcode is not None and exitcode < 0 and \
+ not (exitcode == -9 and hard):
msg = 'qemu received signal %i: %s'
if self._qemu_full_args:
command = ' '.join(self._qemu_full_args)
@@ -378,6 +381,9 @@ def shutdown(self, has_quit=False):
self._launched = False
+ def kill(self):
+ self.shutdown(hard=True)
+
def set_qmp_monitor(self, enabled=True):
"""
Set the QMP monitor.
--
2.21.3
- [PULL 00/25] python-next patches for 2020-05-31, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 01/25] scripts/qemugdb: Remove shebang header, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 02/25] scripts/qemu-gdb: Use Python 3 interpreter, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 03/25] scripts/qmp: Use Python 3 interpreter, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 04/25] scripts/kvm/vmxcap: Use Python 3 interpreter and add pseudo-main(), Philippe Mathieu-Daudé, 2020/05/31
- [PULL 05/25] scripts/modules/module_block: Use Python 3 interpreter & add pseudo-main, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 06/25] scripts/qmp: Fix shebang and imports, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 07/25] python: remove more instances of sys.version_info, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 08/25] python/qemu/machine: add kill() method,
Philippe Mathieu-Daudé <=
- [PULL 09/25] python/qemu/machine: remove logging configuration, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 10/25] python/qemu: delint and add pylintrc, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 11/25] python/qemu: delint; add flake8 config, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 12/25] python/qemu: remove Python2 style super() calls, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 13/25] python/qemu: fix socket.makefile() typing, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 14/25] python/qemu: Adjust traceback typing, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 15/25] python/qemu/qmp: use True/False for non/blocking modes, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 16/25] python/qemu/qmp: assert sockfile is not None, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 17/25] python/qemu/qtest: Check before accessing _qtest, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 18/25] tests/vm: Pass --debug through for vm-boot-ssh, Philippe Mathieu-Daudé, 2020/05/31