From 1a5a1fa7ee807cc03662f00e5a925953d5dbb4bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Tue, 16 Jan 2018 19:56:45 +0100 Subject: [PATCH] Minor fixes to virt_mode select pull request Changes: - added hints about "which virt mode should I use" - changed displayed virt modes to show modes in all caps closes #44 --- qubesmanager/settings.py | 16 ++++++++-------- qubesmanager/utils.py | 4 +++- ui/settingsdlg.ui | 29 ++++++++++++++++++++++------- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 9a82cc6..2c4ed15 100755 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -524,7 +524,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog): try: if self.virt_mode.currentIndex() != self.virt_mode_idx: - self.vm.virt_mode = self.selected_virt_mode() + self.vm.virt_mode = self.selected_virt_mode().lower() self.anything_changed = True except Exception as ex: msg.append(str(ex)) @@ -544,13 +544,13 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog): self.update_pvh_kernel_version_warning() def update_pv_warning(self): - if self.selected_virt_mode() == 'pv': + if self.selected_virt_mode() == 'PV': self.pv_warning.show() else: self.pv_warning.hide() def update_virt_mode_list(self): - choices = ['hvm', 'pv'] + choices = ['HVM', 'PV'] if hasattr(self, 'dev_list'): devs_attached = self.dev_list.selected_list.count() != 0 @@ -560,7 +560,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog): if devs_attached: self.pvh_mode_hidden.show() else: - choices.insert(0, 'pvh') + choices.insert(0, 'PVH') self.pvh_mode_hidden.hide() if hasattr(self, 'virt_mode_list'): @@ -573,8 +573,8 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog): # XXX: Hardcoded default value. self.virt_mode_list, self.virt_mode_idx = utils.prepare_choice( - self.virt_mode, self.vm, 'virt_mode', choices, 'hvm', - allow_default=True) + self.virt_mode, self.vm, 'virt_mode', choices, 'HVM', + allow_default=True, transform=(lambda x: str(x).upper())) if old_mode is not None: self.virt_mode.setCurrentIndex(self.virt_mode_list.index(old_mode)) @@ -585,7 +585,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog): self.update_pvh_kernel_version_warning() def update_pvh_kernel_version_warning(self): - if self.selected_virt_mode() != 'pvh': + if self.selected_virt_mode() != 'PVH': self.pvh_kernel_version_warning.hide() return @@ -723,7 +723,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog): self.update_virt_mode_list() def update_pvh_dont_support_devs(self): - if self.selected_virt_mode() == 'pvh': + if self.selected_virt_mode() == 'PVH': self.dev_list.setEnabled(False) self.pvh_dont_support_devs.setVisible(True) else: diff --git a/qubesmanager/utils.py b/qubesmanager/utils.py index cca3647..25e9f8f 100644 --- a/qubesmanager/utils.py +++ b/qubesmanager/utils.py @@ -34,7 +34,7 @@ def _filter_internal(vm): def prepare_choice(widget, holder, propname, choice, default, filter_function=None, *, icon_getter=None, allow_internal=None, allow_default=False, - allow_none=False): + allow_none=False, transform=None): # for newly created vms, set propname to None @@ -55,6 +55,8 @@ def prepare_choice(widget, holder, propname, choice, default, if propname is not None: oldvalue = getattr(holder, propname) + if transform is not None: + oldvalue = transform(oldvalue) is_default = holder.property_is_default(propname) else: oldvalue = object() # won't match for identity diff --git a/ui/settingsdlg.ui b/ui/settingsdlg.ui index b4e913f..73257e5 100644 --- a/ui/settingsdlg.ui +++ b/ui/settingsdlg.ui @@ -6,7 +6,7 @@ 0 0 - 773 + 813 573 @@ -409,7 +409,7 @@ QFormLayout::AllNonFixedFieldsGrow - + Kernel: @@ -432,7 +432,7 @@ - PVH mode requires Linux 4.11 or newer. + WARNING: PVH mode requires Linux 4.11 or newer. true @@ -490,7 +490,7 @@ QFormLayout::AllNonFixedFieldsGrow - + Mode: @@ -500,10 +500,10 @@ - + - + @@ -523,7 +523,7 @@ - + @@ -540,6 +540,21 @@ + + + + + true + + + + PVH mode is recommended if possible (Linux kernel 4.11 or newer, no PCI passthrough). For Windows qubes always use HVM. + + + true + + +