Removed qvm_start call from bootfromdevice

Returns cdrom_location and handles it from caller
This commit is contained in:
donoban 2021-03-14 00:20:08 +01:00
parent 45e60baecb
commit 57130043e3
No known key found for this signature in database
GPG Key ID: 141310D8E3ED08A5
2 changed files with 11 additions and 9 deletions

View File

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

View File

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