On 12/15/2011 09:49 AM, Adam Tilghman wrote:
> From: Eric Blake <eblake redhat com>
> Subject: Re: [libvirt-users] Wanted: method for qemu hook script to know if called
for migration
> Date: Mon, 25 Jul 2011 14:17:08 -0600
>
>> As a feature suggestion, it would be nice if that fourth input variable,
>> currently "-", was something like "migrate" in this
instance.
>
> Yes, that is probably a bug worth fixing.
I would also find it useful for the QEMU "prepare" hook
to be told whether it's being called in the context of a migration.
(In our case, we use that hook to manage shared DRBD storage, and only permit
Primary/Primary mode in the context of a migration.)
The attached 1-line patch supplies the hook with an additional
argument "migration-target" when appropriate.
Submitted as
https://bugzilla.redhat.com/show_bug.cgi?id=768054
hookret = virHookCall(VIR_HOOK_DRIVER_QEMU,
vm->def->name,
- VIR_HOOK_QEMU_OP_PREPARE, VIR_HOOK_SUBOP_BEGIN, NULL, xml);
+ VIR_HOOK_QEMU_OP_PREPARE, VIR_HOOK_SUBOP_BEGIN, migrateFrom ?
"migration-target" : NULL, xml);
The idea is nice, but I don't think it's quite the right implementation.
migrateFrom is non-NULL not only for migration, but also for operations
like 'virsh restore file' when restoring from a file-based migration
stream even though we aren't changing hosts. Rather, we need to thread
something through the call chain so that we can tell whether this code
was reached from qemu_migrate.c during an actual migration case. In
fact, it might be nice to know when 'virsh restore' was in use,
separately from migration, separately from a fresh boot, so that we
provide more than just '-' or 'migration-target' as the fourth hook
argument.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org