[libvirt] [PATCH V2 6/8] Save migration speed in qemuDomainMigrateSetMaxSpeed

Daniel Veillard veillard at redhat.com
Fri Sep 16 10:16:32 UTC 2011


On Thu, Sep 01, 2011 at 02:42:55PM -0600, Jim Fehlig wrote:
> From: Jim Fehlig <jfehlig at novell.com>
> 
> Now that migration speed is stored in qemuDomainObjPrivate structure,
> save the new value when invoking qemuDomainMigrateSetMaxSpeed().
> 
> Allow setting migration speed on inactive domain too.
> ---
>  src/qemu/qemu_driver.c |   36 +++++++++++++++---------------------
>  1 files changed, 15 insertions(+), 21 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index c5fa106..59b9a91 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -8234,31 +8234,25 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom,
>          return -1;
>      }
>  
> -    if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0)
> -        goto cleanup;
> -
> -    if (!virDomainObjIsActive(vm)) {
> -        qemuReportError(VIR_ERR_OPERATION_INVALID,
> -                        "%s", _("domain is not running"));
> -        goto endjob;
> -    }
> -
>      priv = vm->privateData;
> +    if (virDomainObjIsActive(vm)) {
> +        if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0)
> +            goto cleanup;
>  
> -    if (priv->job.asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT) {
> -        qemuReportError(VIR_ERR_OPERATION_INVALID,
> -                        "%s", _("domain is not being migrated"));
> -        goto endjob;
> -    }
> +        VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth);
> +        qemuDomainObjEnterMonitor(driver, vm);
> +        ret = qemuMonitorSetMigrationSpeed(priv->mon, bandwidth);
> +        qemuDomainObjExitMonitor(driver, vm);
>  
> -    VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth);
> -    qemuDomainObjEnterMonitor(driver, vm);
> -    ret = qemuMonitorSetMigrationSpeed(priv->mon, bandwidth);
> -    qemuDomainObjExitMonitor(driver, vm);
> +        if (ret == 0)
> +            priv->migMaxBandwidth = bandwidth;
>  
> -endjob:
> -    if (qemuDomainObjEndJob(driver, vm) == 0)
> -        vm = NULL;
> +        if (qemuDomainObjEndJob(driver, vm) == 0)
> +            vm = NULL;
> +    } else {
> +        priv->migMaxBandwidth = bandwidth;
> +        ret = 0;
> +    }
>  
>  cleanup:
>      if (vm)

  ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list