Added warning when setting NetVM

When NetVM is set to something else than default_dispvm has set, a warning
icon appears.
This commit is contained in:
Marta Marczykowska-Górecka 2019-02-19 22:15:03 +01:00
parent 52188318b8
commit faae2d0026
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B
2 changed files with 40 additions and 1 deletions

View File

@ -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 = \

View File

@ -29,7 +29,7 @@
<locale language="English" country="UnitedStates"/>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="basic_tab">
<property name="locale">
@ -379,6 +379,19 @@
</item>
</layout>
</item>
<item row="2" column="3">
<widget class="QLabel" name="warn_netvm_dispvm">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Caution: default DispVM template has a different Networking setting than this qube. Unexpected network access may occur!&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../resources.qrc">:/warning.png</pixmap>
</property>
</widget>
</item>
</layout>
</widget>
</item>