From ef8be34622d525fcce9b32039846f0a1ef4783be Mon Sep 17 00:00:00 2001 From: donoban Date: Sun, 10 Jan 2021 19:10:36 +0100 Subject: [PATCH] Cascade shutdown https://github.com/QubesOS/qubes-issues/issues/6109 --- qubesmanager/qube_manager.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index eaa8e43..4b5dad6 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -22,6 +22,7 @@ # # import subprocess +import time from datetime import datetime, timedelta from functools import partial from os import path @@ -1249,6 +1250,25 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): def shutdown_vm(self, vm, shutdown_time=vm_shutdown_timeout, check_time=vm_restart_check_timeout, and_restart=False): try: + connected_vms = [x for x in vm.connected_vms if x.is_running()] + if len(connected_vms) > 0: + reply = QMessageBox.question( + self, self.tr("Qube Shutdown Confirmation"), + self.tr("There are some qubes connected to '{0}'!" + "
Do you want to shutdown: " + "'{1}'?").format( + vm.name ,", ".join([x.name for x in connected_vms])), + QMessageBox.Yes | QMessageBox.Cancel) + + if reply == QMessageBox.Yes: + with common_threads.busy_cursor(): + for connected_vm in connected_vms: + self.shutdown_vm(connected_vm) + while connected_vm.is_running(): + time.sleep(0.5) + else: + return + vm.shutdown() except exc.QubesException as ex: QMessageBox.warning(