diff mbox

[v3,1/4] qemu-img: Convert by cluster size if target is compressed

Message ID 1398412852-2562-2-git-send-email-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng April 25, 2014, 8 a.m. UTC
If target block driver forces compression, 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 <famz@redhat.com>
---
 include/block/block.h | 4 ++++
 qemu-img.c            | 1 +
 2 files changed, 5 insertions(+)

Comments

Stefan Hajnoczi May 6, 2014, 12:50 p.m. UTC | #1
On Fri, Apr 25, 2014 at 04:00:49PM +0800, Fam Zheng wrote:
> diff --git a/include/block/block.h b/include/block/block.h
> index b3230a2..8a1cb83 100644
> --- a/include/block/block.h
> +++ b/include/block/block.h
> @@ -34,6 +34,10 @@ typedef struct BlockDriverInfo {
>       * opened with BDRV_O_UNMAP flag for this to work.
>       */
>      bool can_write_zeroes_with_unmap;
> +    /*
> +     * True if the driver is writing data clusters compressed
> +     */
> +    bool is_compressed;

"is_compressed" is more general than what this flag actually
communicates:

/*
 * True if this block driver only supports compressed writes
 */
bool needs_compressed_writes;
diff mbox

Patch

diff --git a/include/block/block.h b/include/block/block.h
index b3230a2..8a1cb83 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -34,6 +34,10 @@  typedef struct BlockDriverInfo {
      * opened with BDRV_O_UNMAP flag for this to work.
      */
     bool can_write_zeroes_with_unmap;
+    /*
+     * True if the driver is writing data clusters compressed
+     */
+    bool is_compressed;
 } BlockDriverInfo;
 
 typedef struct BlockFragInfo {
diff --git a/qemu-img.c b/qemu-img.c
index 8455994..ace4c21 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1458,6 +1458,7 @@  static int img_convert(int argc, char **argv)
             goto out;
         }
     } else {
+        compress = compress || bdi.is_compressed;
         cluster_sectors = bdi.cluster_size / BDRV_SECTOR_SIZE;
     }