Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qubes/vm/adminvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def on_feature_set_preload_dispvm_max(
return
if not (appvm := getattr(self.app, "default_dispvm", None)):
return
reason = "global feature was set to " + str(value)
reason = "global feature was set to " + repr(str(value))
asyncio.ensure_future(
appvm.fire_event_async("domain-preload-dispvm-start", reason=reason)
)
2 changes: 2 additions & 0 deletions qubes/vm/dispvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def __init__(self, app, xml, *args, **kwargs):
self.volume_config = copy.deepcopy(self.default_volume_config)
template = kwargs.get("template", None)
self.preload_complete = asyncio.Event()
self.clean_shutdown = False

if xml is None:
assert template is not None
Expand Down Expand Up @@ -559,6 +560,7 @@ async def cleanup(self):
"""
if self not in self.app.domains:
return
self.clean_shutdown = True
try:
await self.kill()
except qubes.exc.QubesVMNotStartedError:
Expand Down
2 changes: 1 addition & 1 deletion qubes/vm/mix/dvmtemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def on_feature_set_preload_dispvm_max(
return
if self.is_global_preload_set():
return
reason = "local feature was set to " + str(value)
reason = "local feature was set to " + repr(str(value))
asyncio.ensure_future(
self.fire_event_async("domain-preload-dispvm-start", reason=reason)
)
Expand Down
14 changes: 11 additions & 3 deletions qubes/vm/qubesvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,8 @@ async def start(
)
if qmemman_client:
qmemman_client.close()
if getattr(self, "clean_shutdown", False):
return
raise

try:
Expand Down Expand Up @@ -1509,10 +1511,12 @@ async def start(
self.log.info("Setting Qubes DB info for the qube")
await self.start_qubesdb()
if self.untrusted_qdb is None:
msg = "qubesdb not connected, VM was killed in the meantime"
if getattr(self, "clean_shutdown", False):
self.log.error(msg)
return
# this can happen if vm.is_running() is False
raise qubes.exc.QubesException(
"qubesdb not connected, VM was killed in the meantime"
)
raise qubes.exc.QubesException(msg)
self.create_qdb_entries()
self.start_qdb_watch()

Expand Down Expand Up @@ -1549,6 +1553,8 @@ async def start(
await self.fire_event_async(
"domain-start-failed", reason=str(exc)
)
if getattr(self, "clean_shutdown", False):
return
raise

return self
Expand Down Expand Up @@ -2152,6 +2158,8 @@ async def start_qrexec_daemon(self, stubdom=False):
)
except subprocess.CalledProcessError as err:
if err.returncode == 3:
if getattr(self, "clean_shutdown", False):
return
raise qubes.exc.QubesVMError(
self,
"Cannot connect to qrexec agent for {} seconds, "
Expand Down