From df5748ca25f7199dedcff3ec7b24f052dece8ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Thu, 10 Aug 2023 22:32:06 +0200 Subject: [PATCH] Update size on disk in Qube Manager occassionally To avoid too big a system load, the update will happen: - every 5 minutes for running qubes - on qube state change (running -> transient -> halted etc.) fixes QubesOS/qubes-issues#6053 --- qubesmanager/qube_manager.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index b1127c24..f49965e5 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -849,6 +849,10 @@ def __init__(self, qt_app, qubes_app, dispatcher, _parent=None): self.progress = None self.check_updates() + self.size_on_disk_timer = QTimer() + self.size_on_disk_timer.timeout.connect(self.update_running_size) + self.size_on_disk_timer.setInterval(1000 * 60 * 5) # every 5 mins + self.size_on_disk_timer.start() def change_template(self, template): selected_vms = self.get_selected_vms() @@ -1065,6 +1069,12 @@ def check_updates(self, info=None): except exc.QubesDaemonAccessError: return + def update_running_size(self, *_args): + for vm in self.qubes_app.domains: + if vm.is_running(): + self.qubes_cache.get_vm(qid=vm.qid).update( + update_size_on_disk=True, event='disk_size') + def on_domain_added(self, _submitter, _event, vm, **_kwargs): try: domain = self.qubes_app.domains[vm] @@ -1083,7 +1093,8 @@ def on_domain_removed(self, _submitter, _event, **kwargs): def on_domain_status_changed(self, vm, event, **_kwargs): try: - self.qubes_cache.get_vm(qid=vm.qid).update(event=event) + self.qubes_cache.get_vm(qid=vm.qid).update(update_size_on_disk=True, + event=event) if vm.klass in {'TemplateVM'}: for appvm in vm.appvms: self.qubes_cache.get_vm(qid=appvm.qid).\