In the previous patch we added a new QCow2ClusterType named QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER. There is a couple of places where this new value needs to be handled, and that is what this patch does.
Signed-off-by: Alberto Garcia <be...@igalia.com> --- block/qcow2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 131711d6fa..c222cd261d 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1922,8 +1922,8 @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs, *pnum = bytes; - if ((ret == QCOW2_CLUSTER_NORMAL || ret == QCOW2_CLUSTER_ZERO_ALLOC) && - !s->crypto) { + if ((ret == QCOW2_CLUSTER_NORMAL || ret == QCOW2_CLUSTER_ZERO_ALLOC || + ret == QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER) && !s->crypto) { index_in_cluster = offset & (s->cluster_size - 1); *map = cluster_offset | index_in_cluster; *file = s->data_file->bs; @@ -1931,7 +1931,8 @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs, } if (ret == QCOW2_CLUSTER_ZERO_PLAIN || ret == QCOW2_CLUSTER_ZERO_ALLOC) { status |= BDRV_BLOCK_ZERO; - } else if (ret != QCOW2_CLUSTER_UNALLOCATED) { + } else if (ret != QCOW2_CLUSTER_UNALLOCATED && + ret != QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER) { status |= BDRV_BLOCK_DATA; } if (s->metadata_preallocation && (status & BDRV_BLOCK_DATA) && @@ -2009,6 +2010,7 @@ static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs, switch (ret) { case QCOW2_CLUSTER_UNALLOCATED: + case QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER: if (bs->backing) { BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); @@ -3542,6 +3544,7 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, nr = s->cluster_size; ret = qcow2_get_cluster_offset(bs, offset, &nr, &off); if (ret != QCOW2_CLUSTER_UNALLOCATED && + ret != QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER && ret != QCOW2_CLUSTER_ZERO_PLAIN && ret != QCOW2_CLUSTER_ZERO_ALLOC) { qemu_co_mutex_unlock(&s->lock); @@ -3612,6 +3615,7 @@ qcow2_co_copy_range_from(BlockDriverState *bs, switch (ret) { case QCOW2_CLUSTER_UNALLOCATED: + case QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER: if (bs->backing && bs->backing->bs) { int64_t backing_length = bdrv_getlength(bs->backing->bs); if (src_offset >= backing_length) { -- 2.20.1