]> Git Repo - qemu.git/commitdiff
qcow2: Prepare count_contiguous_clusters() for external data file
authorKevin Wolf <[email protected]>
Fri, 18 Jan 2019 12:44:40 +0000 (13:44 +0100)
committerKevin Wolf <[email protected]>
Fri, 8 Mar 2019 11:26:45 +0000 (12:26 +0100)
Offset 0 can be valid for normal (allocated) clusters now, so use
qcow2_get_cluster_type() instead.

Signed-off-by: Kevin Wolf <[email protected]>
block/qcow2-cluster.c

index 9cc8f0f3e4032bd0db29fc0e0ae5e993be7e3659..660161bf00aec563413ccd7a340c911997af9806 100644 (file)
@@ -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);
 
This page took 0.028073 seconds and 4 git commands to generate.