Re: [PATCH v2] migration: convert speed from Mb/sec to bytes/sec in drive-mirror jobs

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

 



On Fri, Apr 01, 2016 at 10:16:53AM +0800, Rudy Zhang wrote:
> Commit id '7b7600b3' added qemuMigrationDriveMirror to handle NBD
> mirroring, but passed the migrate_speed listed in MiB/s to be used for
> the mirror_speed which expects a bytes/s value.
> 

Misleading, qemuMonitorDriveMirror expected MiB/s at the time.
I changed the commit message to:

    Commit 08cc14f moved the conversion of MiB/s to B/s out of the
    qemuMonitor APIs, but forgot to adjust the qemuMigrationDriveMirror
    caller.

> This patch will convert the migrate_speed value to its mirror_speed
> equivalent.
> 
> Signed-off-by: Rudy Zhang <rudyflyzhang@xxxxxxxxx>
> ---
>  src/qemu/qemu_migration.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
> index 8bc76bf..3d9a55f 100644
> --- a/src/qemu/qemu_migration.c
> +++ b/src/qemu/qemu_migration.c
> @@ -2093,12 +2093,21 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
>      char *diskAlias = NULL;
>      char *nbd_dest = NULL;
>      char *hoststr = NULL;
> +    unsigned long long mirror_speed = speed;
>      unsigned int mirror_flags = VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT;
>      int rv;
>      virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
>  
>      VIR_DEBUG("Starting drive mirrors for domain %s", vm->def->name);
>  
> +    if (mirror_speed > LLONG_MAX >> 20) {
> +        virReportError(VIR_ERR_OVERFLOW,
> +                       _("bandwidth must be less than %llu"),
> +                       LLONG_MAX >> 20);
> +        return ret;

    goto cleanup;

Otherwise we leak a reference to cfg.

> +    }
> +    mirror_speed <<= 20;
> +
>      /* steal NBD port and thus prevent its propagation back to destination */
>      port = mig->nbd->port;
>      mig->nbd->port = 0;
> @@ -2136,7 +2145,7 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver,
>          qemuBlockJobSyncBegin(disk);
>          /* Force "raw" format for NBD export */
>          mon_ret = qemuMonitorDriveMirror(priv->mon, diskAlias, nbd_dest,
> -                                         "raw", speed, 0, 0, mirror_flags);
> +                                         "raw", mirror_speed, 0, 0, mirror_flags);
>          VIR_FREE(diskAlias);
>          VIR_FREE(nbd_dest);
>  

ACK and pushed

Congratulations on your first libvirt patch!

Jan

--
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]