mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
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>
This commit is contained in:
parent
a18e67f5f9
commit
41521fa4a6
1 changed files with 11 additions and 0 deletions
11
qemu-img.c
11
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 */
|
||||
|
|
Loading…
Reference in a new issue