qcow: Fix refcount_bytes

This should be the number of bits (1 << order) divided by bits per byte.

BUG=none
TEST=cargo test

Change-Id: I201dbaf21d13a82af6bcb493ba5f3b62c89286fa
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/954348
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
Dylan Reid 2018-03-07 16:35:46 -08:00 committed by chrome-bot
parent d1ab493672
commit 818afd6eb0

View file

@ -143,7 +143,7 @@ impl QcowHeader {
// Pre-allocate enough clusters for the entire refcount table as it must be // Pre-allocate enough clusters for the entire refcount table as it must be
// continuous in the file. Allocate enough space to refcount all clusters, including // continuous in the file. Allocate enough space to refcount all clusters, including
// the refcount clusters. // the refcount clusters.
let refcount_bytes = 0x01u32 << DEFAULT_REFCOUNT_ORDER / 8; let refcount_bytes = (0x01u32 << DEFAULT_REFCOUNT_ORDER) / 8;
let for_data = div_round_up_u32(num_clusters * refcount_bytes, cluster_size); let for_data = div_round_up_u32(num_clusters * refcount_bytes, cluster_size);
let for_refcounts = div_round_up_u32(for_data * refcount_bytes, cluster_size); let for_refcounts = div_round_up_u32(for_data * refcount_bytes, cluster_size);
let max_refcount_clusters = for_data + for_refcounts; let max_refcount_clusters = for_data + for_refcounts;