From d85940c5a56fbcddcdfe347e2952992adc8c500c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Fri, 6 Sep 2019 15:59:13 +0200 Subject: [PATCH] Added an Advanced tab to Create New Qube dialog Tab contains a warning, provides_network checkbox, install_system_after_creation checkbox, storage pool settings and initial RAM. references QubesOS/qubes-issues#5127 fixes QubeSOS/qubes-issues#5198 --- qubesmanager/create_new_vm.py | 51 ++++- ui/newappvmdlg.ui | 341 ++++++++++++++++++++++------------ 2 files changed, 264 insertions(+), 128 deletions(-) diff --git a/qubesmanager/create_new_vm.py b/qubesmanager/create_new_vm.py index a4a3cb04..f239894c 100644 --- a/qubesmanager/create_new_vm.py +++ b/qubesmanager/create_new_vm.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python3 # # The Qubes OS Project, http://www.qubes-os.org # @@ -37,7 +37,8 @@ # pylint: disable=too-few-public-methods class CreateVMThread(QtCore.QThread): - def __init__(self, app, vmclass, name, label, template, properties): + def __init__(self, app, vmclass, name, label, template, properties, + pool): QtCore.QThread.__init__(self) self.app = app self.vmclass = vmclass @@ -45,6 +46,7 @@ def __init__(self, app, vmclass, name, label, template, properties): self.label = label self.template = template self.properties = properties + self.pool = pool self.msg = None def run(self): @@ -54,15 +56,29 @@ def run(self): src_vm = self.app.default_template else: src_vm = self.template - vm = self.app.clone_vm(src_vm, self.name, self.vmclass, - ignore_volumes=['private']) + + args = { + 'ignore_volumes': ['private'] + } + if self.pool: + args['pool'] = self.pool + + vm = self.app.clone_vm(src_vm, self.name, self.vmclass, **args) + vm.label = self.label for k, v in self.properties.items(): setattr(vm, k, v) else: - vm = self.app.add_new_vm( - self.vmclass, name=self.name, - label=self.label, template=self.template) + args = { + "name": self.name, + "label": self.label, + "template": self.template + } + if self.pool: + args['pool'] = self.pool + + vm = self.app.add_new_vm(self.vmclass, **args) + for k, v in self.properties.items(): setattr(vm, k, v) @@ -107,6 +123,16 @@ def __init__(self, qtapp, app, parent=None): (lambda vm: vm.provides_network), allow_internal=False, allow_default=True, allow_none=True) + self.pool_list, self.pool_idx = utils.prepare_choice( + widget=self.storage_pool, + holder=None, + propname=None, + choice=self.app.pools.values(), + default=self.app.default_pool, + allow_default=True, + allow_none=False + ) + self.name.setValidator(QtGui.QRegExpValidator( QtCore.QRegExp("[a-zA-Z0-9_-]*", QtCore.Qt.CaseInsensitive), None)) self.name.selectAll() @@ -163,8 +189,17 @@ def accept(self): properties['virt_mode'] = 'hvm' properties['kernel'] = None + if self.pool_list[self.storage_pool.currentIndex()] is not \ + qubesadmin.DEFAULT: + pool = self.pool_list[self.storage_pool.currentIndex()] + else: + pool = None + + if self.init_ram.value() > 0: + properties['memory'] = self.init_ram.value() + self.thread = CreateVMThread( - self.app, vmclass, name, label, template, properties) + self.app, vmclass, name, label, template, properties, pool) self.thread.finished.connect(self.create_finished) self.thread.start() diff --git a/ui/newappvmdlg.ui b/ui/newappvmdlg.ui index 44eece08..87034110 100644 --- a/ui/newappvmdlg.ui +++ b/ui/newappvmdlg.ui @@ -15,128 +15,231 @@ - - + .. - - - - 450 - 260 - 160 - 27 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 0 - 10 - 611 - 241 - - - - - - - Template: - - - template_vm - + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + 0 + 0 + + + + 0 + + + + Basic + + + + 12 + + + 12 + + + 12 + + + 12 + + + 12 + + + 9 + + + + + Networking: + + + + + + + + + + + + + Template: + + + + + + + Name and label: + + + + + + + my-new-qube + + + + + + + true + + + + + + + launch settings after creation + + + + + + + Type: + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + - - - - - Networking: - - - template_vm - - - - - - - false - - - install system from device (also available from settings) - - - - - - - launch settings after creation - - - - - - - - - - provides network - - - - - - - Name and label: - - - name - - - - - - - true - - - - - - + + Advanced - - - - - - - - - - my-new-qube - - - - - - - - - - Type: - + + + + 12 + + + 12 + + + 12 + + + 12 + + + 12 + + + 9 + + + + + (default) + + + MB + + + 90000000 + + + + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-weight:600;">Caution</span>: changing these settings can compromise your system or make the qube unable to boot. Use only if you know what you are doing.</p></body></html> + + + true + + + + + + + + + + + + + + Storage pool + + + + + + + Initial RAM (also available from settings) + + + + + + + install system from device (also available from settings) + + + + + + + provides network to other qubes + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + - - - + + + name @@ -144,9 +247,7 @@ vm_type template_vm netvm - provides_network launch_settings - install_system buttonBox