Nils Toedtmann
2013-Jul-24 14:07 UTC
[libvirt-users] How to trigger a script in a guest after resume? (aka guest system clock incorrect after host reboot with suspended guest)
Hi Is there a way i can trigger a script within a libvirt guest immediately after resume? E.g. i don't see any log message that indicates to a guest that it had been paused and was just woken up. The problem that i am trying to solve is that when i reboot the host (pausing all guests), the guests' system clocks are a few minutes late after resume. The guests RTC (current_clocksource = kvm-clock) are correct though, so a "hwclock --hctosys" fixed the offset. I only need to find out how to call hwclock right after resume! Right now i call hwclock every few minutes, but i'd like to shorten the window of wrong time. OTOH i'd like to avoid installing ntpd into all guests, given their perfectly fine RTCs. On the host i am using CentOS 6.4 with all patches and the packaged libvirt-0.10.2 and qemu-kvm-0.12.1.2. All guests are Ubuntu 12.04. /nils.
Eric Blake
2013-Jul-24 21:16 UTC
Re: [libvirt-users] How to trigger a script in a guest after resume? (aka guest system clock incorrect after host reboot with suspended guest)
On 07/24/2013 08:07 AM, Nils Toedtmann wrote:> Hi > > Is there a way i can trigger a script within a libvirt guest immediately > after resume? E.g. i don't see any log message that indicates to a guest > that it had been paused and was just woken up.Upstream qemu has added the guest-set-time command to qemu-ga as of qemu 1.5; if you have the qemu-ga daemon running in your guest (available at least for Linux and Windows guests), then triggering this guest-agent command would do what you want. It might be nice to expose an API in libvirt for poking the guest-agent command on demand, and/or adding some XML configuration to a guest that requests that libvirt will automatically send the guest-agent command every time the guest is resumed. But for now, you're stuck using the unsupported 'virsh qemu-agent-command' option for triggering the command manually. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org