From f65dcdbf10bb61668d7c8c13426b30b899e5a959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 30 Mar 2015 04:59:08 +0200 Subject: [PATCH] Watch for domain start/stop events and refresh VM connection info QubesVm object caches some domain state (domain ID in libvirt object, Qubes DB connection socket), which can become out of date in case of start/stop events. Currently it needs manual trigger to refresh itself. --- qubesmanager/main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qubesmanager/main.py b/qubesmanager/main.py index 82d8d5c..32f275c 100755 --- a/qubesmanager/main.py +++ b/qubesmanager/main.py @@ -261,6 +261,7 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): self.qvm_collection = qvm_collection self.blk_manager = blk_manager self.blk_manager.tray_message_func = trayIcon.showMessage + self.qubes_watch.setup_domain_watch(self.domain_state_changed_callback) self.qubes_watch.setup_block_watch(self.blk_manager.block_devs_event) self.blk_watch_thread = threading.Thread(target=self.qubes_watch.watch_loop) self.blk_watch_thread.daemon = True @@ -510,6 +511,12 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): self.manager_settings.setValue('position/y', self.y()) # do not sync for performance reasons + def domain_state_changed_callback(self, name = None, uuid = None): + if name is not None: + vm = self.qvm_collection.get_vm_by_name(name) + if vm: + vm.refresh() + def get_vms_list(self): self.qvm_collection.lock_db_for_reading() self.qvm_collection.load()