Skip to content

Commit

Permalink
qubesvm: do not prevent suspend if qubes.SuspendPre fails
Browse files Browse the repository at this point in the history
The service is called to allow VM to prepare for suspend, but it's just
a notification - if the call fails, suspend anyway.
This especially is important for HVM with PCI devices - if the service
fails, userspace might be not prepared for the suspend, but later
suspend by the kernel in many cases is enough for the VM to recover. If
VM isn't suspended (but paused by Xen instead), it almost never survive
resume.

While at it, improve logging of both service failure and actual suspend
failure.

QubesOS/qubes-issues#6066
  • Loading branch information
marmarek committed Oct 31, 2022
1 parent 2b0da0e commit b63d487
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions qubes/vm/qubesvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,8 +1386,16 @@ async def suspend(self):
raise qubes.exc.QubesVMNotRunningError(self)

if self.features.check_with_template('qrexec', False):
await self.run_service_for_stdio('qubes.SuspendPre',
user='root')
try:
await self.run_service_for_stdio('qubes.SuspendPre',
user='root')
except subprocess.CalledProcessError as e:
self.log.warning(
"qubes.SuspendPre for %s failed with %d (stderr: %s), "
"suspending anyway",
self.name,
e.returncode,
qubes.utils.sanitize_stderr_for_log(e.stderr))
try:
self.libvirt_domain.pMSuspendForDuration(
libvirt.VIR_NODE_SUSPEND_TARGET_MEM, 0, 0)
Expand All @@ -1396,6 +1404,7 @@ async def suspend(self):
# OS inside doesn't support full suspend, just pause it
self.libvirt_domain.suspend()
else:
self.log.warning("Failed to suspend '%s'", self.name)
raise

return self
Expand Down

0 comments on commit b63d487

Please sign in to comment.