Added gui daemon options to VM settings

Added allow-fullscreen and allow-utf8-titles as options to VM settings

references QubesOS/qubes-issues#2304
This commit is contained in:
Marta Marczykowska-Górecka 2020-07-07 21:02:54 +02:00
parent a6a7560bab
commit a41908f92f
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B
3 changed files with 473 additions and 299 deletions

View File

@ -775,6 +775,27 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog):
except AttributeError:
self.run_in_debug_mode.setVisible(False)
utils.prepare_choice_data(
widget=self.allow_fullscreen,
choices=[
('(use system default)', None),
('allow', True),
('disallow', False)
],
selected_value=utils.get_boolean_feature(self.vm,
'gui-allow-fullscreen'))
self.allow_fullscreen_initial = self.allow_fullscreen.currentIndex()
utils.prepare_choice_data(
widget=self.allow_utf8,
choices=[
('(use system default)', None),
('allow', True),
('disallow', False)
],
selected_value=utils.get_boolean_feature(self.vm,
'gui-allow-utf8-titles'))
self.allow_utf8_initial = self.allow_utf8.currentIndex()
def enable_seamless(self):
self.vm.run_service_for_stdio("qubes.SetGuiMode", input=b'SEAMLESS')
@ -861,6 +882,28 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog):
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))
if self.allow_fullscreen_initial !=\
self.allow_fullscreen.currentIndex():
try:
if self.allow_fullscreen.currentData() is None:
del self.vm.features['gui-allow-fullscreen']
else:
self.vm.features['gui-allow-fullscreen'] = \
self.allow_fullscreen.currentData()
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))
if self.allow_utf8_initial !=\
self.allow_utf8.currentIndex():
try:
if self.allow_utf8.currentData() is None:
del self.vm.features['gui-allow-utf8-titles']
else:
self.vm.features['gui-allow-utf8-titles'] = \
self.allow_utf8.currentData()
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))
return msg
def include_in_balancing_changed(self, state):

View File

@ -68,6 +68,39 @@ class SizeSpinBox(QtWidgets.QSpinBox):
return int(float(value) * multiplier)
def get_boolean_feature(vm, feature_name):
result = vm.features.get(feature_name, None)
if result is not None:
try:
result = bool(result)
except ValueError:
result = None
return result
def prepare_choice_data(widget,
choices,
selected_value=None):
"""
populates widget (ListBox or ComboBox) with items
:param widget: widget to populate
:param choices: list of tuples (text, value) to use to populate widget
:param selected_value: value to populate widget with
:return:
"""
while widget.count() > 0:
widget.removeItem(0)
for (name, value) in choices:
widget.addItem(name, value)
if widget.findData(selected_value) > -1:
widget.setCurrentIndex(widget.findData(selected_value))
else:
widget.addItem(selected_value, selected_value)
widget.setCurrentIndex(widget.findData(selected_value))
def prepare_choice(widget, holder, propname, choice, default,
filter_function=None, *,
icon_getter=None, allow_internal=None, allow_default=False,

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>836</width>
<height>656</height>
<height>665</height>
</rect>
</property>
<property name="windowTitle">
@ -29,7 +29,7 @@
<locale language="English" country="UnitedStates"/>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="basic_tab">
<property name="locale">
@ -444,192 +444,10 @@ border-width: 1px;</string>
<attribute name="title">
<string>Advanced</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="1" rowspan="2" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QGroupBox" name="kernel_groupbox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Kernel</string>
</property>
<layout class="QFormLayout" name="formLayout_9">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="topMargin">
<number>15</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Kernel:</string>
</property>
<property name="buddy">
<cstring>kernel</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="kernel"/>
</item>
<item row="1" column="1">
<widget class="QLabel" name="pvh_kernel_version_warning">
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>WARNING: PVH mode requires Linux 4.11 or newer.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Kernel opts:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="kernel_opts">
<property name="font">
<font>
<weight>50</weight>
<italic>true</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>[]</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="2" column="1" rowspan="2" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QGroupBox" name="virt_groupbox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Virtualization</string>
</property>
<layout class="QFormLayout" name="formLayout_10">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="topMargin">
<number>15</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label_27">
<property name="text">
<string>Mode:</string>
</property>
<property name="buddy">
<cstring>virt_mode</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="virt_mode"/>
</item>
<item row="2" column="1">
<widget class="QLabel" name="pv_warning">
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:rgb(255, 0, 0)</string>
</property>
<property name="text">
<string>Using PV mode exposes more hypervisor attack surface!</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="pvh_mode_hidden">
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>PVH mode is hidden since it doesn't support PCI passthrough.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_21">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>PVH mode is recommended if possible (Linux kernel 4.11 or newer, no PCI passthrough). For Windows qubes always use HVM.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="0" column="0" rowspan="2">
<widget class="QGroupBox" name="groupBox_2">
<property name="enabled">
<bool>true</bool>
@ -647,11 +465,21 @@ border-width: 1px;</string>
<property name="topMargin">
<number>15</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_15">
<item row="2" column="1">
<widget class="QSpinBox" name="vcpus">
<property name="enabled">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -659,35 +487,10 @@ border-width: 1px;</string>
</sizepolicy>
</property>
<property name="text">
<string>Initial memory:</string>
<string>VCPUs no.:</string>
</property>
<property name="buddy">
<cstring>init_mem</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="init_mem">
<property name="enabled">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string> MB</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>1000000</number>
</property>
<property name="singleStep">
<number>50</number>
</property>
<property name="value">
<number>256</number>
<cstring>vcpus</cstring>
</property>
</widget>
</item>
@ -716,32 +519,28 @@ border-width: 1px;</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>VCPUs no.:</string>
</property>
<property name="buddy">
<cstring>vcpus</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="vcpus">
<item row="0" column="1">
<widget class="QSpinBox" name="init_mem">
<property name="enabled">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string> MB</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>1000000</number>
</property>
<property name="singleStep">
<number>50</number>
</property>
<property name="value">
<number>1</number>
<number>256</number>
</property>
</widget>
</item>
@ -775,6 +574,25 @@ border-width: 1px;</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_15">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Initial memory:</string>
</property>
<property name="buddy">
<cstring>init_mem</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_17">
<property name="sizePolicy">
@ -794,20 +612,7 @@ border-width: 1px;</string>
</layout>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<item>
<widget class="QGroupBox" name="other_groupbox">
<property name="title">
<string>Other</string>
@ -909,6 +714,297 @@ The qube must be running to disable seamless mode; this setting is not persisten
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="window_groupbox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Window Options</string>
</property>
<layout class="QGridLayout" name="gridLayout_12">
<item row="0" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Allow fullscreen&lt;span style=&quot; color:#ef2929;&quot;&gt;*&lt;/span&gt;:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="allow_fullscreen"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Allow UTF-8 window titles&lt;span style=&quot; color:#ef2929;&quot;&gt;*&lt;/span&gt;:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="allow_utf8"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="requires_restart_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#ef2929;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot; font-style:normal; color:#000000;&quot;&gt; Requires restart&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="kernel_groupbox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Kernel</string>
</property>
<layout class="QFormLayout" name="formLayout_9">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="topMargin">
<number>15</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Kernel:</string>
</property>
<property name="buddy">
<cstring>kernel</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="kernel"/>
</item>
<item row="1" column="1">
<widget class="QLabel" name="pvh_kernel_version_warning">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>WARNING: PVH mode requires Linux 4.11 or newer.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_20">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Kernel opts:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="kernel_opts">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>50</weight>
<italic>true</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>[]</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="virt_groupbox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Virtualization</string>
</property>
<layout class="QFormLayout" name="formLayout_10">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="topMargin">
<number>15</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label_27">
<property name="text">
<string>Mode:</string>
</property>
<property name="buddy">
<cstring>virt_mode</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="virt_mode"/>
</item>
<item row="2" column="1">
<widget class="QLabel" name="pv_warning">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:rgb(255, 0, 0)</string>
</property>
<property name="text">
<string>Using PV mode exposes more hypervisor attack surface!</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="pvh_mode_hidden">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>PVH mode is hidden since it doesn't support PCI passthrough.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_21">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>PVH mode is recommended if possible (Linux kernel 4.11 or newer, no PCI passthrough). For Windows qubes always use HVM.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="firewall_tab">
@ -1600,16 +1696,18 @@ The qube must be running to disable seamless mode; this setting is not persisten
<tabstop>boot_from_device_button</tabstop>
<tabstop>seamless_on_button</tabstop>
<tabstop>seamless_off_button</tabstop>
<tabstop>allow_fullscreen</tabstop>
<tabstop>allow_utf8</tabstop>
<tabstop>kernel</tabstop>
<tabstop>virt_mode</tabstop>
<tabstop>policy_allow_radio_button</tabstop>
<tabstop>policy_deny_radio_button</tabstop>
<tabstop>rulesTreeView</tabstop>
<tabstop>temp_full_access</tabstop>
<tabstop>temp_full_access_time</tabstop>
<tabstop>new_rule_button</tabstop>
<tabstop>edit_rule_button</tabstop>
<tabstop>delete_rule_button</tabstop>
<tabstop>temp_full_access</tabstop>
<tabstop>temp_full_access_time</tabstop>
<tabstop>no_strict_reset_button</tabstop>
<tabstop>refresh_apps_button</tabstop>
<tabstop>service_line_edit</tabstop>