diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2020-02-17 18:02:42 +0300 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@redhat.com> | 2020-05-31 18:25:07 +0200 |
commit | e0e925a61141552bca7277d06516ad78258423da (patch) | |
tree | c28f30841a437963631e6ede2f504e73d3798470 /python | |
parent | 2d110c11497ac52d5ce9f4b116463cdb8c3f4ad5 (diff) |
python/qemu/machine: add kill() method
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>
Diffstat (limited to 'python')
-rw-r--r-- | python/qemu/machine.py | 12 |
1 files 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 @@ class QEMUMachine(object): 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 @@ class QEMUMachine(object): 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 @@ class QEMUMachine(object): 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 @@ class QEMUMachine(object): self._launched = False + def kill(self): + self.shutdown(hard=True) + def set_qmp_monitor(self, enabled=True): """ Set the QMP monitor. |