From: Alberto Garcia Date: Fri, 10 Jul 2020 16:12:58 +0000 (+0200) Subject: qcow2: Add qcow2_cluster_is_allocated() X-Git-Tag: qemu-xen-4.16.0-rc4~677^2~18 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c94d037825ccecf4819ca63f8838561eba49bc80;p=qemu-xen.git qcow2: Add qcow2_cluster_is_allocated() This helper function tells us if a cluster is allocated (that is, there is an associated host offset for it). Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Message-Id: <6d8771c5c79cbdc6c519875a5078e1cc85856d63.1594396418.git.berto@igalia.com> Signed-off-by: Max Reitz --- diff --git a/block/qcow2.h b/block/qcow2.h index 3aec6f452a..ea647c8bb5 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -780,6 +780,12 @@ QCow2SubclusterType qcow2_get_subcluster_type(BlockDriverState *bs, } } +static inline bool qcow2_cluster_is_allocated(QCow2ClusterType type) +{ + return (type == QCOW2_CLUSTER_COMPRESSED || type == QCOW2_CLUSTER_NORMAL || + type == QCOW2_CLUSTER_ZERO_ALLOC); +} + /* Check whether refcounts are eager or lazy */ static inline bool qcow2_need_accurate_refcounts(BDRVQcow2State *s) {