settings advanced tab (kernel, paths)

This commit is contained in:
Agnieszka Kostrzewa 2012-03-12 21:08:32 +01:00
parent 27226171aa
commit 6857c0e6f4
2 changed files with 95 additions and 3 deletions

View File

@ -34,6 +34,7 @@ from qubes.qubes import qubes_appmenu_remove_cmd
from qubes.qubes import QubesDaemonPidfile
from qubes.qubes import QubesHost
from qubes.qubes import qrexec_client_path
from qubes.qubes import qubes_kernels_base_dir
import qubesmanager.resources_rc
@ -86,6 +87,9 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
###### basic tab
self.__init_basic_tab__()
###### advanced tab
self.__init_advanced_tab__()
###### firewall tab
if self.tabWidget.isTabEnabled(self.tabs_indices["firewall"]):
@ -142,6 +146,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.anything_changed = False
ret = self.__apply_basic_tab__()
self.__apply_advanced_tab__()
if len(ret) > 0 :
thread_monitor.set_error_msg('\n'.join(ret))
@ -201,6 +206,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.template_name.setCurrentIndex(self.template_idx)
else:
self.template_name.setEnabled(False)
self.template_idx = -1
if (not self.vm.is_netvm() or self.vm.is_proxyvm()):
@ -222,6 +228,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.netVM.setCurrentIndex(self.netvm_idx)
else:
self.netVM.setEnabled(False)
self.netvm_idx = -1
self.include_in_backups.setChecked(self.vm.include_in_backups)
@ -307,7 +314,71 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.anything_changed = True
return msg
######### advanced tab
def __init_advanced_tab__(self):
#kernel
if self.vm.template is not None:
text = self.vm.kernel
self.kernel.insertItem(0, text)
self.kernel.setEnabled(False)
self.kernel_idx = 0
else:
text = "default (" + self.qvm_collection.get_default_kernel() +")"
kernel_list = [text]
for k in os.listdir(qubes_kernels_base_dir):
kernel_list.append(k)
kernel_list.append("none")
self.kernel_idx = 0
for (i, k) in enumerate(kernel_list):
text = k
if (text.startswith("default") and self.vm.uses_default_kernel) or ( self.vm.kernel == k and not self.vm.uses_default_kernel) or (k=="none" and self.vm.kernel==None):
text += " (current)"
self.kernel_idx = i
self.kernel.insertItem(i,text)
self.kernel.setCurrentIndex(self.kernel_idx)
#kernel opts
if self.vm.uses_default_kernelopts:
self.kernel_opts.setText(self.vm.kernelopts + " (default)")
else:
self.kernel_opts.setText(self.vm.kernelopts)
#paths
self.dir_path.setText(self.vm.dir_path)
self.config_path.setText(self.vm.conf_file)
if self.vm.template is not None:
self.root_img_path.setText(self.vm.template.root_img)
else:
self.root_img_path.setText("n/a")
self.volatile_img_path.setText(self.vm.volatile_img)
self.private_img_path.setText(self.vm.private_img)
def __apply_advanced_tab__(self):
#kernel changed
if self.kernel.currentIndex() != self.kernel_idx:
new_kernel = self.kernel.currentText()
new_kernel = new_kernel.split(' ')[0]
if(new_kernel == "default"):
kernel = self.qvm_collection.get_default_kernel()
self.vm.uses_default_kernel = True
elif(new_kernel == "none"):
kernel = None
self.vm.uses_default_kernel = False;
else:
self.vm.uses_default_kernel = False;
self.vm.kernel = kernel
self.anything_changed = True
######### firewall tab related
def set_fw_model(self, model):

View File

@ -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">
@ -288,7 +288,7 @@
</widget>
<widget class="QWidget" name="advanced_tab">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<attribute name="title">
<string>Advanced</string>
@ -296,12 +296,18 @@
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>Memory/CPU</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label_15">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Initial memory:</string>
</property>
@ -309,6 +315,9 @@
</item>
<item row="0" column="1">
<widget class="QLabel" name="mem_size">
<property name="enabled">
<bool>false</bool>
</property>
<property name="font">
<font>
<weight>75</weight>
@ -325,6 +334,9 @@
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_16">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>MB</string>
</property>
@ -388,6 +400,9 @@
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="include_in_balancing">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Include in memory balancing</string>
</property>
@ -398,6 +413,9 @@
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox_10">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Kernel</string>
</property>
@ -437,6 +455,9 @@
</item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_11">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Paths</string>
</property>