From: Kevin Wolf Date: Wed, 9 Feb 2011 09:26:06 +0000 (+0100) Subject: qcow2: Fix error handling for reading compressed clusters X-Git-Tag: TizenStudio_2.0_p2.3~3371^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1cea148b1b134a1ef6f79bc11c420705ffeb91fb;p=sdk%2Femulator%2Fqemu.git qcow2: Fix error handling for reading compressed clusters When reading a compressed cluster failed, qcow2 falsely returned success. Signed-off-by: Kevin Wolf Reviewed-by: Markus Armbruster --- diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 5fb8c66..437aaa8 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -878,11 +878,11 @@ int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset) BLKDBG_EVENT(bs->file, BLKDBG_READ_COMPRESSED); ret = bdrv_read(bs->file, coffset >> 9, s->cluster_data, nb_csectors); if (ret < 0) { - return -1; + return ret; } if (decompress_buffer(s->cluster_cache, s->cluster_size, s->cluster_data + sector_offset, csize) < 0) { - return -1; + return -EIO; } s->cluster_cache_offset = coffset; } diff --git a/block/qcow2.c b/block/qcow2.c index 647c2a4..551b3c2 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -497,8 +497,10 @@ static void qcow2_aio_read_cb(void *opaque, int ret) } } else if (acb->cluster_offset & QCOW_OFLAG_COMPRESSED) { /* add AIO support for compressed blocks ? */ - if (qcow2_decompress_cluster(bs, acb->cluster_offset) < 0) + ret = qcow2_decompress_cluster(bs, acb->cluster_offset); + if (ret < 0) { goto done; + } qemu_iovec_from_buffer(&acb->hd_qiov, s->cluster_cache + index_in_cluster * 512,