[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 2/2] migration: do floating-point division
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PULL 2/2] migration: do floating-point division |
Date: |
Thu, 3 Dec 2015 00:23:01 +0100 |
From: Paolo Bonzini <address@hidden>
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 <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
---
migration/migration.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/migration/migration.c b/migration/migration.c
index 1a42aee..adc6b6f 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -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) /
--
2.5.0