I've had my fair share of lockups because I forgot to turn off my VM before putting my host to sleep, and I've started looking into some sort of lock to prevent that kind of mistake. Normally, I'd use something like `systemd-inhibit` to do that, except the calls libvirt makes to its hook scripts are self-contained while sysd-inhibit is completely synchroneous (you use it just like `time`). I've looked into using the underlying dbus calls instead, and it appears that since Inhibit() returns a file descriptor which expires as soon as its owner is closed, I can't just lock it before the VM starts and close it when it stops.
By the looks of it, I can't write a wrapper script for qemu-system either since libvirt doesn't launch it with the same capabilities as a regular user, and the dbus calls coming from sysd-inhibit fail.
I can't seem to find a simple solution to that issue, which is a pretty big deal considering it's not something that libvirt supports on its own (unless I've missed something). What would you all reccomend?