shutdown-when-idle gets its own checkbox in VM settings

It is disabled if the service is unavailable and displays information
about how to enable it if it is unavailable.

references QubesOS/qubes-issues#5298
This commit is contained in:
Marta Marczykowska-Górecka 2020-08-08 00:00:48 +02:00
parent 98a5c93c04
commit 4211d6e403
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B
3 changed files with 132 additions and 80 deletions

View File

@ -437,6 +437,31 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog):
except qubesadmin.exc.QubesDaemonAccessError: except qubesadmin.exc.QubesDaemonAccessError:
self.include_in_backups.setEnabled(False) self.include_in_backups.setEnabled(False)
try:
has_shutdown_idle = self.vm.features.get(
"supported-service.shutdown-idle", False)
if has_shutdown_idle:
self.idle_shutdown_checkbox.setChecked(self.vm.features.get(
"shutdown-idle", False))
else:
text = "Shut down when idle "
if getattr(self.vm, 'template', None):
additional_text = "(unavailable: package " \
"qubes-app-shutdown-idle missing " \
"in the template)"
else:
additional_text = "(unavailable: package " \
"qubes-app-shutdown-idle missing " \
"in the qube)"
self.idle_shutdown_checkbox.setText(
text + additional_text)
self.idle_shutdown_checkbox.setEnabled(False)
except qubesadmin.exc.QubesDaemonCommunicationError:
self.idle_shutdown_checkbox.setText(
self.idle_shutdown_checkbox.text() +
" (unavailable: permission denied)")
self.idle_shutdown_checkbox.setEnabled(False)
try: try:
self.autostart_vm.setChecked(self.vm.autostart) self.autostart_vm.setChecked(self.vm.autostart)
self.autostart_vm.setVisible(True) self.autostart_vm.setVisible(True)
@ -538,6 +563,16 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog):
except qubesadmin.exc.QubesException as ex: except qubesadmin.exc.QubesException as ex:
msg.append(str(ex)) msg.append(str(ex))
# shutdown-idle
try:
current_idle = self.vm.features.get("shutdown-idle", False)
if self.idle_shutdown_checkbox.isEnabled() and \
self.idle_shutdown_checkbox.isChecked() != current_idle:
self.vm.features["shutdown-idle"] = \
self.idle_shutdown_checkbox.isChecked()
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))
# max priv storage # max priv storage
if self.max_priv_storage.isEnabled(): if self.max_priv_storage.isEnabled():
priv_size = self.max_priv_storage.value() priv_size = self.max_priv_storage.value()

View File

@ -5,24 +5,34 @@
class QubesException(BaseException): class QubesException(BaseException):
pass pass
class QubesVMNotStartedError(BaseException): class QubesVMNotStartedError(BaseException):
pass pass
class QubesPropertyAccessError(BaseException): class QubesPropertyAccessError(BaseException):
pass pass
class QubesDaemonAccessError(BaseException): class QubesDaemonAccessError(BaseException):
pass pass
class QubesNoSuchPropertyError(BaseException): class QubesNoSuchPropertyError(BaseException):
pass pass
class QubesDaemonNoResponseError(BaseException): class QubesDaemonNoResponseError(BaseException):
pass pass
class BackupCancelledError(BaseException): class BackupCancelledError(BaseException):
pass pass
class BackupAlreadyRunningError(BaseException): class BackupAlreadyRunningError(BaseException):
pass pass
class QubesDaemonCommunicationError(BaseException):
pass

View File

@ -29,7 +29,7 @@
<locale language="English" country="UnitedStates"/> <locale language="English" country="UnitedStates"/>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="basic_tab"> <widget class="QWidget" name="basic_tab">
<property name="locale"> <property name="locale">
@ -128,6 +128,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="root_resize_label">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>System storage max. size:</string>
</property>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="SizeSpinBox" name="max_priv_storage"> <widget class="SizeSpinBox" name="max_priv_storage">
<property name="enabled"> <property name="enabled">
@ -163,16 +173,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="root_resize_label">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>System storage max. size:</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -285,6 +285,26 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1">
<widget class="QPushButton" name="delete_vm_button">
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:pad, x1:1, y1:1, x2:1, y2:0, stop:0 rgba(255, 179, 179, 255), stop:1 rgba(255, 108, 108, 255));
border-color: rgb(170, 0, 0);
border-style: solid;
border-width: 1px;</string>
</property>
<property name="text">
<string>Delete qube</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="clone_vm_button">
<property name="text">
<string>Clone qube</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="title"> <property name="title">
@ -294,16 +314,27 @@
<property name="topMargin"> <property name="topMargin">
<number>15</number> <number>15</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="3">
<widget class="QLabel" name="label"> <widget class="QComboBox" name="vmlabel">
<property name="text"> <property name="frame">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Name &amp;amp;&amp;amp; label&lt;span style=&quot; color:#ff0000;&quot;&gt;*&lt;/span&gt;:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <bool>true</bool>
</property>
<property name="buddy">
<cstring>vmname</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="template_name"/>
</item>
<item row="5" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="autostart_vm">
<property name="text">
<string>Start qube automatically on boot</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
@ -314,20 +345,39 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="1" column="3">
<widget class="QLabel" name="label_18"> <widget class="QLabel" name="warn_template_missing_apps">
<property name="text"> <property name="toolTip">
<string>Networking:</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Some applications enabled in the Applications tab cannot be found in the current template. The most likely cause is a template change - to restore them, install them in the template.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="buddy"> <property name="text">
<cstring>netVM</cstring> <string/>
</property>
<property name="pixmap">
<pixmap resource="../resources.qrc">:/warning.png</pixmap>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="3"> <item row="0" column="0">
<widget class="QComboBox" name="vmlabel"> <widget class="QLabel" name="label">
<property name="frame"> <property name="text">
<bool>true</bool> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Name &amp;amp;&amp;amp; label&lt;span style=&quot; color:#ff0000;&quot;&gt;*&lt;/span&gt;:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="buddy">
<cstring>vmname</cstring>
</property>
</widget>
</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;&lt;span style=&quot; font-weight:600;&quot;&gt;Caution:&lt;/span&gt; The Default DisposableVM Template (see the Advanced tab) has a different Networking setting than this qube. This configuration may result in unexpected network access. For example, you may have set this qube's Networking to &amp;quot;none&amp;quot; in order to prevent any data from being transmitted out. However, if the Default DisposableVM Template's Networking is set to &amp;quot;sys-firewall,&amp;quot; then a DisposableVM started from this qube may be able to transmit data out, contrary to your intention. You may wish to set the Default DisposableVM Template for this qube to one with equally restrictive Networking settings.&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> </property>
</widget> </widget>
</item> </item>
@ -348,9 +398,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="template_name"/>
</item>
<item row="2" column="1" colspan="2"> <item row="2" column="1" colspan="2">
<widget class="QComboBox" name="netVM"> <widget class="QComboBox" name="netVM">
<property name="toolTip"> <property name="toolTip">
@ -358,7 +405,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="3"> <item row="4" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QCheckBox" name="include_in_backups"> <widget class="QCheckBox" name="include_in_backups">
@ -375,66 +422,26 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="4" column="0" colspan="3"> <item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <widget class="QLabel" name="label_18">
<item>
<widget class="QCheckBox" name="autostart_vm">
<property name="text">
<string>Start qube automatically on boot</string>
</property>
</widget>
</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;&lt;span style=&quot; font-weight:600;&quot;&gt;Caution:&lt;/span&gt; The Default DisposableVM Template (see the Advanced tab) has a different Networking setting than this qube. This configuration may result in unexpected network access. For example, you may have set this qube's Networking to &amp;quot;none&amp;quot; in order to prevent any data from being transmitted out. However, if the Default DisposableVM Template's Networking is set to &amp;quot;sys-firewall,&amp;quot; then a DisposableVM started from this qube may be able to transmit data out, contrary to your intention. You may wish to set the Default DisposableVM Template for this qube to one with equally restrictive Networking settings.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string/> <string>Networking:</string>
</property> </property>
<property name="pixmap"> <property name="buddy">
<pixmap resource="../resources.qrc">:/warning.png</pixmap> <cstring>netVM</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="3"> <item row="3" column="0" colspan="3">
<widget class="QLabel" name="warn_template_missing_apps"> <widget class="QCheckBox" name="idle_shutdown_checkbox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Some applications enabled in the Applications tab cannot be found in the current template. The most likely cause is a template change - to restore them, install them in the template.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string/> <string>Shut down when idle for more than 15 minutes</string>
</property>
<property name="pixmap">
<pixmap resource="../resources.qrc">:/warning.png</pixmap>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="4" column="1">
<widget class="QPushButton" name="delete_vm_button">
<property name="styleSheet">
<string notr="true">background-color: qlineargradient(spread:pad, x1:1, y1:1, x2:1, y2:0, stop:0 rgba(255, 179, 179, 255), stop:1 rgba(255, 108, 108, 255));
border-color: rgb(170, 0, 0);
border-style: solid;
border-width: 1px;</string>
</property>
<property name="text">
<string>Delete qube</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="clone_vm_button">
<property name="text">
<string>Clone qube</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="advanced_tab"> <widget class="QWidget" name="advanced_tab">