diff --git a/qubesmanager/bootfromdevice.py b/qubesmanager/bootfromdevice.py index 683ce80..e408adf 100644 --- a/qubesmanager/bootfromdevice.py +++ b/qubesmanager/bootfromdevice.py @@ -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( diff --git a/qubesmanager/create_new_vm.py b/qubesmanager/create_new_vm.py index 3ba22ef..3ebcd5f 100644 --- a/qubesmanager/create_new_vm.py +++ b/qubesmanager/create_new_vm.py @@ -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()