From faae2d00264bba156e5dad5c23fa4da23577060f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Tue, 19 Feb 2019 22:15:03 +0100 Subject: [PATCH 1/5] Added warning when setting NetVM When NetVM is set to something else than default_dispvm has set, a warning icon appears. --- qubesmanager/settings.py | 26 ++++++++++++++++++++++++++ ui/settingsdlg.ui | 15 ++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 07baf7a..4cca8bf 100755 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -414,6 +414,8 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): (lambda vm: vm.provides_network), allow_default=True, allow_none=True) + self.netVM.currentIndexChanged.connect(self.check_warn_dispvmnetvm) + self.include_in_backups.setChecked(self.vm.include_in_backups) try: @@ -547,6 +549,27 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): "allowed value.")) self.init_mem.setValue(self.max_mem_size.value() / 10) + def check_warn_dispvmnetvm(self): + if not hasattr(self.vm, 'default_dispvm'): + self.warn_netvm_dispvm.setVisible(False) + return + dispvm = self.default_dispvm_list[ + self.default_dispvm.currentIndex()] + own_netvm = self.netvm_list[self.netVM.currentIndex()] + + if dispvm == qubesadmin.DEFAULT: + dispvm = self.vm.property_get_default('default_dispvm') + dispvm_netvm = getattr(dispvm, 'netvm', None) + + if own_netvm == qubesadmin.DEFAULT: + own_netvm = self.vm.property_get_default('netvm') + + if dispvm_netvm and dispvm_netvm != own_netvm: + self.warn_netvm_dispvm.setVisible(True) + else: + self.warn_netvm_dispvm.setVisible(False) + + def rename_vm(self): dependencies = admin_utils.vm_dependencies(self.vm.app, self.vm) @@ -691,7 +714,10 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): None, (lambda vm: getattr(vm, 'template_for_dispvms', False)), allow_default=True, allow_none=True) + self.default_dispvm.currentIndexChanged.connect( + self.check_warn_dispvmnetvm) + self.check_warn_dispvmnetvm() self.update_virt_mode_list() windows_running = \ diff --git a/ui/settingsdlg.ui b/ui/settingsdlg.ui index 833d31e..e0c0c48 100644 --- a/ui/settingsdlg.ui +++ b/ui/settingsdlg.ui @@ -29,7 +29,7 @@ - 1 + 0 @@ -379,6 +379,19 @@ + + + + <html><head/><body><p>Caution: default DispVM template has a different Networking setting than this qube. Unexpected network access may occur!</p></body></html> + + + + + + :/warning.png + + + From ef6288f1ffcbb0d36086ca0bf74576f974a67e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Wed, 6 Feb 2019 14:35:29 +0100 Subject: [PATCH 2/5] Added "set as dvm template" to VM settings Added an 'Advanced' settings checkbox that allows the user to set a given VM as template fo dispvms. It sets both the template_for_dispvms property and the appmenus-dispvm feature - instead of delving into particulars of how and which should be set, the user can just turn off the whole setting if they want to make some changes in the vm and then turn it on again. fixes QubesOS/qubes-issues#4004 --- qubesmanager/settings.py | 17 +++++++++++++++++ ui/settingsdlg.ui | 18 ++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 07baf7a..f707162 100755 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -704,6 +704,11 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): self.seamless_on_button.clicked.connect(self.enable_seamless) self.seamless_off_button.clicked.connect(self.disable_seamless) + if hasattr(self.vm, "template_for_dispvms"): + self.dvm_template_checkbox.setChecked(self.vm.template_for_dispvms) + else: + self.dvm_template_checkbox.setVisible(False) + def enable_seamless(self): self.vm.run_service_for_stdio("qubes.SetGuiMode", input=b'SEAMLESS') @@ -759,6 +764,18 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): except Exception as ex: # pylint: disable=broad-except msg.append(str(ex)) + if getattr(self.vm, "template_for_dispvms", False) != \ + self.dvm_template_checkbox.isChecked(): + try: + self.vm.template_for_dispvms = \ + self.dvm_template_checkbox.isChecked() + if self.dvm_template_checkbox.isChecked(): + self.vm.features["appmenus-dispvm"] = True + else: + del self.vm.features["appmenus-dispvm"] + except Exception as ex: # pylint: disable=broad-except + msg.append(str(ex)) + return msg def include_in_balancing_changed(self, state): diff --git a/ui/settingsdlg.ui b/ui/settingsdlg.ui index 833d31e..d7d5d3d 100644 --- a/ui/settingsdlg.ui +++ b/ui/settingsdlg.ui @@ -779,7 +779,7 @@ border-width: 1px; 15 - + Default DispVM: @@ -789,17 +789,17 @@ border-width: 1px; - + - + Boot qube from CDROM - + @@ -825,6 +825,16 @@ The qube must be running to disable seamless mode; this setting is not persisten + + + + + + + Allow starting DisposableVMs from this qube + + + From d23dafed2847e5b84acba9f9964f6bda42d583bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Sat, 23 Feb 2019 18:19:58 +0100 Subject: [PATCH 3/5] Fixed incorrect behavior after 'Apply' in Settings Changes in some fields (to be precise, drop-downs) were discarded in VM Settings when changed after an 'Apply' and before an 'OK'. fixes QubesOS/qubes-issues#4833 --- qubesmanager/settings.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 07baf7a..0e2882d 100755 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -164,6 +164,17 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): self.tabWidget.currentChanged.connect(self.current_tab_changed) + # Initialize several auxillary variables for pylint's sake + self.netvm_idx = None + self.kernel_idx = None + self.label_idx = None + self.template_idx = None + self.root_img_size = None + self.priv_img_size = None + self.default_dispvm_idx = None + self.virt_mode_idx = None + self.virt_mode_list = None + ###### basic tab self.__init_basic_tab__() self.rename_vm_button.clicked.connect(self.rename_vm) @@ -467,6 +478,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): if self.vmlabel.currentIndex() != self.label_idx: label = self.label_list[self.vmlabel.currentIndex()] self.vm.label = label + self.label_idx = self.vmlabel.currentIndex() except qubesadmin.exc.QubesException as ex: msg.append(str(ex)) @@ -475,6 +487,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): if self.template_name.currentIndex() != self.template_idx: self.vm.template = \ self.template_list[self.template_name.currentIndex()] + self.template_idx = self.template_name.currentIndex() except qubesadmin.exc.QubesException as ex: msg.append(str(ex)) @@ -482,6 +495,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): try: if self.netVM.currentIndex() != self.netvm_idx: self.vm.netvm = self.netvm_list[self.netVM.currentIndex()] + self.netvm_idx = self.netVM.currentIndex() except qubesadmin.exc.QubesException as ex: msg.append(str(ex)) @@ -514,6 +528,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): if self.priv_img_size != priv_size: try: self.vm.volumes['private'].resize(priv_size * 1024**2) + self.priv_img_size = priv_size except qubesadmin.exc.QubesException as ex: msg.append(str(ex)) @@ -522,6 +537,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): if self.root_img_size != sys_size: try: self.vm.volumes['root'].resize(sys_size * 1024**2) + self.root_img_size = sys_size except qubesadmin.exc.QubesException as ex: msg.append(str(ex)) @@ -742,6 +758,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): if self.kernel.currentIndex() != self.kernel_idx: self.vm.kernel = self.kernel_list[ self.kernel.currentIndex()] + self.kernel_idx = self.kernel.currentIndex() except qubesadmin.exc.QubesException as ex: msg.append(str(ex)) @@ -750,12 +767,14 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): if self.default_dispvm.currentIndex() != self.default_dispvm_idx: self.vm.default_dispvm = \ self.default_dispvm_list[self.default_dispvm.currentIndex()] + self.default_dispvm_idx = self.default_dispvm.currentIndex() except qubesadmin.exc.QubesException as ex: msg.append(str(ex)) try: if self.virt_mode.currentIndex() != self.virt_mode_idx: self.vm.virt_mode = self.selected_virt_mode() + self.virt_mode_idx = self.virt_mode.currentIndex() except Exception as ex: # pylint: disable=broad-except msg.append(str(ex)) @@ -811,7 +830,6 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): self.virt_mode.clear() - # pylint: disable=attribute-defined-outside-init self.virt_mode_list, self.virt_mode_idx = utils.prepare_choice(\ self.virt_mode, self.vm, 'virt_mode', choices, None,\ allow_default=True, transform=(lambda x: str(x).upper())) From b31a154e32290706325a3463adac55d8bbe6f0fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Tue, 26 Feb 2019 19:31:41 +0100 Subject: [PATCH 4/5] Fixed error in detecting dvm-template having different NetVM when the currect VM is the same as the dvm_template, there should be no warning fixes QubesOS/qubes-issues#4844 --- qubesmanager/settings.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 429ae27..ad2157b 100755 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -559,6 +559,11 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): if dispvm == qubesadmin.DEFAULT: dispvm = self.vm.property_get_default('default_dispvm') + + if dispvm == self.vm: + self.warn_netvm_dispvm.setVisible(False) + return + dispvm_netvm = getattr(dispvm, 'netvm', None) if own_netvm == qubesadmin.DEFAULT: From 26779a482652031cc3c73bfd558cc63eda8d8f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Tue, 26 Feb 2019 21:05:42 +0100 Subject: [PATCH 5/5] Fixed error in displaying error on VM Rename VM rename was incorrectly trying to display an error by itself and not use QThreads embedded mechanism. fixes QubesOS/qubes-issues#4843 fixes QubesOS/qubes-issues#4767 --- qubesmanager/settings.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 429ae27..183f805 100755 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -68,22 +68,18 @@ class RenameVMThread(QtCore.QThread): setattr(holder, prop, new_vm) except qubesadmin.exc.QubesException: failed_props += [(holder, prop)] - if not failed_props: del self.vm.app.domains[self.vm.name] else: list_text = utils.format_dependencies_list(failed_props) - - QtGui.QMessageBox.warning( - None, - self.tr("Warning: rename partially unsuccessful"), - self.tr("Some properties could not be changed to the new " - "name. The system has now both {} and {} qubes. " - "To resolve this, please check and change the " - "following properties and remove the qube {} " - "manually.
").format( - self.vm.name, self.vm.name, self.vm.name)\ - + list_text) + self.msg = (self.tr("Warning: rename partially unsuccessful!"), + self.tr("Some properties could not be changed to " + "the new name. The system has now both {} " + "and {} qubes. To resolve this, please " + "check and change the following properties " + "and remove the qube {} manually.
" + ).format(self.vm.name, self.vm.name, + self.vm.name) + list_text) except qubesadmin.exc.QubesException as ex: self.msg = ("Rename error!", str(ex))