[libvirt] [PATCH] correct the arguments of migrate_speed

Eric Blake eblake at redhat.com
Mon Nov 29 22:26:46 UTC 2010


On 11/25/2010 01:38 AM, Wen Congyang wrote:
> When we set migrate_speed by json, we receive the following
> error message:
> libvirtError: internal error unable to execute QEMU command
> 'migrate_set_speed': Invalid parameter type, expected: number
> 
> The reason is that: the arguments of migrate_set_speed
> by json is json number, not json string.
> 
> Signed-off-by: Wen Congyang <wency at cn.fujitsu.com>
> 
> ---
>  src/qemu/qemu_monitor_json.c |   10 +++-------
>  1 files changed, 3 insertions(+), 7 deletions(-)

Thanks for submitting this.

> 
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index da51a4f..2576dc5 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -1453,17 +1453,13 @@ int qemuMonitorJSONSetMigrationSpeed(qemuMonitorPtr mon,
>                                       unsigned long bandwidth)
>  {
>      int ret;
> -    char *bandwidthstr;
>      virJSONValuePtr cmd;
>      virJSONValuePtr reply = NULL;
> -    if (virAsprintf(&bandwidthstr, "%lum", bandwidth) < 0) {
> -        virReportOOMError();
> -        return -1;
> -    }
>      cmd = qemuMonitorJSONMakeCommand("migrate_set_speed",
> -                                     "s:value", bandwidthstr,
> +                                     "U:value",
> +                                     /* 1048576 = 1024 * 1024 */
> +                                     (uint64_t)bandwidth * 1048576,

U implies unsigned long long (which might not necessarily be the same
width as uint64_t, although I don't know of any counter-example systems
that violate that assumption at the moment).  Also, rather than a
comment explaining a magic number followed by use of that magic number,
I found it simpler to just use inline expansion of the constant (and
avoiding a cast is always a plus in my books):

bandwidth * 1024ULL * 1024ULL

ACK with that modification, plus a tweak to AUTHORS to keep 'make
syntax-check' happy.  I've pushed the resulting patch now.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101129/4743d89c/attachment-0001.sig>


More information about the libvir-list mailing list