migration: do floating-point division
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 26 Jan 2015 11:12:27 +0000 (12:12 +0100)
committerJuan Quintela <quintela@redhat.com>
Wed, 2 Dec 2015 23:03:00 +0000 (00:03 +0100)
Dividing integer expressions transferred_bytes and time_spent, and then converting
the integer quotient to type double. Any remainder, or fractional part of the
quotient, is ignored.  Fix this.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
migration/migration.c

index 1a42aee..adc6b6f 100644 (file)
@@ -1674,7 +1674,7 @@ static void *migration_thread(void *opaque)
         if (current_time >= initial_time + BUFFER_DELAY) {
             uint64_t transferred_bytes = qemu_ftell(s->file) - initial_bytes;
             uint64_t time_spent = current_time - initial_time;
-            double bandwidth = transferred_bytes / time_spent;
+            double bandwidth = (double)transferred_bytes / time_spent;
             max_size = bandwidth * migrate_max_downtime() / 1000000;
 
             s->mbps = time_spent ? (((double) transferred_bytes * 8.0) /