Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
donob4n committed Mar 6, 2019
2 parents 17fdb3c + 7874aa7 commit 6469dd8
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 18 deletions.
88 changes: 75 additions & 13 deletions qubesmanager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,18 @@ def run(self):
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.<br> ").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.<br>"
).format(self.vm.name, self.vm.name,
self.vm.name) + list_text)

except qubesadmin.exc.QubesException as ex:
self.msg = ("Rename error!", str(ex))
Expand Down Expand Up @@ -162,6 +158,17 @@ def __init__(self, vm, qapp, init_page="basic", parent=None):

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)
Expand Down Expand Up @@ -414,6 +421,8 @@ def __init_basic_tab__(self):
(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:
Expand Down Expand Up @@ -467,6 +476,7 @@ def __apply_basic_tab__(self):
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))

Expand All @@ -475,13 +485,15 @@ def __apply_basic_tab__(self):
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))

# vm netvm changed
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))

Expand Down Expand Up @@ -514,6 +526,7 @@ def __apply_basic_tab__(self):
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))

Expand All @@ -522,6 +535,7 @@ def __apply_basic_tab__(self):
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))

Expand All @@ -547,6 +561,32 @@ def check_mem_changes(self):
"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')

if dispvm == self.vm:
self.warn_netvm_dispvm.setVisible(False)
return

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)
Expand Down Expand Up @@ -691,7 +731,10 @@ def __init_advanced_tab__(self):
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 = \
Expand All @@ -704,6 +747,11 @@ def __init_advanced_tab__(self):
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')

Expand Down Expand Up @@ -742,6 +790,7 @@ def __apply_advanced_tab__(self):
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))

Expand All @@ -750,15 +799,29 @@ def __apply_advanced_tab__(self):
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))

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):
Expand Down Expand Up @@ -811,7 +874,6 @@ def update_virt_mode_list(self):

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()))
Expand Down
33 changes: 28 additions & 5 deletions ui/settingsdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -779,7 +792,7 @@ border-width: 1px;</string>
<property name="topMargin">
<number>15</number>
</property>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>Default DispVM:</string>
Expand All @@ -789,17 +802,17 @@ border-width: 1px;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="default_dispvm"/>
</item>
<item row="2" column="0" colspan="2">
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="boot_from_device_button">
<property name="text">
<string>Boot qube from CDROM</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QPushButton" name="seamless_on_button">
Expand All @@ -825,6 +838,16 @@ The qube must be running to disable seamless mode; this setting is not persisten
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="dvm_template_checkbox">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Allow starting DisposableVMs from this qube</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 6469dd8

Please sign in to comment.