diff mbox

[1/2] qemu-img: Don't allow preallocation and compression at the same time

Message ID 1318952858-18960-1-git-send-email-kwolf@redhat.com
State New
Headers show

Commit Message

Kevin Wolf Oct. 18, 2011, 3:47 p.m. UTC
Only qcow and qcow2 can do compression at all, and they require unallocated
clusters when writing the compressed data.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qemu-img.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

Comments

Stefan Hajnoczi Oct. 20, 2011, 5:27 p.m. UTC | #1
On Tue, Oct 18, 2011 at 8:47 AM, Kevin Wolf <kwolf@redhat.com> wrote:
> Only qcow and qcow2 can do compression at all, and they require unallocated
> clusters when writing the compressed data.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  qemu-img.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
diff mbox

Patch

diff --git a/qemu-img.c b/qemu-img.c
index 6a39731..511f136 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -824,6 +824,8 @@  static int img_convert(int argc, char **argv)
     if (compress) {
         QEMUOptionParameter *encryption =
             get_option_parameter(param, BLOCK_OPT_ENCRYPT);
+        QEMUOptionParameter *preallocation =
+            get_option_parameter(param, BLOCK_OPT_PREALLOC);
 
         if (!drv->bdrv_write_compressed) {
             error_report("Compression not supported for this file format");
@@ -837,6 +839,13 @@  static int img_convert(int argc, char **argv)
             ret = -1;
             goto out;
         }
+
+        if (preallocation && strcmp(preallocation->value.s, "off")) {
+            error_report("Compression and preallocation not supported at "
+                         "the same time");
+            ret = -1;
+            goto out;
+        }
     }
 
     /* Create the new image */