Comment # 19 on bug 1174365 from
(In reply to Klaus Mueller from comment #18)
> Searching for handleSystemMessageFunc in
> https://github.com/paboldin/libvirt/blob/master/daemon/libvirtd.c gives:
> 
> static DBusHandlerResult
> handleSystemMessageFunc(DBusConnection *connection ATTRIBUTE_UNUSED,
>                         DBusMessage *message,
>                         void *opaque)
> ...
> 
> Now it's sure, that a message sent via DBUS initiated the stop of the VM.
> This interferes with systemd stop services (-> racy). The first one wins ...
> .

Heh, and I'm fine admitting I was wrong about libvirt-guests being the only way
to suspend a VM. It is true for the system libvirtd running as root, but not
session libvirtds running unprivileged

https://gitlab.com/libvirt/libvirt/-/commit/b88b171731b6c00cd04c7ffd79b04ccdaf9502c9

That commit registers callbacks with dbus, but only if the daemon is
unprivileged. The callbacks eventually invoke virStateStop for each driver, and
in the case of qemu, the function indeed suspends (saves) all running/paused
VMs

https://gitlab.com/libvirt/libvirt/-/commit/8f9a69317daca80c64e7734c5d08186e8fb8cdee

AFAICT, there is no way to change the behavior via config files, env vars, etc.
Seems reasonable to allow it though. E.g. similar to libvirt-guests, allow
shutting down VMs instead of suspend.

Would you be willing to report this bug in the upstream issue tracker, where
other libvirt devs can chime in? I can do it, but would like to avoid being a
message broker only slowing down communication

https://gitlab.com/libvirt/libvirt/-/issues/new

> > Yeah, that's a classic problem with save/restore. NTP in the guest helps to
> > some extent. If the guest has been suspended for long periods of time,
> > 'virsh domtime ...' or the qemu guest agent 'guest-set-time' command can be
> > used to correct the  guest's clock
> > 
> > https://qemu.readthedocs.io/en/latest/interop/qemu-ga-ref.html#qapidoc-19
> 
> That's a very helpful hint, too! Thanks for it! I tested it and its working.
> Do I understand that I have to execute the guest-set-time myself? Maybe
> there is a switch to enable the execution on startup automatically? Or maybe
> there is a possibility to add "scripts" to be started after a VM has been
> resumed?

I vaguely recall some facility for automating guest-set-time, but can't find
any info on it now. My recollection could also be wrong. There are libvirt
hooks, including one for "restore begin", but not "restore end". Also, I'm not
sure if hooks work with unprivileged daemons

https://libvirt.org/hooks.html

There's probably other ways to automate it, e.g. registering for domain events
from libvirt and running guest-set-time after the VM is running and the guest
agent is alive. I'd also suggest asking on the livirt-users@redhat.com list,
where you might get a better answer :-).


You are receiving this mail because: