diff --git a/pkgs/clan-vm-manager/clan_vm_manager/models/use_vms.py b/pkgs/clan-vm-manager/clan_vm_manager/models/use_vms.py index ac0b91497..ab19c829d 100644 --- a/pkgs/clan-vm-manager/clan_vm_manager/models/use_vms.py +++ b/pkgs/clan-vm-manager/clan_vm_manager/models/use_vms.py @@ -72,13 +72,12 @@ class VM(GObject.Object): threading.Thread(target=self.__start).start() - if self._watcher_id == 0: - # Every 50ms check if the VM is still running - self._watcher_id = GLib.timeout_add(50, self._vm_watcher_task) + # Every 50ms check if the VM is still running + self._watcher_id = GLib.timeout_add(50, self._vm_watcher_task) - if self._watcher_id == 0: - log.error("Failed to add watcher") - raise ClanError("Failed to add watcher") + if self._watcher_id == 0: + log.error("Failed to add watcher") + raise ClanError("Failed to add watcher") def _vm_watcher_task(self) -> bool: if self.is_running() != self._last_liveness: @@ -88,6 +87,7 @@ class VM(GObject.Object): # If the VM was running and now it is not, remove the watcher if prev_liveness and not self.is_running(): + print("===>Removing watcher") return GLib.SOURCE_REMOVE return GLib.SOURCE_CONTINUE diff --git a/pkgs/clan-vm-manager/clan_vm_manager/views/list.py b/pkgs/clan-vm-manager/clan_vm_manager/views/list.py index 16cfd31b5..3f5f1fc49 100644 --- a/pkgs/clan-vm-manager/clan_vm_manager/views/list.py +++ b/pkgs/clan-vm-manager/clan_vm_manager/views/list.py @@ -189,8 +189,9 @@ class ClanList(Gtk.Box): def vm_status_changed(self, switch: Gtk.Switch, vm: VM, _vm: VM) -> None: switch.set_active(vm.is_running()) switch.set_state(vm.is_running()) - - if not vm.is_running() and vm.process.proc.exitcode != 0: - print("VM exited with error. Exitcode:", vm.process.proc.exitcode) - # print(vm.read_log()) - # self.show_error_dialog(vm.read_log()) + print("====> Set switch to", vm.is_running()) + exitc = vm.process.proc.exitcode + if not vm.is_running() and exitc != 0 and exitc != -15: + print("VM exited with error. Exitcode:", exitc) + print(vm.read_log()) + self.show_error_dialog(vm.read_log())