]> git.proxmox.com Git - qemu.git/commitdiff
qemu-img: Don't allow preallocation and compression at the same time
authorKevin Wolf <kwolf@redhat.com>
Tue, 18 Oct 2011 14:19:42 +0000 (16:19 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 21 Oct 2011 15:34:13 +0000 (17:34 +0200)
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>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
qemu-img.c

index 6a3973163f82f483b6b627a9f97bd4314d8cdea4..86127f0b1142fc976f5864efc7d79c51f669f4f0 100644 (file)
@@ -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,15 @@ static int img_convert(int argc, char **argv)
             ret = -1;
             goto out;
         }
+
+        if (preallocation && preallocation->value.s
+            && strcmp(preallocation->value.s, "off"))
+        {
+            error_report("Compression and preallocation not supported at "
+                         "the same time");
+            ret = -1;
+            goto out;
+        }
     }
 
     /* Create the new image */