From 1f9b462bd31e72c2cb50b49e23abbe052b115186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Wed, 5 Jun 2019 18:22:31 +0200 Subject: [PATCH] Added 'provides network' checkbox to VM settings A simple checkbox in the 'Advanced' tab. Does not allow disabling 'provides_network' if the VM is in use as NetVM; instead, a tooltip informs the user which VMs use it. fixes QubesOS/qubes-issues#5079 --- qubesmanager/settings.py | 19 +++++++++++++++++++ ui/settingsdlg.ui | 19 +++++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 40ec22b..786cb5c 100644 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -745,6 +745,17 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): else: self.dvm_template_checkbox.setVisible(False) + self.provides_network_checkbox.setChecked( + getattr(self.vm, 'provides_network', False)) + if self.provides_network_checkbox.isChecked(): + domains_using = [vm.name for vm in self.vm.connected_vms] + if domains_using: + self.provides_network_checkbox.setEnabled(False) + self.provides_network_checkbox.setToolTip( + "Cannot change this setting while this qube is used as a " + "NetVM by the following qubes:\n" + + "\n".join(domains_using)) + def enable_seamless(self): self.vm.run_service_for_stdio("qubes.SetGuiMode", input=b'SEAMLESS') @@ -815,6 +826,14 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog): except Exception as ex: # pylint: disable=broad-except msg.append(str(ex)) + if getattr(self.vm, 'provides_network', False) != \ + self.provides_network_checkbox.isChecked(): + try: + self.vm.provides_network = \ + self.provides_network_checkbox.isChecked() + 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 4c04ce4..ef7b307 100644 --- a/ui/settingsdlg.ui +++ b/ui/settingsdlg.ui @@ -29,7 +29,7 @@ - 0 + 1 @@ -792,7 +792,7 @@ border-width: 1px; 15 - + Default DispVM: @@ -802,17 +802,17 @@ border-width: 1px; - + - + Boot qube from CDROM - + @@ -838,7 +838,14 @@ The qube must be running to disable seamless mode; this setting is not persisten - + + + + Provides network + + + +