aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2019-01-18 13:44:40 +0100
committerKevin Wolf <kwolf@redhat.com>2019-03-08 12:26:45 +0100
commitb8c8353a38296fbb92e05a2843e853c1ddfc2674 (patch)
tree1ba0ae0d16202623fdb8222964d6873efb95602c
parenta4ea184d8af936cdc4bea4afdb5c30ffaed0c4f7 (diff)
downloadqemu-b8c8353a38296fbb92e05a2843e853c1ddfc2674.zip
qemu-b8c8353a38296fbb92e05a2843e853c1ddfc2674.tar.gz
qemu-b8c8353a38296fbb92e05a2843e853c1ddfc2674.tar.bz2
qcow2: Prepare count_contiguous_clusters() for external data file
Offset 0 can be valid for normal (allocated) clusters now, so use qcow2_get_cluster_type() instead. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--block/qcow2-cluster.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 9cc8f0f..660161b 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -389,12 +389,12 @@ static int count_contiguous_clusters(BlockDriverState *bs, int nb_clusters,
uint64_t first_entry = be64_to_cpu(l2_slice[0]);
uint64_t offset = first_entry & mask;
- if (!offset) {
+ first_cluster_type = qcow2_get_cluster_type(bs, first_entry);
+ if (first_cluster_type == QCOW2_CLUSTER_UNALLOCATED) {
return 0;
}
/* must be allocated */
- first_cluster_type = qcow2_get_cluster_type(bs, first_entry);
assert(first_cluster_type == QCOW2_CLUSTER_NORMAL ||
first_cluster_type == QCOW2_CLUSTER_ZERO_ALLOC);