Skip to content
Snippets Groups Projects
Commit e0e925a6 authored by Vladimir Sementsov-Ogievskiy's avatar Vladimir Sementsov-Ogievskiy Committed by Philippe Mathieu-Daudé
Browse files

python/qemu/machine: add kill() method


Add method to hard-kill vm, without any quit commands.

Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: default avatarAndrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Message-Id: <20200217150246.29180-19-vsementsov@virtuozzo.com>
Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
parent 2d110c11
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment