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

Re: [libvirt] [PATCH] Various monitor improvements for migration.



On Wed, Sep 30, 2009 at 03:38:45PM +0200, Chris Lalancette wrote:
> The upcoming tunnelled migration needs to be able to set
> a migration in progress in the background, as well as
> be able to cancel a migration when a problem has happened.
> This patch allows for both of these to properly work.
> 
> Signed-off-by: Chris Lalancette <clalance redhat com>
> ---
>  src/qemu/qemu_driver.c       |    8 ++++----
>  src/qemu/qemu_monitor_text.c |   40 +++++++++++++++++++++++++++++++++++++---
>  src/qemu/qemu_monitor_text.h |    8 ++++++++
>  3 files changed, 49 insertions(+), 7 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 155e4a3..70e9c70 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -3221,7 +3221,7 @@ static int qemudDomainSave(virDomainPtr dom,
>  
>      if (header.compressed == QEMUD_SAVE_FORMAT_RAW) {
>          const char *args[] = { "cat", NULL };
> -        ret = qemuMonitorMigrateToCommand(vm, args, path);
> +        ret = qemuMonitorMigrateToCommand(vm, 0, args, path);
>      } else {
>          const char *prog = qemudSaveCompressionTypeToString(header.compressed);
>          const char *args[] = {
> @@ -3229,7 +3229,7 @@ static int qemudDomainSave(virDomainPtr dom,
>              "-c",
>              NULL
>          };
> -        ret = qemuMonitorMigrateToCommand(vm, args, path);
> +        ret = qemuMonitorMigrateToCommand(vm, 0, args, path);
>      }
>  
>      if (ret < 0)
> @@ -3303,7 +3303,7 @@ static int qemudDomainCoreDump(virDomainPtr dom,
>          paused = 1;
>      }
>  
> -    ret = qemuMonitorMigrateToCommand(vm, args, path);
> +    ret = qemuMonitorMigrateToCommand(vm, 0, args, path);
>      paused = 1;
>  cleanup:
>  
> @@ -6041,7 +6041,7 @@ qemudDomainMigratePerform (virDomainPtr dom,
>          goto cleanup;
>      }
>  
> -    if (qemuMonitorMigrateToHost(vm, uribits->server, uribits->port) < 0)
> +    if (qemuMonitorMigrateToHost(vm, 0, uribits->server, uribits->port) < 0)
>          goto cleanup;
>  
>      /* it is also possible that the migrate didn't fail initially, but
> diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
> index f57460c..67dd075 100644
> --- a/src/qemu/qemu_monitor_text.c
> +++ b/src/qemu/qemu_monitor_text.c
> @@ -1138,19 +1138,26 @@ cleanup:
>  
>  
>  static int qemuMonitorMigrate(const virDomainObjPtr vm,
> +                              int background,
>                                const char *dest)
>  {
>      char *cmd = NULL;
>      char *info = NULL;
>      int ret = -1;
>      char *safedest = qemuMonitorEscapeArg(dest);
> +    const char *extra;
>  
>      if (!safedest) {
>          virReportOOMError(NULL);
>          return -1;
>      }
>  
> -    if (virAsprintf(&cmd, "migrate \"%s\"", safedest) < 0) {
> +    if (background)
> +        extra = "-d ";
> +    else
> +        extra = " ";
> +
> +    if (virAsprintf(&cmd, "migrate %s\"%s\"", extra, safedest) < 0) {
>          virReportOOMError(NULL);
>          goto cleanup;
>      }
> @@ -1186,6 +1193,7 @@ cleanup:
>  }
>  
>  int qemuMonitorMigrateToHost(const virDomainObjPtr vm,
> +                             int background,
>                               const char *hostname,
>                               int port)
>  {
> @@ -1200,7 +1208,7 @@ int qemuMonitorMigrateToHost(const virDomainObjPtr vm,
>          return -1;
>      }
>  
> -    ret = qemuMonitorMigrate(vm, uri);
> +    ret = qemuMonitorMigrate(vm, background, uri);
>  
>      VIR_FREE(uri);
>  
> @@ -1209,6 +1217,7 @@ int qemuMonitorMigrateToHost(const virDomainObjPtr vm,
>  
>  
>  int qemuMonitorMigrateToCommand(const virDomainObjPtr vm,
> +                                int background,
>                                  const char * const *argv,
>                                  const char *target)
>  {
> @@ -1238,7 +1247,7 @@ int qemuMonitorMigrateToCommand(const virDomainObjPtr vm,
>          goto cleanup;
>      }
>  
> -    ret = qemuMonitorMigrate(vm, dest);
> +    ret = qemuMonitorMigrate(vm, background, dest);
>  
>  cleanup:
>      VIR_FREE(safe_target);
> @@ -1247,6 +1256,31 @@ cleanup:
>      return ret;
>  }
>  
> +int qemuMonitorMigrateToUnix(const virDomainObjPtr vm,
> +                             int background,
> +                             const char *unixfile)
> +{
> +    char *dest = NULL;
> +    int ret = -1;
> +
> +    if (virAsprintf(&dest, "unix:%s", unixfile) < 0) {
> +        virReportOOMError(NULL);
> +        return -1;
> +    }
> +
> +    ret = qemuMonitorMigrate(vm, background, dest);
> +
> +    VIR_FREE(dest);
> +
> +    return ret;
> +}
> +
> +void qemuMonitorMigrateCancel(const virDomainObjPtr vm)
> +{
> +    char *info = NULL;
> +    qemuMonitorCommand(vm, "migrate cancel", &info);
> +    VIR_FREE(info);
> +}

An error status return value for this last one.... Aside from
that it looks good


Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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