If qemu is not running, or just the binary qemu-system-x86_64 is executed without a VM, suspend /resume function normally.
If qemu is running an active guest, the host system freezes during suspend. Last kernel message is “wlan0: disassociate from …”, after that the system is unresponsive. SysRq does not work, but may be related to my keyboard.
Incremental updates and testing the result brought me to the conclusion that the systemd update from 255 → 256 was responsible for the suspend failures, after all. In retrospect, the systemctl Journal started to show “Failed to freeze unit ‘user.slice’” errors after the failed update on June 19.
Github has two issues that highlight this bug.
33626 might well be the root cause of this failure; the proposed patch has not yet appeared in any kernel.
So it’s the same problem as with NVIDIA graphics (which in my case is optional because I both have a dedicated NVIDIA card as well as a builtin AMD GPU, and I can switch these).
But the thing is I was also experiencing this when using AMD graphics, which makes clear that the issue is much larger than just NVIDIA related.
It’s quite frustrating to see my system entirely hang with a black screen after walking away while it was running a virtual machine too.
In my case I am running vanilla Arch Linux, but the same things currently apply, running systemd version 256+.
I am now also considering that SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=false setting, because if there are multiple ways those problems occur, what more is possible?
However, for QEMU I did solve it in another way (I really don’t trust sleep and hibernation generally actually), I changed my shell script to run QEMU this way:
systemd-inhibit is a systemd tool to suppress the sleep while the program (QEMU in this case) you specify to run with it is running.
(Note that the 2 environment variables that I have set are unrelated, these solve another problem, namely that running under Wayland while fractional scaling is used results in pixel blur with QEMU, so XWayand is a need for me)
Thank you for the systemd-inhibit snippet, it might be useful at some time.
The SYSTEMD_SLEEP_FREEZE_USER_SESSIONS environment variable is currently in place.
$ journalctl -b 0 -u systemd-suspend
now contains a warning:
User sessions remain unfrozen on explicit request ($SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=0).
This is not recommended, and might result in unexpected behavior, particularly in suspend-then-hibernate operations or setups with encrypted home directories.
The kernel freezes tasks anyway (just not initiated by systemd), the systemd warning relates to scenarios that are out of scope for me, so I might keep this workaround indefinitely.