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

Re: [libvirt] [PATCH 7/8] Set qemu migration speed unlimited when migrating to file



On Fri, Aug 26, 2011 at 12:10:26PM -0600, Jim Fehlig wrote:
> The qemu migration speed default is 32MiB/s as defined in migration.c
> 
> /* Migration speed throttling */
> static int64_t max_throttle = (32 << 20);
> 
> The only reason to throttle migration when targeting a file is user
> request.  If user has not changed the qemu default, set migration speed
> to unlimited prior to migration, and restore to qemu default value after
> migration.
> 
> Default units is MB for migrate_set_speed monitor command, so
> (INT64_MAX / (1024 * 1024)) is used for unlimited migration speed.
> 
> Tested with both json and text monitors.
> ---
>  src/qemu/qemu_migration.c |   22 ++++++++++++++++++++++
>  src/qemu/qemu_migration.h |    3 +++
>  2 files changed, 25 insertions(+), 0 deletions(-)
> 
> diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
> index a2dc97c..910cd8d 100644
> --- a/src/qemu/qemu_migration.c
> +++ b/src/qemu/qemu_migration.c
> @@ -2699,6 +2699,18 @@ qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
>      bool restoreLabel = false;
>      virCommandPtr cmd = NULL;
>      int pipeFD[2] = { -1, -1 };
> +    unsigned long initMigBandwidth = vm->def->migration_max_bandwidth;
> +
> +    /* If no user-defined migration speed is set, increase qemu default
> +     * (32MiB/s) to unlimited since target is a file.
> +     * Failure to change migration speed is not fatal. */
> +    if (initMigBandwidth == 0) {
> +        if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
> +            qemuMonitorSetMigrationSpeed(priv->mon, QEMU_FILE_MIGRATION_SPEED_MAX);
> +            vm->def->migration_max_bandwidth =  QEMU_FILE_MIGRATION_SPEED_MAX;
> +            qemuDomainObjExitMonitorWithDriver(driver, vm);
> +        }
> +    }
>  
>      if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
>          (!compressor || pipe(pipeFD) == 0)) {
> @@ -2807,6 +2819,16 @@ qemuMigrationToFile(struct qemud_driver *driver, virDomainObjPtr vm,
>      ret = 0;
>  
>  cleanup:
> +    /* If migration speed was changed from default, restore it. */
> +    if (initMigBandwidth == 0) {
> +        if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
> +            qemuMonitorSetMigrationSpeed(priv->mon,
> +                                         QEMU_DEFAULT_MIGRATION_SPEED_MAX);
> +            vm->def->migration_max_bandwidth = 0;
> +            qemuDomainObjExitMonitorWithDriver(driver, vm);
> +        }
> +    }

IMHO, we should just unconditionally set & reset the migration bandwidth
in QEMU here, and when doing a real migration, also unconditionally
set the bandwidth there, so we remove QEMU's internal default setting
from the equation & get predictable behaviour with all QEMUs.


> +
>      VIR_FORCE_CLOSE(pipeFD[0]);
>      VIR_FORCE_CLOSE(pipeFD[1]);
>      virCommandFree(cmd);
> diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
> index 5c6921d..e49505e 100644
> --- a/src/qemu/qemu_migration.h
> +++ b/src/qemu/qemu_migration.h
> @@ -53,6 +53,9 @@ enum qemuMigrationJobPhase {
>  };
>  VIR_ENUM_DECL(qemuMigrationJobPhase)
>  
> +# define QEMU_DEFAULT_MIGRATION_SPEED_MAX (32 << 20)
> +# define QEMU_FILE_MIGRATION_SPEED_MAX    (INT64_MAX / (1024 * 1024))
> +
>  int qemuMigrationJobStart(struct qemud_driver *driver,
>                            virDomainObjPtr vm,
>                            enum qemuDomainAsyncJob job)
> -- 

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


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