qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, jcody@redhat.com, gentoo.integer@gmail.com,
	stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v2 1/5] qemu-img: Convert by cluster size if target is compressed
Date: Tue, 11 Feb 2014 11:28:35 +0800	[thread overview]
Message-ID: <1392089319-25307-2-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1392089319-25307-1-git-send-email-famz@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 <famz@redhat.com>
---
 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

  reply	other threads:[~2014-02-11  3:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-11  3:28 [Qemu-devel] [PATCH v2 0/5] Fix conversion from ISO to VMDK streamOptimized Fam Zheng
2014-02-11  3:28 ` Fam Zheng [this message]
2014-02-11  3:28 ` [Qemu-devel] [PATCH v2 2/5] vmdk: Implement .bdrv_write_compressed Fam Zheng
2014-02-11  3:28 ` [Qemu-devel] [PATCH v2 3/5] block: Change BlockDriverInfo.cluster_size to 64 bits Fam Zheng
2014-02-27 13:06   ` Stefan Hajnoczi
2014-02-11  3:28 ` [Qemu-devel] [PATCH v2 4/5] vmdk: Implement .bdrv_get_info() Fam Zheng
2014-02-11  3:28 ` [Qemu-devel] [PATCH v2 5/5] mirror: Check for bdrv_get_info result Fam Zheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392089319-25307-2-git-send-email-famz@redhat.com \
    --to=famz@redhat.com \
    --cc=gentoo.integer@gmail.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).