From e6efb919cca2cc7be6ce99420802ec246bdcef5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Mon, 21 Nov 2022 14:09:25 +0100 Subject: [PATCH] Fix cache invalidation for domain-start-failed may improve domains widgets functionality, too fixes QubesOS/qubes-issues#7844 --- qubesadmin/app.py | 3 +++ qubesadmin/events/__init__.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/qubesadmin/app.py b/qubesadmin/app.py index b42f5bcc..7ac6af4c 100644 --- a/qubesadmin/app.py +++ b/qubesadmin/app.py @@ -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. @@ -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 diff --git a/qubesadmin/events/__init__.py b/qubesadmin/events/__init__.py index c982f254..25490ca6 100644 --- a/qubesadmin/events/__init__.py +++ b/qubesadmin/events/__init__.py @@ -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