@@ -2996,7 +2996,7 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
int refcount_order;
const char *encryptfmt = NULL;
Error *local_err = NULL;
- int ret;
+ int ret = -EINVAL;
/* Read out options */
size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
@@ -3008,7 +3008,6 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
if (qemu_opt_get_del(opts, BLOCK_OPT_ENCRYPT)) {
error_setg(errp, "Options " BLOCK_OPT_ENCRYPT " and "
BLOCK_OPT_ENCRYPT_FORMAT " are mutually exclusive");
- ret = -EINVAL;
goto finish;
}
} else if (qemu_opt_get_bool_del(opts, BLOCK_OPT_ENCRYPT, false)) {
@@ -3017,7 +3016,6 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
cluster_size = qcow2_opt_get_cluster_size_del(opts, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- ret = -EINVAL;
goto finish;
}
buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
@@ -3026,14 +3024,12 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
&local_err);
if (local_err) {
error_propagate(errp, local_err);
- ret = -EINVAL;
goto finish;
}
version = qcow2_opt_get_version_del(opts, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- ret = -EINVAL;
goto finish;
}
@@ -3044,21 +3040,18 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
if (backing_file && prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Backing file and preallocation cannot be used at "
"the same time");
- ret = -EINVAL;
goto finish;
}
if (version < 3 && (flags & BLOCK_FLAG_LAZY_REFCOUNTS)) {
error_setg(errp, "Lazy refcounts only supported with compatibility "
"level 1.1 and above (use compat=1.1 or greater)");
- ret = -EINVAL;
goto finish;
}
refcount_bits = qcow2_opt_get_refcount_bits_del(opts, version, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- ret = -EINVAL;
goto finish;
}
@@ -3074,13 +3067,11 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
visit_start_struct(v, NULL, NULL, 0, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- ret = -EINVAL;
goto finish;
}
visit_type_Qcow2Compress_members(v, &compress, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- ret = -EINVAL;
goto finish;
}
visit_end_struct(v, NULL);
@@ -3091,12 +3082,12 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
&local_err);
if (local_err) {
error_propagate(errp, local_err);
- ret = -EINVAL;
goto finish;
}
compress_ptr = &compress;
}
+ /* ret is still -EINVAL until here */
ret = qcow2_create2(filename, size, backing_file, backing_fmt, flags,
cluster_size, prealloc, opts, version, refcount_order,
encryptfmt, compress_ptr, &local_err);
Signed-off-by: Peter Lieven <pl@kamp.de> --- block/qcow2.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)