settings.py 46 KB

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