Skip to content

Commit

Permalink
migration: fix xbzrle encoding rate calculation
Browse files Browse the repository at this point in the history
It's reported an error of implicit conversion from "unsigned long" to
"double" when compiling with Clang 10. Simply make the encoding rate 0
when the encoded_size is 0.

Fixes: e460a4b
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reported-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20200617201309.1640952-3-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
wei-w-wang authored and pm215 committed Jun 18, 2020
1 parent 4066288 commit 9227140
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions migration/ram.c
Expand Up @@ -913,10 +913,8 @@ static void migration_update_rates(RAMState *rs, int64_t end_time)
unencoded_size = (xbzrle_counters.pages - rs->xbzrle_pages_prev) *
TARGET_PAGE_SIZE;
encoded_size = xbzrle_counters.bytes - rs->xbzrle_bytes_prev;
if (xbzrle_counters.pages == rs->xbzrle_pages_prev) {
if (xbzrle_counters.pages == rs->xbzrle_pages_prev || !encoded_size) {
xbzrle_counters.encoding_rate = 0;
} else if (!encoded_size) {
xbzrle_counters.encoding_rate = UINT64_MAX;
} else {
xbzrle_counters.encoding_rate = unencoded_size / encoded_size;
}
Expand Down

0 comments on commit 9227140

Please sign in to comment.