Warning on shutting down a VM that attached blk devices to other VMs
This commit is contained in:
parent
42828835cc
commit
d2a75bae4c
@ -182,6 +182,9 @@ class BackupVMsWindow(Ui_Backup, QWizard):
|
|||||||
if len(vms) == 0:
|
if len(vms) == 0:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
for vm in vms:
|
||||||
|
self.blk_manager.check_if_serves_as_backend(vm)
|
||||||
|
|
||||||
reply = QMessageBox.question(None, "VM Shutdown Confirmation",
|
reply = QMessageBox.question(None, "VM Shutdown Confirmation",
|
||||||
"Are you sure you want to power down the following VMs: <b>{0}</b>?<br>"
|
"Are you sure you want to power down the following VMs: <b>{0}</b>?<br>"
|
||||||
"<small>This will shutdown all the running applications within them.</small>".format(', '.join(names)),
|
"<small>This will shutdown all the running applications within them.</small>".format(', '.join(names)),
|
||||||
|
@ -1218,6 +1218,8 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow):
|
|||||||
vm = self.get_selected_vm()
|
vm = self.get_selected_vm()
|
||||||
assert vm.is_running()
|
assert vm.is_running()
|
||||||
|
|
||||||
|
self.blk_manager.check_if_serves_as_backend(vm)
|
||||||
|
|
||||||
reply = QMessageBox.question(None, "VM Shutdown Confirmation",
|
reply = QMessageBox.question(None, "VM Shutdown Confirmation",
|
||||||
"Are you sure you want to power down the VM <b>'{0}'</b>?<br>"
|
"Are you sure you want to power down the VM <b>'{0}'</b>?<br>"
|
||||||
"<small>This will shutdown all the running applications within this VM.</small>".format(vm.name),
|
"<small>This will shutdown all the running applications within this VM.</small>".format(vm.name),
|
||||||
@ -1690,6 +1692,19 @@ class QubesBlockDevicesManager():
|
|||||||
trayIcon.showMessage ("Qubes VM Manager", "{0} - detaching {1}".format(vm.name, dev_name), msecs=3000)
|
trayIcon.showMessage ("Qubes VM Manager", "{0} - detaching {1}".format(vm.name, dev_name), msecs=3000)
|
||||||
qubesutils.block_detach(None, dev_id, vm_xid)
|
qubesutils.block_detach(None, dev_id, vm_xid)
|
||||||
|
|
||||||
|
def check_if_serves_as_backend(self, vm):
|
||||||
|
serves_for = []
|
||||||
|
for d in self.attached_devs:
|
||||||
|
if self.attached_devs[d]['backend_name'] == vm.name:
|
||||||
|
serves_for.append((self.attached_devs[d]['dev'], self.attached_devs[d]['attached_to']['vm']))
|
||||||
|
|
||||||
|
if len(serves_for) > 0:
|
||||||
|
msg = "VM <b>" + vm.name + "</b> attaches block devices to other VMs: "
|
||||||
|
msg += ', '.join(["<b>"+v+"</b>("+d+")" for (d,v) in serves_for ])
|
||||||
|
msg += ".<br><br> Shutting the VM down will dettach the devices from them."
|
||||||
|
|
||||||
|
QMessageBox.warning (None, "Warning!", msg)
|
||||||
|
|
||||||
|
|
||||||
class QubesTrayIcon(QSystemTrayIcon):
|
class QubesTrayIcon(QSystemTrayIcon):
|
||||||
def __init__(self, icon):
|
def __init__(self, icon):
|
||||||
|
Loading…
Reference in New Issue
Block a user