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

Re: [libvirt] [PATCH 12/27] Add API for issuing the 'migrate_set_speed' monitor command



On Thu, 2009-09-24 at 16:00 +0100, Daniel P. Berrange wrote:
> * src/qemu/qemu_driver.c: Use new qemuMonitorSetMigrationSpeed()
>   API during migration
> * src/qemu/qemu_monitor.h, src/qemu/qemu_monitor.c: Add new
>   qemuMonitorSetMigrationSpeed() API
> ---
>  src/qemu/qemu_driver.c       |   11 +++--------
>  src/qemu/qemu_monitor_text.c |   28 ++++++++++++++++++++++++++++
>  src/qemu/qemu_monitor_text.h |    3 +++
>  3 files changed, 34 insertions(+), 8 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index f95c473..ccc13c4 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -6530,14 +6530,9 @@ qemudDomainMigratePerform (virDomainPtr dom,
>          event = NULL;
>      }
>  
> -    if (resource > 0) {
> -        /* Issue migrate_set_speed command.  Don't worry if it fails. */
> -        snprintf (cmd, sizeof cmd, "migrate_set_speed %lum", resource);
> -        qemudMonitorCommand (vm, cmd, &info);
> -
> -        DEBUG ("%s: migrate_set_speed reply: %s", vm->def->name, info);
> -        VIR_FREE (info);
> -    }
> +    if (resource > 0 &&
> +        qemuMonitorSetMigrationSpeed(vm, resource) < 0)
> +        goto cleanup;

Checking for errors is new, but makes sense

>  
>      /* Issue the migrate command. */
>      safe_uri = qemudEscapeMonitorArg (uri);
> diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
> index f35b1ef..d9227a2 100644
> --- a/src/qemu/qemu_monitor_text.c
> +++ b/src/qemu/qemu_monitor_text.c
> @@ -969,3 +969,31 @@ int qemuMonitorSavePhysicalMemory(const virDomainObjPtr vm,
>  {
>      return qemuMonitorSaveMemory(vm, "pmemsave", offset, length, path);
>  }
> +
> +
> +int qemuMonitorSetMigrationSpeed(const virDomainObjPtr vm,
> +                                 unsigned long bandwidth)
> +{
> +    char *cmd = NULL;
> +    char *info = NULL;
> +    int ret = -1;
> +
> +    if (virAsprintf(&cmd, "migrate_set_speed %lum", bandwidth) < 0) {
> +        virReportOOMError(NULL);
> +        goto cleanup;
> +    }
> +
> +    if (qemudMonitorCommand (vm, cmd, &info) < 0) {
                              ^
> +        qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
> +                         "%s", _("could restrict migration speed"));
> +        goto cleanup;
> +    }
> +
> +    DEBUG ("%s: migrate_set_speed reply: %s", vm->def->name, info);
            ^
> +    ret = 0;
> +
> +cleanup:
> +    VIR_FREE (info);
               ^
Whitespace, no big deal

ACK

Cheers,
Mark.


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