Re: [PATCH 2/2] qemu: Add pre-migration hook

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/28/2012 02:49 PM, Jiri Denemark wrote:
> This hook is called during the Prepare phase on destination host and may
> be used for changing domain XML.
> ---
>  docs/hooks.html.in        |   35 +++++++++++++++++++++++------------
>  src/qemu/qemu_migration.c |   40 ++++++++++++++++++++++++++++++++++++++++
>  src/util/hooks.c          |    3 ++-
>  src/util/hooks.h          |    1 +
>  4 files changed, 66 insertions(+), 13 deletions(-)
> 
> diff --git a/docs/hooks.html.in b/docs/hooks.html.in
> index 890359e..6c82c6d 100644
> --- a/docs/hooks.html.in
> +++ b/docs/hooks.html.in
> @@ -120,6 +120,16 @@
>          called again, <span class="since">since 0.9.0</span>, to allow
>          any additional resource cleanup:<br/>
>          <pre>/etc/libvirt/hooks/qemu guest_name release end -</pre></li>
> +      <li><span class="since">Since 0.9.11</span>, the qemu hook script
> +        is also called at the beginning of incoming migration. It is called
> +        as: <pre>/etc/libvirt/hooks/qemu guest_name migrate begin -</pre>
> +        with domain XML sent to standard input of the script. In this case,
> +        the script acts as a filter and is supposed to modify the domain
> +        XML and print it out on its standard output. Empty output is
> +        identical to copying the input XML without changing it. In case the
> +        script returns failure or the output XML is not valid, incoming
> +        migration will be canceled. This hook may be used to, e.g., change

I think this reads better as:

s/used to, e.g., change/used, e.g., to change/

> +        location of disk images for incoming domains.</li>
>      </ul>
>  
>      <h5><a name="lxc">/etc/libvirt/hooks/lxc</a></h5>
> @@ -161,19 +171,20 @@
>         source and destination hosts:</p>
>      <ol>
>        <li>At the beginning of the migration, the <i>qemu</i> hook script on
> -          the <b>destination</b> host is executed with the "start"
> -          operation.<br/><br/></li>
> -      <li>If this hook script returns indicating success (error code 0), the
> -          migration continues.  Any other return code indicates failure, and
> -          the migration is aborted.<br/><br/></li>
> -      <li>The QEMU guest is then migrated to the destination host.<br/>
> -          <br/></li>
> +          the <b>destination</b> host is executed with the "migrate"
> +          operation.</li>
> +      <li>Before QEMU process is spawned, the two operations ("prepare" and
> +          "start") called for domain start are executed on
> +          <b>destination</b> host.</li>
> +      <li>If any of these hook script executions returns indicating success
> +          (error code 0), the migration continues.  Any other return code
> +          indicates failure, and the migration is aborted.</li>

This reads awkwardly - it makes it sound like 'prepare' exiting with 0
makes the overall operation succeed even if 'start' exits with non-zero.
 I'd change it to:

If both of these hook script executions exit successfully (exit status
0), the migration continues.  Any other exit code indicates failure, and
the migration is aborted.

> @@ -1150,6 +1152,43 @@ qemuMigrationPrepareAny(struct qemud_driver *driver,
>              goto cleanup;
>      }
>  
> +    /* Let migration hook filter domain XML */
> +    if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
> +        char *xml = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE);
> +        int hookret;
> +
> +        hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, def->name,
> +                              VIR_HOOK_QEMU_OP_MIGRATE, VIR_HOOK_SUBOP_BEGIN,
> +                              NULL, xml, &xmlout);

Needs to check for xml being NULL on OOM before virHookCall.

ACK with those issues fixed.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]