summary refs log tree commit diff stats
path: root/qemu-img.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2011-10-18 16:19:42 +0200
committerKevin Wolf <kwolf@redhat.com>2011-10-21 17:34:13 +0200
commit41521fa4a60344eaad433db1ab4597ba6bf78f69 (patch)
treee9bb6ca61741faa6b9f43ff27e9b4694277fc4e9 /qemu-img.c
parenta18e67f5f9dc1e5e9a293a946666e2e74daa1c91 (diff)
downloadfocaccia-qemu-41521fa4a60344eaad433db1ab4597ba6bf78f69.tar.gz
focaccia-qemu-41521fa4a60344eaad433db1ab4597ba6bf78f69.zip
qemu-img: Don't allow preallocation and compression at the same time
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>
Diffstat (limited to 'qemu-img.c')
-rw-r--r--qemu-img.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/qemu-img.c b/qemu-img.c
index 6a3973163f..86127f0b11 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,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 */