From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WD41c-0005IH-Jc for qemu-devel@nongnu.org; Mon, 10 Feb 2014 22:28:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WD41W-0001vb-G0 for qemu-devel@nongnu.org; Mon, 10 Feb 2014 22:28:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:61999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WD41W-0001vP-81 for qemu-devel@nongnu.org; Mon, 10 Feb 2014 22:28:38 -0500 From: Fam Zheng Date: Tue, 11 Feb 2014 11:28:35 +0800 Message-Id: <1392089319-25307-2-git-send-email-famz@redhat.com> In-Reply-To: <1392089319-25307-1-git-send-email-famz@redhat.com> References: <1392089319-25307-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v2 1/5] qemu-img: Convert by cluster size if target is compressed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, jcody@redhat.com, gentoo.integer@gmail.com, stefanha@redhat.com If target block driver forces compression (bdi.is_compressed == true), qemu-img convert needs to write by cluster size as well as "-c" option. Particularly, this applies for converting to VMDK streamOptimized format. Signed-off-by: Fam Zheng --- include/block/block.h | 1 + qemu-img.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/block/block.h b/include/block/block.h index 963a61f..826b5da 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -34,6 +34,7 @@ typedef struct BlockDriverInfo { * opened with BDRV_O_UNMAP flag for this to work. */ bool can_write_zeroes_with_unmap; + bool is_compressed; } BlockDriverInfo; typedef struct BlockFragInfo { diff --git a/qemu-img.c b/qemu-img.c index c989850..859b927 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1425,11 +1425,14 @@ static int img_convert(int argc, char **argv) cluster_sectors = 0; ret = bdrv_get_info(out_bs, &bdi); if (ret < 0) { + /* We don't care whether bdrv_get_info() fails or not unless we are to + * compress */ if (compress) { error_report("could not get block driver info"); goto out; } } else { + compress = compress || bdi.is_compressed; cluster_sectors = bdi.cluster_size / BDRV_SECTOR_SIZE; } -- 1.8.5.4