Skip to content

Commit

Permalink
Fix cache invalidation for domain-start-failed
Browse files Browse the repository at this point in the history
may improve domains widgets functionality, too

fixes QubesOS/qubes-issues#7844
  • Loading branch information
marmarta committed Nov 21, 2022
1 parent ebea2e7 commit e6efb91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions qubesadmin/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ def _update_power_state_cache(self, subject, event, **kwargs):
- domain-shutdown
- domain-paused
- domain-unpaused
- domain-start-failed
This is done in :py:class:`qubesadmin.events.EventsDispatcher` class
directly, before calling other handlers.
Expand All @@ -671,6 +672,8 @@ def _update_power_state_cache(self, subject, event, **kwargs):
power_state = 'Paused'
elif event == 'domain-unpaused':
power_state = 'Running'
elif event == 'domain-start-failed':
power_state = 'Halted'
else:
# unknown power state change, drop cached power state
power_state = None
Expand Down
3 changes: 2 additions & 1 deletion qubesadmin/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ def handle(self, subject, event, **kwargs):
event.startswith('property-reset:'):
self.app._invalidate_cache(subject, event, **kwargs)
elif event in ('domain-pre-start', 'domain-start', 'domain-shutdown',
'domain-paused', 'domain-unpaused'):
'domain-paused', 'domain-unpaused',
'domain-start-failed'):
self.app._update_power_state_cache(subject, event, **kwargs)
elif event == 'connection-established':
# on (re)connection, clear cache completely - we don't have
Expand Down

0 comments on commit e6efb91

Please sign in to comment.