Libvirt, qemu, reboot hook

hooklibvirtqemu

Is it possible to detect that the guest VM has rebooted and perform an action using libvirt / qemu? The hooks here only support the "start" and "stop" events. I would like to detect if my VM has rebooted.

HOST is running ubuntu 10.04
GUEST is running ubuntu 10.04

Best Answer

The qemu message protocol (QMP) supports a number of asynchronous messages, including one about restart. If you start your qemu instance with a QMP Server it will report a restart. libvirtd uses QMP to manage qemu guests, so you might try setting something like a proxy qmp server up to look for reboot messages. http://wiki.qemu.org/QMP#Asynchronous_message has a little bit more, but the QEMU-KVM source code has the best documentation of events.