From 20cabb5563ae4ed1ddfac0a1e383c7ba1e806896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Sat, 24 Mar 2018 22:53:22 +0100 Subject: [PATCH] Check if VM needs killing before murdering it In some cases, when the user waited some time before force-killing a VM, it could be already dead. fixes QubesOS/qubes-issues#3730 --- qubesmanager/qube_manager.py | 7 ++++++- test-packages/qubesadmin/exc.py | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index eb41bca..05bf1d9 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -192,7 +192,12 @@ class VmShutdownMonitor(QtCore.QObject): self.tr("Wait another {0} seconds...").format( self.shutdown_time / 1000)) if reply == 0: - vm.kill() + try: + vm.kill() + except exc.QubesVMNotStartedError: + # the VM shut down while the user was thinking about + # shutting it down + pass self.restart_vm_if_needed() else: self.shutdown_started = datetime.now() diff --git a/test-packages/qubesadmin/exc.py b/test-packages/qubesadmin/exc.py index 22a3a27..90b4d3c 100644 --- a/test-packages/qubesadmin/exc.py +++ b/test-packages/qubesadmin/exc.py @@ -4,3 +4,6 @@ class QubesException(BaseException): pass + +class QubesVMNotStartedError(BaseException): + pass \ No newline at end of file