]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
qemu-img: Convert by cluster size if target is compressed
authorFam Zheng <famz@redhat.com>
Tue, 6 May 2014 13:08:43 +0000 (21:08 +0800)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 9 May 2014 11:32:16 +0000 (13:32 +0200)
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>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
include/block/block.h
qemu-img.c

index 467fb2ba0a1336b353b71c38b928311ade0c7009..27d8598eecbd550afdf59d6b3e887ff6f966b349 100644 (file)
@@ -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 this block driver only supports compressed writes
+     */
+    bool needs_compressed_writes;
 } BlockDriverInfo;
 
 typedef struct BlockFragInfo {
index 317bc6c1cd3c4ad930c32c67f42a37dbd1b1be18..04ce02aeb4da61bc0a15d8c2ff9b373c3097aec3 100644 (file)
@@ -1502,6 +1502,7 @@ static int img_convert(int argc, char **argv)
             goto out;
         }
     } else {
+        compress = compress || bdi.needs_compressed_writes;
         cluster_sectors = bdi.cluster_size / BDRV_SECTOR_SIZE;
     }