qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v5 04/12] rdma: introduce qemu_get_max_size()


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v5 04/12] rdma: introduce qemu_get_max_size()
Date: Mon, 22 Apr 2013 14:20:25 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130402 Thunderbird/17.0.5

On 04/21/2013 03:17 PM, address@hidden wrote:
> From: "Michael R. Hines" <address@hidden>
> 
> This functions allows you to perform your own per-QEMUFileOps
> calculation for the value of 'max_size'.
> 
> For RDMA, this calculation artificially limits migration throughput
> and needs to be done differently for high-throughput links.
> 
> Signed-off-by: Michael R. Hines <address@hidden>
> ---

>  
> +size_t qemu_get_max_size(QEMUFile *f, uint64_t transferred_bytes,
> +                         uint64_t time_spent, uint64_t max_downtime)
> +{
> +    if (time_spent) {
> +        mbps = (((double) transferred_bytes * 8.0) / 
> +            ((double) time_spent / 1000.0)) / 1000.0 / 1000.0;
> +    } else {
> +        mbps = -1.0;
> +    }
> +
> +    if (f->ops->get_max_size) {
> +        return f->ops->get_max_size(f, f->opaque, 
> +            transferred_bytes, time_spent, max_downtime);
> +    }
> +
> +    return ((double) (transferred_bytes / time_spent)) * 
> +                    max_downtime / 1000000;

Cast to double is too late; you've already suffered from integer
division truncation when you compute (transferred_bytes/time_spent).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]