Skip to content

Commit

Permalink
Update size on disk in Qube Manager occassionally
Browse files Browse the repository at this point in the history
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
  • Loading branch information
marmarta committed Aug 10, 2023
1 parent 9b9e972 commit df5748c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion qubesmanager/qube_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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]
Expand All @@ -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).\
Expand Down

0 comments on commit df5748c

Please sign in to comment.