aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2-cluster.c
diff options
context:
space:
mode:
authorAlberto Garcia <berto@igalia.com>2020-07-10 18:12:59 +0200
committerMax Reitz <mreitz@redhat.com>2020-08-25 08:33:20 +0200
commitca4a0bb81b5259e326a30b758959911459d2a266 (patch)
treee45292f92fe559ee5e496887289bf06bafd755f3 /block/qcow2-cluster.c
parentc94d037825ccecf4819ca63f8838561eba49bc80 (diff)
qcow2: Add cluster type parameter to qcow2_get_host_offset()
This function returns an integer that can be either an error code or a cluster type (a value from the QCow2ClusterType enum). We are going to start using subcluster types instead of cluster types in some functions so it's better to use the exact data types instead of integers for clarity and in order to detect errors more easily. This patch makes qcow2_get_host_offset() return 0 on success and puts the returned cluster type in a separate parameter. There are no semantic changes. Signed-off-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <396b6eab1859a271551dcd7dcba77f8934aa3c3f.1594396418.git.berto@igalia.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/qcow2-cluster.c')
-rw-r--r--block/qcow2-cluster.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 2fe7a0f79c..ec0fe0e13b 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -565,13 +565,14 @@ static int coroutine_fn do_perform_cow_write(BlockDriverState *bs,
*
* On exit, *bytes is the number of bytes starting at offset that have the same
* cluster type and (if applicable) are stored contiguously in the image file.
+ * The cluster type is stored in *cluster_type.
* Compressed clusters are always returned one by one.
*
- * Returns the cluster type (QCOW2_CLUSTER_*) on success, -errno in error
- * cases.
+ * Returns 0 on success, -errno in error cases.
*/
int qcow2_get_host_offset(BlockDriverState *bs, uint64_t offset,
- unsigned int *bytes, uint64_t *host_offset)
+ unsigned int *bytes, uint64_t *host_offset,
+ QCow2ClusterType *cluster_type)
{
BDRVQcow2State *s = bs->opaque;
unsigned int l2_index;
@@ -713,7 +714,9 @@ out:
assert(bytes_available - offset_in_cluster <= UINT_MAX);
*bytes = bytes_available - offset_in_cluster;
- return type;
+ *cluster_type = type;
+
+ return 0;
fail:
qcow2_cache_put(s->l2_table_cache, (void **)&l2_slice);