Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/109'
Browse files Browse the repository at this point in the history
* origin/pr/109:
  Make pylint happy
  domains: Handle removal of VM during on_shutdown.
  • Loading branch information
marmarek committed May 30, 2021
2 parents baeacd4 + c1412d8 commit b6828cc
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions qui/tray/domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,26 @@ def remove_domain_item(self, _submitter, _event, vm, **_kwargs):
self.tray_menu.remove(vm_widget)
del self.menu_items[vm]

def handle_domain_shutdown(self, vm):
try:
if getattr(vm, 'klass', None) == 'TemplateVM':
for menu_item in self.menu_items.values():
try:
if not menu_item.vm.is_running():
# A VM based on this template can only be
# outdated if the VM is currently running.
continue
except exc.QubesPropertyAccessError:
continue
if getattr(menu_item.vm, 'template', None) == vm and \
any(vol.is_outdated()
for vol in menu_item.vm.volumes.values()):
menu_item.name.update_outdated(True)
except exc.QubesVMNotFoundError:
# attribute not available anymore as VM was removed
# in the meantime
pass

def update_domain_item(self, vm, event, **kwargs):
''' Update the menu item with the started menu for
the specified vm in the tray'''
Expand Down Expand Up @@ -698,19 +718,7 @@ def update_domain_item(self, vm, event, **kwargs):
item.update_state(state)

if event == 'domain-shutdown':
if getattr(vm, 'klass', None) == 'TemplateVM':
for menu_item in self.menu_items.values():
try:
if not menu_item.vm.is_running():
# A VM based on this template can only be
# outdated if the VM is currently running.
continue
except exc.QubesPropertyAccessError:
continue
if getattr(menu_item.vm, 'template', None) == vm and \
any(vol.is_outdated()
for vol in menu_item.vm.volumes.values()):
menu_item.name.update_outdated(True)
self.handle_domain_shutdown(vm)
# if the VM was shut down, it is no longer outdated
item.name.update_outdated(False)

Expand Down

0 comments on commit b6828cc

Please sign in to comment.