Start VM in separate thread (#149)
This commit is contained in:
parent
00aea2d3bf
commit
76761f6ba5
@ -747,17 +747,36 @@ class VmManagerWindow(QMainWindow):
|
|||||||
QMessageBox.warning (None, "Error unpausing VM!", "ERROR: {0}".format(ex))
|
QMessageBox.warning (None, "Error unpausing VM!", "ERROR: {0}".format(ex))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
thread_monitor = ThreadMonitor()
|
||||||
|
thread = threading.Thread (target=self.do_start_vm, args=(vm, thread_monitor))
|
||||||
|
thread.daemon = True
|
||||||
|
thread.start()
|
||||||
|
|
||||||
|
trayIcon.showMessage ("Qubes Manager", "Starting '{0}'...".format(vm.name), msecs=3000)
|
||||||
|
|
||||||
|
while not thread_monitor.is_finished():
|
||||||
|
app.processEvents()
|
||||||
|
time.sleep (0.1)
|
||||||
|
|
||||||
|
if thread_monitor.success:
|
||||||
|
trayIcon.showMessage ("Qubes Manager", "VM '{0}' has been started.".format(vm.name), msecs=3000)
|
||||||
|
else:
|
||||||
|
QMessageBox.warning (None, "Error starting VM!", "ERROR: {0}".format(thread_monitor.error_msg))
|
||||||
|
|
||||||
|
def do_start_vm(self, vm, thread_monitor):
|
||||||
try:
|
try:
|
||||||
vm.verify_files()
|
vm.verify_files()
|
||||||
xid = vm.start()
|
xid = vm.start()
|
||||||
except (IOError, OSError, QubesException) as err:
|
except Exception as ex:
|
||||||
QMessageBox.warning (None, "Error starting VM!", "ERROR: {0}".format(err))
|
thread_monitor.set_error_msg(str(ex))
|
||||||
|
thread_monitor.set_finished()
|
||||||
return
|
return
|
||||||
|
|
||||||
retcode = subprocess.call ([qubes_guid_path, "-d", str(xid), "-c", vm.label.color, "-i", vm.label.icon, "-l", str(vm.label.index)])
|
retcode = subprocess.call ([qubes_guid_path, "-d", str(xid), "-c", vm.label.color, "-i", vm.label.icon, "-l", str(vm.label.index)])
|
||||||
if (retcode != 0):
|
if (retcode != 0):
|
||||||
QMessageBox.warning (None, "Error starting VM!", "ERROR: Cannot start qubes_guid!")
|
hread_monitor.set_error_msg("Cannot start qubes_guid!")
|
||||||
return
|
|
||||||
|
thread_monitor.set_finished()
|
||||||
|
|
||||||
def pause_vm(self):
|
def pause_vm(self):
|
||||||
vm = self.get_selected_vm()
|
vm = self.get_selected_vm()
|
||||||
|
Loading…
Reference in New Issue
Block a user