The script tools/libvirt-guests.sh.in is used in distributions to shut down or suspend domains when the host goes down. This works like a charm. However, currently, KVM has the issue that the host going to _sleep_ sometimes affects the running domains: It sometimes happens that the domains become unresponsive CPU-hogs. It does help to suspend the KVM domains before the host sleeps. systemd provides a mechanism to do that by means of /lib/systemd/system-sleep/. libvirt-guests.sh contains most of the code needed to suspend all running domains, but it doesn't expose those mechanisms to the public. Please consider adding a "suspend" and a "resume" option to libvirt-guests.sh that applies the respective operation to all domains even if the selected shutdown operation is "shutdown". I am willing to provide a patch if you indicate that you would accept it.
If qemu VMs consume tons of CPU after host suspend/resume, that's a qemu bug that should be fixed. But the feature request is still reasonable IMO, but it wouldn't be something we enable by default. Maybe make it a qemu.conf or libvirtd.conf option that can tie into systemd's suspend inhibitor? There's a related bug at https://bugzilla.redhat.com/show_bug.cgi?id=826044
Thank you for reporting this issue to the libvirt project. Unfortunately we have been unable to resolve this issue due to insufficient maintainer capacity and it will now be closed. This is not a reflection on the possible validity of the issue, merely the lack of resources to investigate and address it, for which we apologise. If you none the less feel the issue is still important, you may choose to report it again at the new project issue tracker https://gitlab.com/libvirt/libvirt/-/issues The project also welcomes contribution from anyone who believes they can provide a solution.