settings.py 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242
  1. #!/usr/bin/python3
  2. #
  3. # The Qubes OS Project, http://www.qubes-os.org
  4. #
  5. # Copyright (C) 2012 Agnieszka Kostrzewa <agnieszka.kostrzewa@gmail.com>
  6. # Copyright (C) 2012 Marek Marczykowski-Górecki
  7. # <marmarek@invisiblethingslab.com>
  8. # Copyright (C) 2017 Wojtek Porczyk <woju@invisiblethingslab.com>
  9. #
  10. # This program is free software; you can redistribute it and/or
  11. # modify it under the terms of the GNU General Public License
  12. # as published by the Free Software Foundation; either version 2
  13. # of the License, or (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU Lesser General Public License along
  21. # with this program; if not, see <http://www.gnu.org/licenses/>.
  22. #
  23. #
  24. import collections
  25. import os.path
  26. import os
  27. import re
  28. import subprocess
  29. import traceback
  30. import sys
  31. from qubesadmin.tools import QubesArgumentParser
  32. from qubesadmin import devices
  33. from qubesadmin import utils as admin_utils
  34. import qubesadmin.exc
  35. from . import utils
  36. from . import multiselectwidget
  37. from . import common_threads
  38. from . import device_list
  39. from .appmenu_select import AppmenuSelectManager
  40. from . import firewall
  41. from PyQt4 import QtCore, QtGui # pylint: disable=import-error
  42. from . import ui_settingsdlg # pylint: disable=no-name-in-module
  43. # pylint: disable=too-few-public-methods
  44. class RenameVMThread(QtCore.QThread):
  45. def __init__(self, vm, new_vm_name, dependencies):
  46. QtCore.QThread.__init__(self)
  47. self.vm = vm
  48. self.new_vm_name = new_vm_name
  49. self.dependencies = dependencies
  50. self.msg = None
  51. def run(self):
  52. try:
  53. new_vm = self.vm.app.clone_vm(self.vm, self.new_vm_name)
  54. failed_props = []
  55. for (holder, prop) in self.dependencies:
  56. try:
  57. if holder is None:
  58. setattr(self.vm.app, prop, new_vm)
  59. else:
  60. setattr(holder, prop, new_vm)
  61. except qubesadmin.exc.QubesException:
  62. failed_props += [(holder, prop)]
  63. if not failed_props:
  64. del self.vm.app.domains[self.vm.name]
  65. else:
  66. list_text = utils.format_dependencies_list(failed_props)
  67. QtGui.QMessageBox.warning(
  68. self,
  69. self.tr("Warning: rename partially unsuccessful"),
  70. self.tr("Some properties could not be changed to the new "
  71. "name. The system has now both {} and {} qubes. "
  72. "To resolve this, please check and change the "
  73. "following properties and remove the qube {} "
  74. "manually.<br> ").format(
  75. self.vm.name, self.vm.name, self.vm.name)\
  76. + list_text)
  77. except qubesadmin.exc.QubesException as ex:
  78. self.msg = ("Rename error!", str(ex))
  79. except Exception as ex: # pylint: disable=broad-except
  80. self.msg = ("Rename error!", repr(ex))
  81. # pylint: disable=too-few-public-methods
  82. class RefreshAppsVMThread(QtCore.QThread):
  83. def __init__(self, vm, button):
  84. QtCore.QThread.__init__(self)
  85. self.vm = vm
  86. self.button = button
  87. self.msg = None
  88. def run(self):
  89. vms_to_refresh = [self.vm]
  90. template = getattr(self.vm, 'template', None)
  91. if template:
  92. vms_to_refresh.append(template)
  93. for vm in vms_to_refresh:
  94. self.button.setText(
  95. self.tr('Refresh in progress (refreshing applications '
  96. 'from {})').format(vm.name))
  97. try:
  98. if not vm.is_running():
  99. not_running = True
  100. vm.start()
  101. else:
  102. not_running = False
  103. subprocess.check_call(['qvm-sync-appmenus', vm.name])
  104. if not_running:
  105. vm.shutdown()
  106. except Exception as ex: # pylint: disable=broad-except
  107. self.msg = ("Refresh failed!", str(ex))
  108. # pylint: disable=too-many-instance-attributes
  109. class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
  110. tabs_indices = collections.OrderedDict((
  111. ('basic', 0),
  112. ('advanced', 1),
  113. ('firewall', 2),
  114. ('devices', 3),
  115. ('applications', 4),
  116. ('services', 5),
  117. ))
  118. def __init__(self, vm, qapp, init_page="basic", parent=None):
  119. super(VMSettingsWindow, self).__init__(parent)
  120. self.vm = vm
  121. self.qapp = qapp
  122. self.threads_list = []
  123. self.progress = None
  124. self.thread_closes = False
  125. try:
  126. self.source_vm = self.vm.template
  127. except AttributeError:
  128. self.source_vm = self.vm
  129. self.setupUi(self)
  130. self.setWindowTitle(self.tr("Settings: {vm}").format(vm=self.vm.name))
  131. if init_page in self.tabs_indices:
  132. idx = self.tabs_indices[init_page]
  133. assert idx in range(self.tabWidget.count())
  134. self.tabWidget.setCurrentIndex(idx)
  135. self.buttonBox.button(QtGui.QDialogButtonBox.Ok).clicked.connect(
  136. self.save_and_apply)
  137. self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).clicked.connect(
  138. self.reject)
  139. self.buttonBox.button(QtGui.QDialogButtonBox.Apply).clicked.connect(
  140. self.apply)
  141. self.tabWidget.currentChanged.connect(self.current_tab_changed)
  142. ###### basic tab
  143. self.__init_basic_tab__()
  144. self.rename_vm_button.clicked.connect(self.rename_vm)
  145. self.delete_vm_button.clicked.connect(self.remove_vm)
  146. self.clone_vm_button.clicked.connect(self.clone_vm)
  147. ###### advanced tab
  148. self.__init_advanced_tab__()
  149. self.include_in_balancing.stateChanged.connect(
  150. self.include_in_balancing_changed)
  151. self.connect(self.init_mem,
  152. QtCore.SIGNAL("editingFinished()"),
  153. self.check_mem_changes)
  154. self.connect(self.max_mem_size,
  155. QtCore.SIGNAL("editingFinished()"),
  156. self.check_mem_changes)
  157. self.boot_from_device_button.clicked.connect(
  158. self.boot_from_cdrom_button_pressed)
  159. ###### firewall tab
  160. if self.tabWidget.isTabEnabled(self.tabs_indices['firewall']):
  161. model = firewall.QubesFirewallRulesModel()
  162. try:
  163. model.set_vm(vm)
  164. self.set_fw_model(model)
  165. self.firewall_modified_outside_label.setVisible(False)
  166. except firewall.FirewallModifiedOutsideError:
  167. self.disable_all_fw_conf()
  168. self.new_rule_button.clicked.connect(self.new_rule_button_pressed)
  169. self.edit_rule_button.clicked.connect(self.edit_rule_button_pressed)
  170. self.delete_rule_button.clicked.connect(
  171. self.delete_rule_button_pressed)
  172. self.policy_deny_radio_button.clicked.connect(self.policy_changed)
  173. self.policy_allow_radio_button.clicked.connect(self.policy_changed)
  174. if init_page == 'firewall':
  175. self.check_network_availability()
  176. ####### devices tab
  177. self.__init_devices_tab__()
  178. self.connect(self.dev_list,
  179. QtCore.SIGNAL("selected_changed()"),
  180. self.devices_selection_changed)
  181. self.no_strict_reset_button.clicked.connect(
  182. self.strict_reset_button_pressed)
  183. self.current_strict_reset_list = []
  184. self.new_strict_reset_list = []
  185. self.define_strict_reset_devices()
  186. ####### services tab
  187. self.__init_services_tab__()
  188. self.service_line_edit.lineEdit().returnPressed.connect(
  189. self.__add_service__)
  190. self.add_srv_button.clicked.connect(self.__add_service__)
  191. self.remove_srv_button.clicked.connect(self.__remove_service__)
  192. ####### apps tab
  193. if self.tabWidget.isTabEnabled(self.tabs_indices["applications"]):
  194. self.app_list = multiselectwidget.MultiSelectWidget(self)
  195. self.apps_layout.addWidget(self.app_list)
  196. self.app_list_manager = AppmenuSelectManager(self.vm, self.app_list)
  197. self.refresh_apps_button.clicked.connect(
  198. self.refresh_apps_button_pressed)
  199. def clear_threads(self):
  200. for thread in self.threads_list:
  201. if thread.isFinished():
  202. if self.progress:
  203. self.progress.hide()
  204. self.progress = None
  205. if thread.msg:
  206. (title, msg) = thread.msg
  207. QtGui.QMessageBox.warning(
  208. None,
  209. self.tr(title),
  210. self.tr(msg))
  211. self.threads_list.remove(thread)
  212. if self.thread_closes:
  213. self.done(0)
  214. return
  215. raise RuntimeError('No finished thread found')
  216. def keyPressEvent(self, event): # pylint: disable=invalid-name
  217. if event.key() == QtCore.Qt.Key_Enter \
  218. or event.key() == QtCore.Qt.Key_Return:
  219. return
  220. super(VMSettingsWindow, self).keyPressEvent(event)
  221. def reject(self):
  222. self.done(0)
  223. # needed not to close the dialog before applying changes
  224. def accept(self):
  225. pass
  226. def save_changes(self):
  227. error = self.__save_changes__()
  228. if error:
  229. QtGui.QMessageBox.warning(
  230. self,
  231. self.tr("Error while changing settings for {0}!"\
  232. ).format(self.vm.name),\
  233. self.tr("ERROR: {0}").format('\n'.join(error)))
  234. def apply(self):
  235. self.save_changes()
  236. def save_and_apply(self):
  237. self.save_changes()
  238. self.done(0)
  239. def __save_changes__(self):
  240. ret = []
  241. try:
  242. ret_tmp = self.__apply_basic_tab__()
  243. if ret_tmp:
  244. ret += ["Basic tab:"] + ret_tmp
  245. ret_tmp = self.__apply_advanced_tab__()
  246. if ret_tmp:
  247. ret += ["Advanced tab:"] + ret_tmp
  248. ret_tmp = self.__apply_devices_tab__()
  249. if ret_tmp:
  250. ret += ["Devices tab:"] + ret_tmp
  251. ret_tmp = self.__apply_services_tab__()
  252. if ret_tmp:
  253. ret += ["Sevices tab:"] + ret_tmp
  254. except qubesadmin.exc.QubesException as qex:
  255. ret.append(self.tr('Error while saving changes: ') + str(qex))
  256. except Exception as ex: # pylint: disable=broad-except
  257. ret.append(repr(ex))
  258. try:
  259. if self.policy_allow_radio_button.isEnabled():
  260. self.fw_model.apply_rules(
  261. self.policy_allow_radio_button.isChecked(),
  262. self.temp_full_access.isChecked(),
  263. self.temp_full_access_time.value())
  264. except qubesadmin.exc.QubesException as qex:
  265. ret += [self.tr("Firewall tab:"), str(qex)]
  266. except Exception as ex: # pylint: disable=broad-except
  267. ret += [self.tr("Firewall tab:"), repr(ex)]
  268. try:
  269. if self.tabWidget.isTabEnabled(self.tabs_indices["applications"]):
  270. self.app_list_manager.save_appmenu_select_changes()
  271. except qubesadmin.exc.QubesException as qex:
  272. ret += [self.tr("Applications tab:"), str(qex)]
  273. except Exception as ex: # pylint: disable=broad-except
  274. ret += [self.tr("Applications tab:"), repr(ex)]
  275. utils.debug('\n'.join(ret))
  276. return ret
  277. def check_network_availability(self):
  278. netvm = self.vm.netvm
  279. self.no_netvm_label.setVisible(netvm is None)
  280. self.netvm_no_firewall_label.setVisible(
  281. netvm is not None and
  282. not netvm.features.check_with_template('qubes-firewall', False))
  283. if netvm is None:
  284. QtGui.QMessageBox.warning(
  285. self,
  286. self.tr("Qube configuration problem!"),
  287. self.tr('This qube has networking disabled '
  288. '(Basic -> Networking) - network will be disabled. '
  289. 'If you want to use firewall, '
  290. 'please enable networking.')
  291. )
  292. if netvm is not None and \
  293. not netvm.features.check_with_template(\
  294. 'qubes-firewall', False):
  295. QtGui.QMessageBox.warning(
  296. self,
  297. self.tr("Qube configuration problem!"),
  298. self.tr("The '{vm}' qube is network connected to "\
  299. "'{netvm}', which does not support firewall!<br/>"\
  300. "You may edit the '{vm}' qube firewall rules, but "\
  301. "these will not take any effect until you connect it "\
  302. "to a working Firewall qube.").format(\
  303. vm=self.vm.name, netvm=netvm.name))
  304. def current_tab_changed(self, idx):
  305. if idx == self.tabs_indices["firewall"]:
  306. self.check_network_availability()
  307. ######### basic tab
  308. # TODO LISTENERS
  309. # - vm start/shutdown -> setEnabled on fields: template labels
  310. # - vm create/delete -> choices lists, whole window deactiv (if self.vm)
  311. # - property-set -> individual fields
  312. # TODO INTERACTIONS
  313. # netvm -> networking_groupbox
  314. # hvm -> include_in_balancing
  315. # TODO REMOVE
  316. # other_groupbox
  317. def __init_basic_tab__(self):
  318. self.vmname.setText(self.vm.name)
  319. self.vmname.setValidator(
  320. QtGui.QRegExpValidator(
  321. QtCore.QRegExp("[a-zA-Z0-9_-]*",
  322. QtCore.Qt.CaseInsensitive), None))
  323. self.vmname.setEnabled(False)
  324. self.rename_vm_button.setEnabled(not self.vm.is_running())
  325. self.delete_vm_button.setEnabled(not self.vm.is_running())
  326. if self.vm.is_running():
  327. self.delete_vm_button.setText(
  328. self.tr('Delete qube (cannot delete a running qube)'))
  329. if self.vm.qid == 0:
  330. self.vmlabel.setVisible(False)
  331. else:
  332. self.label_list, self.label_idx = utils.prepare_label_choice(
  333. self.vmlabel,
  334. self.vm, 'label',
  335. None,
  336. allow_default=False
  337. )
  338. self.vmlabel.setVisible(True)
  339. self.vmlabel.setEnabled(not self.vm.is_running())
  340. if self.vm.klass == 'AppVM':
  341. self.template_list, self.template_idx = utils.prepare_vm_choice(
  342. self.template_name,
  343. self.vm, 'template',
  344. self.vm.app.default_template,
  345. (lambda vm: vm.klass == 'TemplateVM'),
  346. allow_default=False, allow_none=False)
  347. else:
  348. self.template_name.setEnabled(False)
  349. self.template_idx = -1
  350. self.netvm_list, self.netvm_idx = utils.prepare_vm_choice(
  351. self.netVM,
  352. self.vm, 'netvm',
  353. self.vm.app.default_netvm,
  354. (lambda vm: vm.provides_network),
  355. allow_default=True, allow_none=True)
  356. self.include_in_backups.setChecked(self.vm.include_in_backups)
  357. try:
  358. self.run_in_debug_mode.setChecked(self.vm.debug)
  359. self.run_in_debug_mode.setVisible(True)
  360. except AttributeError:
  361. self.run_in_debug_mode.setVisible(False)
  362. try:
  363. self.autostart_vm.setChecked(self.vm.autostart)
  364. self.autostart_vm.setVisible(True)
  365. except AttributeError:
  366. self.autostart_vm.setVisible(False)
  367. # type
  368. self.type_label.setText(self.vm.klass)
  369. # installed by rpm
  370. self.rpm_label.setText('Yes' if self.vm.installed_by_rpm else 'No')
  371. # networking info
  372. if self.vm.netvm:
  373. self.networking_groupbox.setEnabled(True)
  374. self.ip_label.setText(self.vm.ip or "none")
  375. self.netmask_label.setText(self.vm.visible_netmask or "none")
  376. self.gateway_label.setText(self.vm.visible_gateway or "none")
  377. else:
  378. self.networking_groupbox.setEnabled(False)
  379. # max priv storage
  380. self.priv_img_size = self.vm.volumes['private'].size // 1024**2
  381. self.max_priv_storage.setMinimum(self.priv_img_size)
  382. self.max_priv_storage.setValue(self.priv_img_size)
  383. self.root_img_size = self.vm.volumes['root'].size // 1024**2
  384. self.root_resize.setValue(self.root_img_size)
  385. self.root_resize.setMinimum(self.root_img_size)
  386. self.root_resize.setEnabled(self.vm.volumes['root'].save_on_stop)
  387. self.root_resize_label.setEnabled(self.root_resize.isEnabled())
  388. def __apply_basic_tab__(self):
  389. msg = []
  390. # vm label changed
  391. try:
  392. if self.vmlabel.isVisible():
  393. if self.vmlabel.currentIndex() != self.label_idx:
  394. label = self.label_list[self.vmlabel.currentIndex()]
  395. self.vm.label = label
  396. except qubesadmin.exc.QubesException as ex:
  397. msg.append(str(ex))
  398. # vm template changed
  399. try:
  400. if self.template_name.currentIndex() != self.template_idx:
  401. self.vm.template = \
  402. self.template_list[self.template_name.currentIndex()]
  403. except qubesadmin.exc.QubesException as ex:
  404. msg.append(str(ex))
  405. # vm netvm changed
  406. try:
  407. if self.netVM.currentIndex() != self.netvm_idx:
  408. self.vm.netvm = self.netvm_list[self.netVM.currentIndex()]
  409. except qubesadmin.exc.QubesException as ex:
  410. msg.append(str(ex))
  411. # include in backups
  412. try:
  413. if self.vm.include_in_backups != \
  414. self.include_in_backups.isChecked():
  415. self.vm.include_in_backups = self.include_in_backups.isChecked()
  416. except qubesadmin.exc.QubesException as ex:
  417. msg.append(str(ex))
  418. # run_in_debug_mode
  419. try:
  420. if self.run_in_debug_mode.isVisible():
  421. if self.vm.debug != self.run_in_debug_mode.isChecked():
  422. self.vm.debug = self.run_in_debug_mode.isChecked()
  423. except qubesadmin.exc.QubesException as ex:
  424. msg.append(str(ex))
  425. # autostart_vm
  426. try:
  427. if self.autostart_vm.isVisible():
  428. if self.vm.autostart != self.autostart_vm.isChecked():
  429. self.vm.autostart = self.autostart_vm.isChecked()
  430. except qubesadmin.exc.QubesException as ex:
  431. msg.append(str(ex))
  432. # max priv storage
  433. priv_size = self.max_priv_storage.value()
  434. if self.priv_img_size != priv_size:
  435. try:
  436. self.vm.volumes['private'].resize(priv_size * 1024**2)
  437. except qubesadmin.exc.QubesException as ex:
  438. msg.append(str(ex))
  439. # max sys storage
  440. sys_size = self.root_resize.value()
  441. if self.root_img_size != sys_size:
  442. try:
  443. self.vm.volumes['root'].resize(sys_size * 1024**2)
  444. except qubesadmin.exc.QubesException as ex:
  445. msg.append(str(ex))
  446. return msg
  447. def check_mem_changes(self):
  448. if self.max_mem_size.value() < self.init_mem.value():
  449. QtGui.QMessageBox.warning(
  450. self,
  451. self.tr("Warning!"),
  452. self.tr("Max memory can not be less than initial memory.<br>"
  453. "Setting max memory to equal initial memory."))
  454. self.max_mem_size.setValue(self.init_mem.value())
  455. # Linux specific limit: init memory must not be below
  456. # max_mem_size/10.79 in order to allow scaling up to
  457. # max_mem_size (or else "add_memory() failed: -17" problem)
  458. if self.init_mem.value() * 10 < self.max_mem_size.value():
  459. QtGui.QMessageBox.warning(
  460. self,
  461. self.tr("Warning!"),
  462. self.tr("Initial memory can not be less than one tenth "
  463. "Max memory.<br>Setting initial memory to the minimum "
  464. "allowed value."))
  465. self.init_mem.setValue(self.max_mem_size.value() / 10)
  466. def rename_vm(self):
  467. dependencies = admin_utils.vm_dependencies(self.vm.app, self.vm)
  468. running_dependencies = [vm.name for (vm, prop) in dependencies
  469. if vm and prop == 'template'
  470. and vm.is_running()]
  471. if running_dependencies:
  472. QtGui.QMessageBox.warning(
  473. self,
  474. self.tr("Qube cannot be renamed!"),
  475. self.tr(
  476. "The following qubes using this qube as a template are "
  477. "running: <br> {}. <br> In order to rename this qube, you "
  478. "must first shut them down.").format(
  479. ", ".join(running_dependencies)))
  480. return
  481. new_vm_name, ok = QtGui.QInputDialog.getText(
  482. self,
  483. self.tr('Rename qube'),
  484. self.tr('New name: (WARNING: all other changes will be discarded)'))
  485. if ok:
  486. thread = RenameVMThread(self.vm, new_vm_name, dependencies)
  487. self.threads_list.append(thread)
  488. thread.finished.connect(self.clear_threads)
  489. self.progress = QtGui.QProgressDialog(
  490. self.tr(
  491. "Renaming Qube..."), "", 0, 0)
  492. self.progress.setCancelButton(None)
  493. self.progress.setModal(True)
  494. self.thread_closes = True
  495. self.progress.show()
  496. thread.start()
  497. def remove_vm(self):
  498. dependencies = admin_utils.vm_dependencies(self.vm.app, self.vm)
  499. if dependencies:
  500. list_text = utils.format_dependencies_list(dependencies)
  501. QtGui.QMessageBox.warning(
  502. self,
  503. self.tr("Qube cannot be removed!"),
  504. self.tr("This qube cannot be removed. It is used as:"
  505. " <br> {} <small>If you want to remove this qube, "
  506. "you should remove or change settings of each qube "
  507. "or setting that uses it.</small>").format(list_text))
  508. return
  509. answer, ok = QtGui.QInputDialog.getText(
  510. self,
  511. self.tr('Delete qube'),
  512. self.tr('Are you absolutely sure you want to delete this qube? '
  513. '<br/> All qube settings and data will be irrevocably'
  514. ' deleted. <br/> If you are sure, please enter this '
  515. 'qube\'s name below.'))
  516. if ok and answer == self.vm.name:
  517. thread = common_threads.RemoveVMThread(self.vm)
  518. thread.start()
  519. self.done(0)
  520. elif ok:
  521. QtGui.QMessageBox.warning(
  522. self,
  523. self.tr("Removal cancelled"),
  524. self.tr("The qube will not be removed."))
  525. def clone_vm(self):
  526. cloned_vm_name, ok = QtGui.QInputDialog.getText(
  527. self,
  528. self.tr('Clone qube'),
  529. self.tr('Name for the cloned qube:'))
  530. if ok:
  531. thread = common_threads.CloneVMThread(self.vm, cloned_vm_name)
  532. thread.finished.connect(self.clear_threads)
  533. self.threads_list.append(thread)
  534. self.progress = QtGui.QProgressDialog(
  535. self.tr(
  536. "Cloning Qube..."), "", 0, 0)
  537. self.progress.setCancelButton(None)
  538. self.progress.setModal(True)
  539. self.thread_closes = True
  540. self.progress.show()
  541. thread.start()
  542. ######### advanced tab
  543. def __init_advanced_tab__(self):
  544. # mem/cpu
  545. # qubes_memory = QubesHost().memory_total/1024
  546. self.init_mem.setValue(int(self.vm.memory))
  547. # self.init_mem.setMaximum(qubes_memory)
  548. self.max_mem_size.setValue(int(self.vm.maxmem))
  549. # self.max_mem_size.setMaximum(qubes_memory)
  550. self.vcpus.setMinimum(1)
  551. # self.vcpus.setMaximum(QubesHost().no_cpus)
  552. self.vcpus.setValue(int(self.vm.vcpus))
  553. self.include_in_balancing.setEnabled(True)
  554. self.include_in_balancing.setChecked(
  555. bool(self.vm.features.get('service.meminfo-writer', True)))
  556. self.max_mem_size.setEnabled(self.include_in_balancing.isChecked())
  557. # in case VM is HVM
  558. if hasattr(self.vm, "kernel"):
  559. self.kernel_groupbox.setVisible(True)
  560. self.kernel_list, self.kernel_idx = utils.prepare_kernel_choice(
  561. self.kernel, self.vm, 'kernel',
  562. None,
  563. allow_default=True, allow_none=True)
  564. self.kernel.currentIndexChanged.connect(self.kernel_changed)
  565. self.kernel_opts.setText(getattr(self.vm, 'kernelopts', '-'))
  566. else:
  567. self.kernel_groupbox.setVisible(False)
  568. self.other_groupbox.setVisible(False)
  569. if not hasattr(self.vm, 'default_dispvm'):
  570. self.other_groupbox.setVisible(False)
  571. else:
  572. self.other_groupbox.setVisible(True)
  573. self.default_dispvm_list, self.default_dispvm_idx = \
  574. utils.prepare_vm_choice(
  575. self.default_dispvm,
  576. self.vm, 'default_dispvm',
  577. None,
  578. (lambda vm: getattr(vm, 'template_for_dispvms', False)),
  579. allow_default=True, allow_none=True)
  580. self.update_virt_mode_list()
  581. windows_running = self.vm.features.get('os', None) == 'Windows' and \
  582. self.vm.is_running()
  583. self.seamless_on_button.setEnabled(windows_running)
  584. self.seamless_off_button.setEnabled(windows_running)
  585. self.seamless_on_button.clicked.connect(self.enable_seamless)
  586. self.seamless_off_button.clicked.connect(self.disable_seamless)
  587. def enable_seamless(self):
  588. self.vm.run_service_for_stdio("qubes.SetGuiMode", input=b'SEAMLESS')
  589. def disable_seamless(self):
  590. self.vm.run_service_for_stdio("qubes.SetGuiMode", input=b'FULLSCREEN')
  591. def __apply_advanced_tab__(self):
  592. msg = []
  593. # mem/cpu
  594. try:
  595. if self.init_mem.value() != int(self.vm.memory):
  596. self.vm.memory = self.init_mem.value()
  597. if self.max_mem_size.value() != int(self.vm.maxmem):
  598. self.vm.maxmem = self.max_mem_size.value()
  599. if self.vcpus.value() != int(self.vm.vcpus):
  600. self.vm.vcpus = self.vcpus.value()
  601. except qubesadmin.exc.QubesException as ex:
  602. msg.append(str(ex))
  603. # include_in_memory_balancing applied in services tab
  604. # in case VM is not Linux
  605. if hasattr(self.vm, "kernel") and self.kernel_groupbox.isVisible():
  606. try:
  607. if self.kernel.currentIndex() != self.kernel_idx:
  608. self.vm.kernel = self.kernel_list[
  609. self.kernel.currentIndex()]
  610. except qubesadmin.exc.QubesException as ex:
  611. msg.append(str(ex))
  612. # vm default_dispvm changed
  613. try:
  614. if self.default_dispvm.currentIndex() != self.default_dispvm_idx:
  615. self.vm.default_dispvm = \
  616. self.default_dispvm_list[self.default_dispvm.currentIndex()]
  617. except qubesadmin.exc.QubesException as ex:
  618. msg.append(str(ex))
  619. try:
  620. if self.virt_mode.currentIndex() != self.virt_mode_idx:
  621. self.vm.virt_mode = self.selected_virt_mode()
  622. except Exception as ex: # pylint: disable=broad-except
  623. msg.append(str(ex))
  624. return msg
  625. def boot_from_cdrom_button_pressed(self):
  626. self.save_and_apply()
  627. subprocess.check_call(['qubes-vm-boot-from-device', self.vm.name])
  628. def selected_virt_mode(self):
  629. return self.virt_mode_list[self.virt_mode.currentIndex()]
  630. def virt_mode_changed(self, new_idx): # pylint: disable=unused-argument
  631. self.update_pv_warning()
  632. self.update_pvh_dont_support_devs()
  633. self.update_pvh_kernel_ver_warning()
  634. def update_pv_warning(self):
  635. if self.selected_virt_mode() == 'PV':
  636. self.pv_warning.show()
  637. else:
  638. self.pv_warning.hide()
  639. def update_virt_mode_list(self):
  640. choices = ['HVM', 'PV']
  641. if hasattr(self, 'dev_list'):
  642. devs_attached = self.dev_list.selected_list.count() != 0
  643. else:
  644. devs_attached = bool(list(self.vm.devices['pci'].persistent()))
  645. if devs_attached:
  646. self.pvh_mode_hidden.show()
  647. else:
  648. choices.insert(0, 'PVH')
  649. self.pvh_mode_hidden.hide()
  650. if hasattr(self, 'virt_mode_list'):
  651. old_mode = self.selected_virt_mode()
  652. self.virt_mode.currentIndexChanged.disconnect()
  653. else:
  654. old_mode = None
  655. self.virt_mode.clear()
  656. # pylint: disable=attribute-defined-outside-init
  657. self.virt_mode_list, self.virt_mode_idx = utils.prepare_choice(\
  658. self.virt_mode, self.vm, 'virt_mode', choices, None,\
  659. allow_default=True, transform=(lambda x: str(x).upper()))
  660. if old_mode is not None:
  661. self.virt_mode.setCurrentIndex(self.virt_mode_list.index(old_mode))
  662. self.virt_mode.currentIndexChanged.connect(self.virt_mode_changed)
  663. self.update_pv_warning()
  664. self.update_pvh_kernel_ver_warning()
  665. def update_pvh_kernel_ver_warning(self):
  666. if self.selected_virt_mode() != 'PVH':
  667. self.pvh_kernel_version_warning.hide()
  668. return
  669. kernel = self.kernel_list[self.kernel.currentIndex()]
  670. if self.pvh_kernel_version_ok(kernel):
  671. self.pvh_kernel_version_warning.hide()
  672. else:
  673. self.pvh_kernel_version_warning.show()
  674. def kernel_changed(self):
  675. self.update_pvh_kernel_ver_warning()
  676. def pvh_kernel_version_ok(self, name):
  677. # There are nearly no limitaions on kernel names (only file system and
  678. # general qvm-prefs rules). So we just look if we see something which
  679. # looks like a version number. It's just a warning to help the user
  680. # anyways.
  681. if name is None:
  682. return False
  683. if name is qubesadmin.DEFAULT:
  684. name = self.vm.app.default_kernel
  685. m = re.search(r'(\d+)\.(\d+)', name)
  686. if m is None:
  687. return False
  688. return (int(m.group(1)), int(m.group(2))) >= (4, 11)
  689. ######## devices tab
  690. def __init_devices_tab__(self):
  691. self.dev_list = multiselectwidget.MultiSelectWidget(self)
  692. self.dev_list.add_all_button.setVisible(False)
  693. self.devices_layout.addWidget(self.dev_list)
  694. devs = []
  695. lspci = subprocess.check_output(['/usr/sbin/lspci']).decode()
  696. for dev in lspci.splitlines():
  697. devs.append((dev.rstrip(), dev.split(' ')[0]))
  698. # pylint: disable=too-few-public-methods
  699. class DevListWidgetItem(QtGui.QListWidgetItem):
  700. def __init__(self, name, ident, parent=None):
  701. super(DevListWidgetItem, self).__init__(name, parent)
  702. self.ident = ident
  703. persistent = [ass.ident.replace('_', ':')
  704. for ass in self.vm.devices['pci'].persistent()]
  705. for name, ident in devs:
  706. if ident in persistent:
  707. self.dev_list.selected_list.addItem(
  708. DevListWidgetItem(name, ident))
  709. else:
  710. self.dev_list.available_list.addItem(
  711. DevListWidgetItem(name, ident))
  712. if self.dev_list.selected_list.count() > 0\
  713. and self.include_in_balancing.isChecked():
  714. self.dmm_warning_adv.show()
  715. self.dmm_warning_dev.show()
  716. else:
  717. self.dmm_warning_adv.hide()
  718. self.dmm_warning_dev.hide()
  719. if self.vm.is_running():
  720. self.dev_list.setEnabled(False)
  721. self.turn_off_vm_to_modify_devs.setVisible(True)
  722. self.no_strict_reset_button.setEnabled(False)
  723. else:
  724. self.dev_list.setEnabled(True)
  725. self.turn_off_vm_to_modify_devs.setVisible(False)
  726. self.update_pvh_dont_support_devs()
  727. def __apply_devices_tab__(self):
  728. msg = []
  729. try:
  730. old = [ass.ident.replace('_', ':')
  731. for ass in self.vm.devices['pci'].persistent()]
  732. new = [self.dev_list.selected_list.item(i).ident
  733. for i in range(self.dev_list.selected_list.count())]
  734. for ident in new:
  735. if ident not in old:
  736. options = {}
  737. if ident in self.new_strict_reset_list:
  738. options['no-strict-reset'] = True
  739. ass = devices.DeviceAssignment(
  740. self.vm.app.domains['dom0'],
  741. ident.replace(':', '_'),
  742. persistent=True, options=options)
  743. self.vm.devices['pci'].attach(ass)
  744. elif (ident in self.current_strict_reset_list) != \
  745. (ident in self.new_strict_reset_list):
  746. current_assignment = None
  747. for assignment in self.vm.devices['pci'].assignments(
  748. persistent=True):
  749. if assignment.ident.replace("_", ":") == ident:
  750. current_assignment = assignment
  751. break
  752. if current_assignment is None:
  753. # it would be very weird if this happened
  754. msg.append(self.tr("Error re-assigning device ") +
  755. ident)
  756. continue
  757. self.vm.devices['pci'].detach(current_assignment)
  758. current_assignment.options['no-strict-reset'] = \
  759. (ident in self.new_strict_reset_list)
  760. self.vm.devices['pci'].attach(current_assignment)
  761. for ass in self.vm.devices['pci'].assignments(persistent=True):
  762. if ass.ident.replace('_', ':') not in new:
  763. self.vm.devices['pci'].detach(ass)
  764. except qubesadmin.exc.QubesException as ex:
  765. if utils.is_debug():
  766. traceback.print_exc()
  767. msg.append(str(ex))
  768. return msg
  769. def include_in_balancing_changed(self, state):
  770. for i in range(self.services_list.count()):
  771. item = self.services_list.item(i)
  772. if str(item.text()) == 'meminfo-writer':
  773. item.setCheckState(state)
  774. break
  775. if self.dev_list.selected_list.count() > 0:
  776. if state == ui_settingsdlg.QtCore.Qt.Checked:
  777. self.dmm_warning_adv.show()
  778. self.dmm_warning_dev.show()
  779. else:
  780. self.dmm_warning_adv.hide()
  781. self.dmm_warning_dev.hide()
  782. self.max_mem_size.setEnabled(self.include_in_balancing.isChecked())
  783. def devices_selection_changed(self):
  784. if self.include_in_balancing.isChecked():
  785. if self.dev_list.selected_list.count() > 0:
  786. self.dmm_warning_adv.show()
  787. self.dmm_warning_dev.show()
  788. else:
  789. self.dmm_warning_adv.hide()
  790. self.dmm_warning_dev.hide()
  791. self.update_virt_mode_list()
  792. def update_pvh_dont_support_devs(self):
  793. if self.selected_virt_mode() == 'PVH':
  794. self.dev_list.setEnabled(False)
  795. self.pvh_dont_support_devs.setVisible(True)
  796. else:
  797. self.dev_list.setEnabled(True)
  798. self.pvh_dont_support_devs.setVisible(False)
  799. def define_strict_reset_devices(self):
  800. for assignment in self.vm.devices['pci'].assignments():
  801. if assignment.options.get('no-strict-reset', False):
  802. self.current_strict_reset_list.append(
  803. assignment.ident.replace('_', ':'))
  804. self.new_strict_reset_list = self.current_strict_reset_list.copy()
  805. def strict_reset_button_pressed(self):
  806. device_list_window = device_list.PCIDeviceListWindow(
  807. self.vm, self.qapp, self.dev_list, self.new_strict_reset_list, self)
  808. device_list_window.exec()
  809. ######## applications tab
  810. def refresh_apps_button_pressed(self):
  811. self.refresh_apps_button.setEnabled(False)
  812. self.refresh_apps_button.setText(self.tr('Refresh in progress...'))
  813. thread = RefreshAppsVMThread(self.vm, self.refresh_apps_button)
  814. thread.finished.connect(self.clear_threads)
  815. thread.finished.connect(self.refresh_finished)
  816. self.threads_list.append(thread)
  817. thread.start()
  818. def refresh_finished(self):
  819. self.app_list_manager = AppmenuSelectManager(self.vm, self.app_list)
  820. self.refresh_apps_button.setEnabled(True)
  821. self.refresh_apps_button.setText(self.tr('Refresh Applications'))
  822. ######## services tab
  823. def __init_services_tab__(self):
  824. self.new_srv_dict = {}
  825. for feature in self.vm.features:
  826. if not feature.startswith('service.'):
  827. continue
  828. service = feature[len('service.'):]
  829. item = QtGui.QListWidgetItem(service)
  830. item.setCheckState(ui_settingsdlg.QtCore.Qt.Checked
  831. if self.vm.features[feature]
  832. else ui_settingsdlg.QtCore.Qt.Unchecked)
  833. self.services_list.addItem(item)
  834. self.new_srv_dict[service] = self.vm.features[feature]
  835. self.connect(
  836. self.services_list,
  837. QtCore.SIGNAL("itemClicked(QListWidgetItem *)"),
  838. self.services_item_clicked)
  839. # add suggested services
  840. self.service_line_edit.addItem('clocksync')
  841. self.service_line_edit.addItem('crond')
  842. self.service_line_edit.addItem('cups')
  843. self.service_line_edit.addItem('disable-default-route')
  844. self.service_line_edit.addItem('disable-dns-server')
  845. self.service_line_edit.addItem('meminfo-writer')
  846. self.service_line_edit.addItem('network-manager')
  847. self.service_line_edit.addItem('qubes-firewall')
  848. self.service_line_edit.addItem('qubes-network')
  849. self.service_line_edit.addItem('qubes-update-check')
  850. self.service_line_edit.addItem('qubes-updates-proxy')
  851. self.service_line_edit.addItem('qubes-yum-proxy')
  852. self.service_line_edit.addItem('updates-proxy-setup')
  853. self.service_line_edit.addItem('yum-proxy-setup')
  854. self.service_line_edit.setEditText("")
  855. def __add_service__(self):
  856. srv = str(self.service_line_edit.currentText()).strip()
  857. if srv != "":
  858. if srv in self.new_srv_dict:
  859. QtGui.QMessageBox.information(
  860. self,
  861. '',
  862. self.tr('Service already on the list!'))
  863. else:
  864. item = QtGui.QListWidgetItem(srv)
  865. item.setCheckState(ui_settingsdlg.QtCore.Qt.Checked)
  866. self.services_list.addItem(item)
  867. self.new_srv_dict[srv] = True
  868. def __remove_service__(self):
  869. item = self.services_list.currentItem()
  870. if not item:
  871. return
  872. if str(item.text()) == 'meminfo-writer':
  873. QtGui.QMessageBox.information(
  874. self,
  875. self.tr('Service can not be removed'),
  876. self.tr('Service meminfo-writer can not '
  877. 'be removed from the list.'))
  878. return
  879. row = self.services_list.currentRow()
  880. item = self.services_list.takeItem(row)
  881. del self.new_srv_dict[str(item.text())]
  882. def services_item_clicked(self, item):
  883. if str(item.text()) == 'meminfo-writer':
  884. if item.checkState() == ui_settingsdlg.QtCore.Qt.Checked:
  885. if not self.include_in_balancing.isChecked():
  886. self.include_in_balancing.setChecked(True)
  887. elif item.checkState() == ui_settingsdlg.QtCore.Qt.Unchecked:
  888. if self.include_in_balancing.isChecked():
  889. self.include_in_balancing.setChecked(False)
  890. def __apply_services_tab__(self):
  891. msg = []
  892. try:
  893. for i in range(self.services_list.count()):
  894. item = self.services_list.item(i)
  895. self.new_srv_dict[str(item.text())] = \
  896. (item.checkState() == ui_settingsdlg.QtCore.Qt.Checked)
  897. balancing_was_checked = self.vm.features.get(
  898. 'service.meminfo-writer', True)
  899. balancing_is_checked = self.include_in_balancing.isChecked()
  900. meminfo_writer_checked = self.new_srv_dict.get(
  901. 'meminfo-writer', True)
  902. if balancing_is_checked != meminfo_writer_checked:
  903. if balancing_is_checked != balancing_was_checked:
  904. self.new_srv_dict['meminfo-writer'] = balancing_is_checked
  905. for service, v in self.new_srv_dict.items():
  906. feature = 'service.' + service
  907. if v != self.vm.features.get(feature, object()):
  908. self.vm.features[feature] = v
  909. for feature in self.vm.features:
  910. if not feature.startswith('service.'):
  911. continue
  912. service = feature[len('service.'):]
  913. if service not in self.new_srv_dict:
  914. del self.vm.features[feature]
  915. except qubesadmin.exc.QubesException as ex:
  916. msg.append(str(ex))
  917. return msg
  918. ######### firewall tab related
  919. def set_fw_model(self, model):
  920. self.fw_model = model
  921. self.rulesTreeView.setModel(model)
  922. self.rulesTreeView.header().setResizeMode(
  923. QtGui.QHeaderView.ResizeToContents)
  924. self.rulesTreeView.header().setResizeMode(0, QtGui.QHeaderView.Stretch)
  925. self.set_allow(model.allow)
  926. if model.temp_full_access_expire_time:
  927. self.temp_full_access.setChecked(True)
  928. self.temp_full_access_time.setValue(
  929. (model.temp_full_access_expire_time -
  930. int(firewall.datetime.datetime.now().strftime("%s"))) / 60)
  931. def disable_all_fw_conf(self):
  932. self.firewall_modified_outside_label.setVisible(True)
  933. self.policy_allow_radio_button.setEnabled(False)
  934. self.policy_deny_radio_button.setEnabled(False)
  935. self.rulesTreeView.setEnabled(False)
  936. self.new_rule_button.setEnabled(False)
  937. self.edit_rule_button.setEnabled(False)
  938. self.delete_rule_button.setEnabled(False)
  939. self.firewal_rules_label.setEnabled(False)
  940. self.tempFullAccessWidget.setEnabled(False)
  941. def set_allow(self, allow):
  942. self.policy_allow_radio_button.setChecked(allow)
  943. self.policy_deny_radio_button.setChecked(not allow)
  944. self.policy_changed()
  945. def policy_changed(self):
  946. self.rulesTreeView.setEnabled(
  947. self.policy_deny_radio_button.isChecked())
  948. self.new_rule_button.setEnabled(
  949. self.policy_deny_radio_button.isChecked())
  950. self.edit_rule_button.setEnabled(
  951. self.policy_deny_radio_button.isChecked())
  952. self.delete_rule_button.setEnabled(
  953. self.policy_deny_radio_button.isChecked())
  954. self.firewal_rules_label.setEnabled(
  955. self.policy_deny_radio_button.isChecked())
  956. self.tempFullAccessWidget.setEnabled(
  957. self.policy_deny_radio_button.isChecked())
  958. def new_rule_button_pressed(self):
  959. dialog = firewall.NewFwRuleDlg()
  960. self.fw_model.run_rule_dialog(dialog)
  961. def edit_rule_button_pressed(self):
  962. selected = self.rulesTreeView.selectedIndexes()
  963. if selected:
  964. dialog = firewall.NewFwRuleDlg()
  965. dialog.set_ok_state(True)
  966. row = self.rulesTreeView.selectedIndexes().pop().row()
  967. self.fw_model.populate_edit_dialog(dialog, row)
  968. self.fw_model.run_rule_dialog(dialog, row)
  969. def delete_rule_button_pressed(self):
  970. for i in {index.row() for index
  971. in self.rulesTreeView.selectedIndexes()}:
  972. self.fw_model.remove_child(i)
  973. # Bases on the original code by:
  974. # Copyright (c) 2002-2007 Pascal Varet <p.varet@gmail.com>
  975. def handle_exception(exc_type, exc_value, exc_traceback):
  976. filename, line, dummy, dummy = traceback.extract_tb(exc_traceback).pop()
  977. filename = os.path.basename(filename)
  978. error = "%s: %s" % (exc_type.__name__, exc_value)
  979. strace = ""
  980. stacktrace = traceback.extract_tb(exc_traceback)
  981. while stacktrace:
  982. (filename, line, func, txt) = stacktrace.pop()
  983. strace += "----\n"
  984. strace += "line: %s\n" % txt
  985. strace += "func: %s\n" % func
  986. strace += "line no.: %d\n" % line
  987. strace += "file: %s\n" % filename
  988. msg_box = QtGui.QMessageBox()
  989. msg_box.setDetailedText(strace)
  990. msg_box.setIcon(QtGui.QMessageBox.Critical)
  991. msg_box.setWindowTitle("Houston, we have a problem...")
  992. msg_box.setText("Whoops. A critical error has occured. "
  993. "This is most likely a bug in Qubes Manager.<br><br>"
  994. "<b><i>%s</i></b>" % error +
  995. "<br/>at line <b>%d</b><br/>of file %s.<br/><br/>"
  996. % (line, filename))
  997. msg_box.exec_()
  998. parser = QubesArgumentParser(vmname_nargs=1)
  999. parser.add_argument('--tab', metavar='TAB',
  1000. action='store',
  1001. choices=VMSettingsWindow.tabs_indices.keys())
  1002. parser.set_defaults(
  1003. tab='basic',
  1004. )
  1005. def main(args=None):
  1006. args = parser.parse_args(args)
  1007. vm = args.domains.pop()
  1008. qapp = QtGui.QApplication(sys.argv)
  1009. qapp.setOrganizationName('Invisible Things Lab')
  1010. qapp.setOrganizationDomain("https://www.qubes-os.org/")
  1011. qapp.setApplicationName("Qube Settings")
  1012. if not utils.is_debug():
  1013. sys.excepthook = handle_exception
  1014. settings_window = VMSettingsWindow(vm, qapp, args.tab)
  1015. settings_window.show()
  1016. qapp.exec_()
  1017. qapp.exit()
  1018. if __name__ == "__main__":
  1019. main()
  1020. # vim:sw=4:et: