migration: fix implicit integer division in migration_update_counters
switchover_bw is a uint64_t, so switchover_bw / 1000 results in an integer division. This value is then assigned to expected_bw_per_ms which is of type double. This results in losing precision and is type unsafe. Adding explicit cast ensures floating-point division. Signed-off-by: Aadeshveer Singh <aadeshveer07@gmail.com> Reviewed-by: Peter Xu <peterx@redhat.com> Link: https://lore.kernel.org/qemu-devel/20260316134509.157964-1-aadeshveer07@gmail.com Signed-off-by: Fabiano Rosas <farosas@suse.de>
Aadeshveer Singh committed
Mar 16, 2026 at 19:15 UTC
b6a6d91b9e5ebe32c31ca1510a87077a586d9923
1 file changed
+1
-1
migration/migration.c
+1
-1
@@ -3141,7 +3141,7 @@ static void migration_update_counters(MigrationState *s,
3141
* If the user specified a switchover bandwidth, let's trust the
3142
* user so that can be more accurate than what we estimated.
3143
*/
3144
- expected_bw_per_ms = switchover_bw / 1000;
3144
+ expected_bw_per_ms = (double)switchover_bw / 1000;
3145
} else {
3146
/* If the user doesn't specify bandwidth, we use the estimated */
3147
expected_bw_per_ms = bandwidth;