9ae3a8
From 871111d1bf38bc391728793f898527823717ed6d Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <871111d1bf38bc391728793f898527823717ed6d.1418766606.git.jen@redhat.com>
9ae3a8
In-Reply-To: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
9ae3a8
References: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
9ae3a8
From: Fam Zheng <famz@redhat.com>
9ae3a8
Date: Thu, 4 Dec 2014 00:05:12 -0600
9ae3a8
Subject: [CHANGE 18/31] qemu-img: Convert by cluster size if target is
9ae3a8
 compressed
9ae3a8
To: rhvirt-patches@redhat.com,
9ae3a8
    jen@redhat.com
9ae3a8
9ae3a8
RH-Author: Fam Zheng <famz@redhat.com>
9ae3a8
Message-id: <1417651524-18041-19-git-send-email-famz@redhat.com>
9ae3a8
Patchwork-id: 62691
9ae3a8
O-Subject: [RHEL-7.1 qemu-kvm PATCH v5 18/30] qemu-img: Convert by cluster size if target is compressed
9ae3a8
Bugzilla: 1134283
9ae3a8
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9ae3a8
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
RH-Acked-by: Max Reitz <mreitz@redhat.com>
9ae3a8
9ae3a8
If target block driver forces compression, qemu-img convert needs to
9ae3a8
write by cluster size as well as "-c" option.
9ae3a8
9ae3a8
Particularly, this applies for converting to VMDK streamOptimized
9ae3a8
format.
9ae3a8
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit 85f49cad879adfb5c3cbdc47ca3c3b50eb8f40bc)
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Jeff E. Nelson <jen@redhat.com>
9ae3a8
---
9ae3a8
 include/block/block.h | 4 ++++
9ae3a8
 qemu-img.c            | 1 +
9ae3a8
 2 files changed, 5 insertions(+)
9ae3a8
9ae3a8
diff --git a/include/block/block.h b/include/block/block.h
9ae3a8
index 3651bd9..b06a9dc 100644
9ae3a8
--- a/include/block/block.h
9ae3a8
+++ b/include/block/block.h
9ae3a8
@@ -34,6 +34,10 @@ typedef struct BlockDriverInfo {
9ae3a8
      * opened with BDRV_O_UNMAP flag for this to work.
9ae3a8
      */
9ae3a8
     bool can_write_zeroes_with_unmap;
9ae3a8
+    /*
9ae3a8
+     * True if this block driver only supports compressed writes
9ae3a8
+     */
9ae3a8
+    bool needs_compressed_writes;
9ae3a8
 } BlockDriverInfo;
9ae3a8
 
9ae3a8
 typedef struct BlockFragInfo {
9ae3a8
diff --git a/qemu-img.c b/qemu-img.c
9ae3a8
index f14890f..9c021e7 100644
9ae3a8
--- a/qemu-img.c
9ae3a8
+++ b/qemu-img.c
9ae3a8
@@ -1477,6 +1477,7 @@ static int img_convert(int argc, char **argv)
9ae3a8
             goto out;
9ae3a8
         }
9ae3a8
     } else {
9ae3a8
+        compress = compress || bdi.needs_compressed_writes;
9ae3a8
         cluster_sectors = bdi.cluster_size / BDRV_SECTOR_SIZE;
9ae3a8
     }
9ae3a8
 
9ae3a8
-- 
9ae3a8
2.1.0
9ae3a8