Skip to content

Commit

Permalink
qvm-start-daemon: handle policy denials
Browse files Browse the repository at this point in the history
Do not interrupt enumerating VMs if one gets policy deny.

QubesOS/qubes-issues#1590
  • Loading branch information
marmarek committed May 2, 2024
1 parent c779d0d commit 86d0312
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions qubesadmin/tools/qvm_start_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,28 +694,32 @@ def on_connection_established(self, _subject, _event, **_kwargs):
monitor_layout = get_monitor_layout()
self.app.domains.clear_cache()
for vm in self.app.domains:
if vm.klass == 'AdminVM':
continue
try:
if vm.klass == 'AdminVM':
continue

Check warning on line 699 in qubesadmin/tools/qvm_start_daemon.py

View check run for this annotation

Codecov / codecov/patch

qubesadmin/tools/qvm_start_daemon.py#L697-L699

Added lines #L697 - L699 were not covered by tests

if not self.is_watched(vm):
continue
if not self.is_watched(vm):
continue

Check warning on line 702 in qubesadmin/tools/qvm_start_daemon.py

View check run for this annotation

Codecov / codecov/patch

qubesadmin/tools/qvm_start_daemon.py#L701-L702

Added lines #L701 - L702 were not covered by tests

power_state = vm.get_power_state()
if power_state == 'Running':
if "guivm" in self.enabled_services:
asyncio.ensure_future(
self.start_gui(vm, monitor_layout=monitor_layout)
)
if "audiovm" in self.enabled_services:
asyncio.ensure_future(self.start_audio(vm))
self.xid_cache[vm.name] = vm.xid, vm.stubdom_xid
elif power_state == 'Transient':
# it is still starting, we'll get 'domain-start'
# event when fully started
if "guivm" in self.enabled_services and vm.virt_mode == 'hvm':
asyncio.ensure_future(
self.start_gui_for_stubdomain(vm)
)
power_state = vm.get_power_state()
if power_state == 'Running':
if "guivm" in self.enabled_services:
asyncio.ensure_future(

Check warning on line 707 in qubesadmin/tools/qvm_start_daemon.py

View check run for this annotation

Codecov / codecov/patch

qubesadmin/tools/qvm_start_daemon.py#L704-L707

Added lines #L704 - L707 were not covered by tests
self.start_gui(vm, monitor_layout=monitor_layout)
)
if "audiovm" in self.enabled_services:
asyncio.ensure_future(self.start_audio(vm))
self.xid_cache[vm.name] = vm.xid, vm.stubdom_xid
elif power_state == 'Transient':

Check warning on line 713 in qubesadmin/tools/qvm_start_daemon.py

View check run for this annotation

Codecov / codecov/patch

qubesadmin/tools/qvm_start_daemon.py#L710-L713

Added lines #L710 - L713 were not covered by tests
# it is still starting, we'll get 'domain-start'
# event when fully started
if "guivm" in self.enabled_services \

Check warning on line 716 in qubesadmin/tools/qvm_start_daemon.py

View check run for this annotation

Codecov / codecov/patch

qubesadmin/tools/qvm_start_daemon.py#L716

Added line #L716 was not covered by tests
and vm.virt_mode == 'hvm':
asyncio.ensure_future(

Check warning on line 718 in qubesadmin/tools/qvm_start_daemon.py

View check run for this annotation

Codecov / codecov/patch

qubesadmin/tools/qvm_start_daemon.py#L718

Added line #L718 was not covered by tests
self.start_gui_for_stubdomain(vm)
)
except qubesadmin.exc.QubesDaemonCommunicationError as e:
vm.log.warning("Failed to handle %s: %s", vm.name, str(e))

Check warning on line 722 in qubesadmin/tools/qvm_start_daemon.py

View check run for this annotation

Codecov / codecov/patch

qubesadmin/tools/qvm_start_daemon.py#L721-L722

Added lines #L721 - L722 were not covered by tests

def on_domain_stopped(self, vm, _event, **_kwargs):
"""Handler of 'domain-stopped' event, cleans up"""
Expand Down

0 comments on commit 86d0312

Please sign in to comment.