Added bootfromdevice dialog to create_new_vm (instead subprocess.call)

This commit is contained in:
donoban 2021-03-14 13:23:43 +01:00
parent 70ea6e2591
commit cbae4f5868
No known key found for this signature in database
GPG Key ID: 141310D8E3ED08A5
2 changed files with 19 additions and 7 deletions

View File

@ -28,13 +28,14 @@ from qubesadmin import exc
class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
QtWidgets.QDialog):
def __init__(self, vm, qapp, qubesapp=None, parent=None):
def __init__(self, vm, qapp, qubesapp=None, parent=None, new_vm = False):
super().__init__(parent)
self.vm = vm
self.qapp = qapp
self.qubesapp = qubesapp
self.cdrom_location = None
self.new_vm = new_vm
self.setupUi(self)
self.setWindowTitle(
@ -69,6 +70,9 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
self.accept()
def __warn_if_running__(self):
if self.new_vm:
return
try:
if self.qubesapp.domains[self.vm].is_running():
QtWidgets.QMessageBox.warning(

View File

@ -32,6 +32,7 @@ import qubesadmin.tools
import qubesadmin.exc
from . import utils
from . import bootfromdevice
from .ui_newappvmdlg import Ui_NewVMDlg # pylint: disable=import-error
@ -102,6 +103,7 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
self.thread = None
self.progress = None
self.boot_dialog = None
utils.initialize_widget_with_labels(
widget=self.label,
@ -175,9 +177,14 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
def accept(self):
vmclass = self.vm_type.currentData()
name = str(self.name.text())
if self.install_system.isChecked():
self.boot_dialog = bootfromdevice.VMBootFromDeviceWindow(
name, self.qtapp, self.app, self, True)
if not self.boot_dialog.exec_():
return
if name in self.app.domains:
QtWidgets.QMessageBox.warning(
self,
@ -227,6 +234,7 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
def create_finished(self):
self.progress.hide()
self.done(0)
if self.thread.msg:
QtWidgets.QMessageBox.warning(
@ -234,15 +242,15 @@ class NewVmDlg(QtWidgets.QDialog, Ui_NewVMDlg):
self.tr("Error creating the qube!"),
self.tr("ERROR: {0}").format(self.thread.msg))
self.done(0)
if not self.thread.msg:
else:
if self.launch_settings.isChecked():
subprocess.check_call(['qubes-vm-settings',
str(self.name.text())])
if self.install_system.isChecked():
subprocess.check_call(
['qubes-vm-boot-from-device', str(self.name.text())])
qubesadmin.tools.qvm_start.main(
['--cdrom', self.boot_dialog.cdrom_location,
self.name.text()])
def type_change(self):
template = self.template_vm.currentData()