On 04/22/2013 04:20 PM, Eric Blake wrote:
On 04/21/2013 03:17 PM, mrhi...@linux.vnet.ibm.com wrote:
From: "Michael R. Hines" <mrhi...@us.ibm.com>

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 <mrhi...@us.ibm.com>
---
+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).


Good catch, thank you.



Reply via email to