Hi,
Reading
http://libvirt.org/hooks.html I'm wondering of the following
implication is accurate:
Under "QEMU guest migration" it says
At the beginning of the migration, the qemu hook script on the
_destination_ host is executed with the "start" operation.
Above that, under "Specifics"
Before a QEMU guest is started, the qemu hook script is called in
two locations; if either location fails, the guest is not started.
The first location, since 0.9.0, is before libvirt performs any
resource labeling.... This is called as:
/etc/libvirt/hooks/qemu guest_name prepare begin -
The second location, available Since 0.8.0, occurs after libvirt has
finished labeling all resources, but has not yet started the guest,
called as:
/etc/libvirt/hooks/qemu guest_name start begin -
Is it accurate that under 0.9.x, starting a VM will run the qemu hook script
as both "prepare" and "start," but migrating a VM will only run the
qemu
hook script as "start"? Or is the description incomplete with libvirt also
running "prepare" on migration?
Another question, under "Calling libvirt functions from within a hook
script" it says
DO NOT DO THIS!
A hook script must not call back into libvirt, as the libvirt daemon
is already waiting for the script to exit.
A deadlock is likely to occur.
That makes obvious sense. But does it apply to calling libvirt on a second
system? For example, a script might check the status of VMs on a second
system as a condition of starting a VM on first, using virsh. My guess is
that shouldn't deadlock. But then since during migration "the qemu hook
script on the _destination_ host is executed," if the destination hook
script were in turn to use virsh to check the _source_ host, then in a
roundabout way a libvirt function has been called from within the hook
script. I can't quite picture whether this particular instance would be
dangerous.
If it's accurate that the _destination_ hook script is only called with
"start" and not with "prepare," the second question matters less. The
checks
on the second system that I want to do can be limited to the "prepare"
invocation, and so never loop back.
On the other hand, if the destination hook script _is_ called with "prepare"
during migration, it would be useful to know how to tell if it's being
called as part of a migration.
TIA,
Whit