Browse Source

Removed qvm_start call from bootfromdevice

Returns cdrom_location and handles it from caller
donoban 3 years ago
parent
commit
57130043e3
2 changed files with 11 additions and 9 deletions
  1. 4 7
      qubesmanager/bootfromdevice.py
  2. 7 2
      qubesmanager/settings.py

+ 4 - 7
qubesmanager/bootfromdevice.py

@@ -23,7 +23,6 @@ from . import utils
 from . import ui_bootfromdevice  # pylint: disable=no-name-in-module
 from PyQt5 import QtWidgets, QtGui  # pylint: disable=import-error
 from qubesadmin import tools
-from qubesadmin.tools import qvm_start
 from qubesadmin import exc
 
 
@@ -35,6 +34,7 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
         self.vm = vm
         self.qapp = qapp
         self.qubesapp = qubesapp
+        self.cdrom_location = None
 
         self.setupUi(self)
         self.setWindowTitle(
@@ -57,9 +57,9 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
 
     def save_and_apply(self):
         if self.blockDeviceRadioButton.isChecked():
-            cdrom_location = self.blockDeviceComboBox.currentText()
+            self.cdrom_location = self.blockDeviceComboBox.currentText()
         elif self.fileRadioButton.isChecked():
-            cdrom_location = str(self.fileVM.currentData()) + \
+            self.cdrom_location = str(self.fileVM.currentData()) + \
                              ":" + self.pathText.text()
         else:
             QtWidgets.QMessageBox.warning(
@@ -70,10 +70,7 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
 
         # warn user if the VM is currently running
         self.__warn_if_running__()
-
-        qvm_start.main(['--cdrom', cdrom_location, self.vm.name])
-
-        self.done(0)
+        self.accept()
 
     def __warn_if_running__(self):
         try:

+ 7 - 2
qubesmanager/settings.py

@@ -30,8 +30,10 @@ import traceback
 from qubesadmin.tools import QubesArgumentParser
 from qubesadmin import devices
 from qubesadmin import utils as admin_utils
+from qubesadmin.tools import qvm_start
 import qubesadmin.exc
 
+from . import bootfromdevice
 from . import utils
 from . import multiselectwidget
 from . import common_threads
@@ -1022,8 +1024,11 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog):
             self.check_mem_changes()
 
     def boot_from_cdrom_button_pressed(self):
-        self.save_and_apply()
-        subprocess.check_call(['qubes-vm-boot-from-device', self.vm.name])
+        boot_dialog = bootfromdevice.VMBootFromDeviceWindow(
+                self.vm, self.qapp, self.qubesapp, self)
+        if boot_dialog.exec_():
+            self.save_and_apply()
+            qvm_start.main(['--cdrom', boot_dialog.cdrom_location, self.vm.name])
 
     def virt_mode_changed(self, new_idx):  # pylint: disable=unused-argument
         self.update_pv_warning()