|
|
ae23c9 |
From 26f46c414ca053bfe87cebd9d40107fc4fa6bc1b Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Date: Mon, 18 Jun 2018 14:59:38 +0200
|
|
|
ae23c9 |
Subject: [PATCH 065/268] block: Add Error parameter to bdrv_amend_options
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180618145943.4489-3-mreitz@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 80755
|
|
|
ae23c9 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 2/7] block: Add Error parameter to bdrv_amend_options
|
|
|
ae23c9 |
Bugzilla: 1537956
|
|
|
ae23c9 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Looking at the qcow2 code that is riddled with error_report() calls,
|
|
|
ae23c9 |
this is really how it should have been from the start.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Along the way, turn the target_version/current_version comparisons at
|
|
|
ae23c9 |
the beginning of qcow2_downgrade() into assertions (the caller has to
|
|
|
ae23c9 |
make sure these conditions are met), and rephrase the error message on
|
|
|
ae23c9 |
using compat=1.1 to get refcount widths other than 16 bits.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Message-id: 20180509210023.20283-3-mreitz@redhat.com
|
|
|
ae23c9 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
ae23c9 |
Reviewed-by: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit d1402b502691142b9cebadd5cb993dc8858e9071)
|
|
|
ae23c9 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
block.c | 8 ++++--
|
|
|
ae23c9 |
block/qcow2.c | 72 ++++++++++++++++++++++++++--------------------
|
|
|
ae23c9 |
include/block/block.h | 3 +-
|
|
|
ae23c9 |
include/block/block_int.h | 3 +-
|
|
|
ae23c9 |
qemu-img.c | 4 +--
|
|
|
ae23c9 |
tests/qemu-iotests/060.out | 4 +--
|
|
|
ae23c9 |
tests/qemu-iotests/061.out | 7 -----
|
|
|
ae23c9 |
tests/qemu-iotests/080.out | 4 +--
|
|
|
ae23c9 |
tests/qemu-iotests/112.out | 5 +---
|
|
|
ae23c9 |
9 files changed, 58 insertions(+), 52 deletions(-)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/block.c b/block.c
|
|
|
ae23c9 |
index 982d54e..d991a09 100644
|
|
|
ae23c9 |
--- a/block.c
|
|
|
ae23c9 |
+++ b/block.c
|
|
|
ae23c9 |
@@ -5008,15 +5008,19 @@ void bdrv_remove_aio_context_notifier(BlockDriverState *bs,
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
int bdrv_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
- BlockDriverAmendStatusCB *status_cb, void *cb_opaque)
|
|
|
ae23c9 |
+ BlockDriverAmendStatusCB *status_cb, void *cb_opaque,
|
|
|
ae23c9 |
+ Error **errp)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
if (!bs->drv) {
|
|
|
ae23c9 |
+ error_setg(errp, "Node is ejected");
|
|
|
ae23c9 |
return -ENOMEDIUM;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
if (!bs->drv->bdrv_amend_options) {
|
|
|
ae23c9 |
+ error_setg(errp, "Block driver '%s' does not support option amendment",
|
|
|
ae23c9 |
+ bs->drv->format_name);
|
|
|
ae23c9 |
return -ENOTSUP;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
- return bs->drv->bdrv_amend_options(bs, opts, status_cb, cb_opaque);
|
|
|
ae23c9 |
+ return bs->drv->bdrv_amend_options(bs, opts, status_cb, cb_opaque, errp);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/* This function will be called by the bdrv_recurse_is_first_non_filter method
|
|
|
ae23c9 |
diff --git a/block/qcow2.c b/block/qcow2.c
|
|
|
ae23c9 |
index 26a6a7f..092db81 100644
|
|
|
ae23c9 |
--- a/block/qcow2.c
|
|
|
ae23c9 |
+++ b/block/qcow2.c
|
|
|
ae23c9 |
@@ -4039,22 +4039,21 @@ static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
|
|
|
ae23c9 |
* have to be removed.
|
|
|
ae23c9 |
*/
|
|
|
ae23c9 |
static int qcow2_downgrade(BlockDriverState *bs, int target_version,
|
|
|
ae23c9 |
- BlockDriverAmendStatusCB *status_cb, void *cb_opaque)
|
|
|
ae23c9 |
+ BlockDriverAmendStatusCB *status_cb, void *cb_opaque,
|
|
|
ae23c9 |
+ Error **errp)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
BDRVQcow2State *s = bs->opaque;
|
|
|
ae23c9 |
int current_version = s->qcow_version;
|
|
|
ae23c9 |
int ret;
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- if (target_version == current_version) {
|
|
|
ae23c9 |
- return 0;
|
|
|
ae23c9 |
- } else if (target_version > current_version) {
|
|
|
ae23c9 |
- return -EINVAL;
|
|
|
ae23c9 |
- } else if (target_version != 2) {
|
|
|
ae23c9 |
- return -EINVAL;
|
|
|
ae23c9 |
- }
|
|
|
ae23c9 |
+ /* This is qcow2_downgrade(), not qcow2_upgrade() */
|
|
|
ae23c9 |
+ assert(target_version < current_version);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ /* There are no other versions (now) that you can downgrade to */
|
|
|
ae23c9 |
+ assert(target_version == 2);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
if (s->refcount_order != 4) {
|
|
|
ae23c9 |
- error_report("compat=0.10 requires refcount_bits=16");
|
|
|
ae23c9 |
+ error_setg(errp, "compat=0.10 requires refcount_bits=16");
|
|
|
ae23c9 |
return -ENOTSUP;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
@@ -4062,6 +4061,7 @@ static int qcow2_downgrade(BlockDriverState *bs, int target_version,
|
|
|
ae23c9 |
if (s->incompatible_features & QCOW2_INCOMPAT_DIRTY) {
|
|
|
ae23c9 |
ret = qcow2_mark_clean(bs);
|
|
|
ae23c9 |
if (ret < 0) {
|
|
|
ae23c9 |
+ error_setg_errno(errp, -ret, "Failed to make the image clean");
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
@@ -4071,6 +4071,8 @@ static int qcow2_downgrade(BlockDriverState *bs, int target_version,
|
|
|
ae23c9 |
* best thing to do anyway */
|
|
|
ae23c9 |
|
|
|
ae23c9 |
if (s->incompatible_features) {
|
|
|
ae23c9 |
+ error_setg(errp, "Cannot downgrade an image with incompatible features "
|
|
|
ae23c9 |
+ "%#" PRIx64 " set", s->incompatible_features);
|
|
|
ae23c9 |
return -ENOTSUP;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
@@ -4084,6 +4086,7 @@ static int qcow2_downgrade(BlockDriverState *bs, int target_version,
|
|
|
ae23c9 |
|
|
|
ae23c9 |
ret = qcow2_expand_zero_clusters(bs, status_cb, cb_opaque);
|
|
|
ae23c9 |
if (ret < 0) {
|
|
|
ae23c9 |
+ error_setg_errno(errp, -ret, "Failed to turn zero into data clusters");
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
@@ -4091,6 +4094,7 @@ static int qcow2_downgrade(BlockDriverState *bs, int target_version,
|
|
|
ae23c9 |
ret = qcow2_update_header(bs);
|
|
|
ae23c9 |
if (ret < 0) {
|
|
|
ae23c9 |
s->qcow_version = current_version;
|
|
|
ae23c9 |
+ error_setg_errno(errp, -ret, "Failed to update the image header");
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
return 0;
|
|
|
ae23c9 |
@@ -4168,7 +4172,8 @@ static void qcow2_amend_helper_cb(BlockDriverState *bs,
|
|
|
ae23c9 |
|
|
|
ae23c9 |
static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
BlockDriverAmendStatusCB *status_cb,
|
|
|
ae23c9 |
- void *cb_opaque)
|
|
|
ae23c9 |
+ void *cb_opaque,
|
|
|
ae23c9 |
+ Error **errp)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
BDRVQcow2State *s = bs->opaque;
|
|
|
ae23c9 |
int old_version = s->qcow_version, new_version = old_version;
|
|
|
ae23c9 |
@@ -4180,7 +4185,6 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
bool encrypt;
|
|
|
ae23c9 |
int encformat;
|
|
|
ae23c9 |
int refcount_bits = s->refcount_bits;
|
|
|
ae23c9 |
- Error *local_err = NULL;
|
|
|
ae23c9 |
int ret;
|
|
|
ae23c9 |
QemuOptDesc *desc = opts->list->desc;
|
|
|
ae23c9 |
Qcow2AmendHelperCBInfo helper_cb_info;
|
|
|
ae23c9 |
@@ -4201,11 +4205,11 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
} else if (!strcmp(compat, "1.1")) {
|
|
|
ae23c9 |
new_version = 3;
|
|
|
ae23c9 |
} else {
|
|
|
ae23c9 |
- error_report("Unknown compatibility level %s", compat);
|
|
|
ae23c9 |
+ error_setg(errp, "Unknown compatibility level %s", compat);
|
|
|
ae23c9 |
return -EINVAL;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
} else if (!strcmp(desc->name, BLOCK_OPT_PREALLOC)) {
|
|
|
ae23c9 |
- error_report("Cannot change preallocation mode");
|
|
|
ae23c9 |
+ error_setg(errp, "Cannot change preallocation mode");
|
|
|
ae23c9 |
return -ENOTSUP;
|
|
|
ae23c9 |
} else if (!strcmp(desc->name, BLOCK_OPT_SIZE)) {
|
|
|
ae23c9 |
new_size = qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0);
|
|
|
ae23c9 |
@@ -4218,7 +4222,8 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
!!s->crypto);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
if (encrypt != !!s->crypto) {
|
|
|
ae23c9 |
- error_report("Changing the encryption flag is not supported");
|
|
|
ae23c9 |
+ error_setg(errp,
|
|
|
ae23c9 |
+ "Changing the encryption flag is not supported");
|
|
|
ae23c9 |
return -ENOTSUP;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
} else if (!strcmp(desc->name, BLOCK_OPT_ENCRYPT_FORMAT)) {
|
|
|
ae23c9 |
@@ -4226,17 +4231,19 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
qemu_opt_get(opts, BLOCK_OPT_ENCRYPT_FORMAT));
|
|
|
ae23c9 |
|
|
|
ae23c9 |
if (encformat != s->crypt_method_header) {
|
|
|
ae23c9 |
- error_report("Changing the encryption format is not supported");
|
|
|
ae23c9 |
+ error_setg(errp,
|
|
|
ae23c9 |
+ "Changing the encryption format is not supported");
|
|
|
ae23c9 |
return -ENOTSUP;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
} else if (g_str_has_prefix(desc->name, "encrypt.")) {
|
|
|
ae23c9 |
- error_report("Changing the encryption parameters is not supported");
|
|
|
ae23c9 |
+ error_setg(errp,
|
|
|
ae23c9 |
+ "Changing the encryption parameters is not supported");
|
|
|
ae23c9 |
return -ENOTSUP;
|
|
|
ae23c9 |
} else if (!strcmp(desc->name, BLOCK_OPT_CLUSTER_SIZE)) {
|
|
|
ae23c9 |
cluster_size = qemu_opt_get_size(opts, BLOCK_OPT_CLUSTER_SIZE,
|
|
|
ae23c9 |
cluster_size);
|
|
|
ae23c9 |
if (cluster_size != s->cluster_size) {
|
|
|
ae23c9 |
- error_report("Changing the cluster size is not supported");
|
|
|
ae23c9 |
+ error_setg(errp, "Changing the cluster size is not supported");
|
|
|
ae23c9 |
return -ENOTSUP;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
} else if (!strcmp(desc->name, BLOCK_OPT_LAZY_REFCOUNTS)) {
|
|
|
ae23c9 |
@@ -4249,8 +4256,8 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
if (refcount_bits <= 0 || refcount_bits > 64 ||
|
|
|
ae23c9 |
!is_power_of_2(refcount_bits))
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
- error_report("Refcount width must be a power of two and may "
|
|
|
ae23c9 |
- "not exceed 64 bits");
|
|
|
ae23c9 |
+ error_setg(errp, "Refcount width must be a power of two and "
|
|
|
ae23c9 |
+ "may not exceed 64 bits");
|
|
|
ae23c9 |
return -EINVAL;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
} else {
|
|
|
ae23c9 |
@@ -4275,6 +4282,7 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
ret = qcow2_update_header(bs);
|
|
|
ae23c9 |
if (ret < 0) {
|
|
|
ae23c9 |
s->qcow_version = old_version;
|
|
|
ae23c9 |
+ error_setg_errno(errp, -ret, "Failed to update the image header");
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
@@ -4283,18 +4291,17 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
int refcount_order = ctz32(refcount_bits);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
if (new_version < 3 && refcount_bits != 16) {
|
|
|
ae23c9 |
- error_report("Different refcount widths than 16 bits require "
|
|
|
ae23c9 |
- "compatibility level 1.1 or above (use compat=1.1 or "
|
|
|
ae23c9 |
- "greater)");
|
|
|
ae23c9 |
+ error_setg(errp, "Refcount widths other than 16 bits require "
|
|
|
ae23c9 |
+ "compatibility level 1.1 or above (use compat=1.1 or "
|
|
|
ae23c9 |
+ "greater)");
|
|
|
ae23c9 |
return -EINVAL;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
helper_cb_info.current_operation = QCOW2_CHANGING_REFCOUNT_ORDER;
|
|
|
ae23c9 |
ret = qcow2_change_refcount_order(bs, refcount_order,
|
|
|
ae23c9 |
&qcow2_amend_helper_cb,
|
|
|
ae23c9 |
- &helper_cb_info, &local_err);
|
|
|
ae23c9 |
+ &helper_cb_info, errp);
|
|
|
ae23c9 |
if (ret < 0) {
|
|
|
ae23c9 |
- error_report_err(local_err);
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
@@ -4304,6 +4311,7 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
backing_file ?: s->image_backing_file,
|
|
|
ae23c9 |
backing_format ?: s->image_backing_format);
|
|
|
ae23c9 |
if (ret < 0) {
|
|
|
ae23c9 |
+ error_setg_errno(errp, -ret, "Failed to change the backing file");
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
@@ -4311,14 +4319,16 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
if (s->use_lazy_refcounts != lazy_refcounts) {
|
|
|
ae23c9 |
if (lazy_refcounts) {
|
|
|
ae23c9 |
if (new_version < 3) {
|
|
|
ae23c9 |
- error_report("Lazy refcounts only supported with compatibility "
|
|
|
ae23c9 |
- "level 1.1 and above (use compat=1.1 or greater)");
|
|
|
ae23c9 |
+ error_setg(errp, "Lazy refcounts only supported with "
|
|
|
ae23c9 |
+ "compatibility level 1.1 and above (use compat=1.1 "
|
|
|
ae23c9 |
+ "or greater)");
|
|
|
ae23c9 |
return -EINVAL;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS;
|
|
|
ae23c9 |
ret = qcow2_update_header(bs);
|
|
|
ae23c9 |
if (ret < 0) {
|
|
|
ae23c9 |
s->compatible_features &= ~QCOW2_COMPAT_LAZY_REFCOUNTS;
|
|
|
ae23c9 |
+ error_setg_errno(errp, -ret, "Failed to update the image header");
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
s->use_lazy_refcounts = true;
|
|
|
ae23c9 |
@@ -4326,6 +4336,7 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
/* make image clean first */
|
|
|
ae23c9 |
ret = qcow2_mark_clean(bs);
|
|
|
ae23c9 |
if (ret < 0) {
|
|
|
ae23c9 |
+ error_setg_errno(errp, -ret, "Failed to make the image clean");
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
/* now disallow lazy refcounts */
|
|
|
ae23c9 |
@@ -4333,6 +4344,7 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
ret = qcow2_update_header(bs);
|
|
|
ae23c9 |
if (ret < 0) {
|
|
|
ae23c9 |
s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS;
|
|
|
ae23c9 |
+ error_setg_errno(errp, -ret, "Failed to update the image header");
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
s->use_lazy_refcounts = false;
|
|
|
ae23c9 |
@@ -4341,17 +4353,15 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
|
|
|
ae23c9 |
if (new_size) {
|
|
|
ae23c9 |
BlockBackend *blk = blk_new(BLK_PERM_RESIZE, BLK_PERM_ALL);
|
|
|
ae23c9 |
- ret = blk_insert_bs(blk, bs, &local_err);
|
|
|
ae23c9 |
+ ret = blk_insert_bs(blk, bs, errp);
|
|
|
ae23c9 |
if (ret < 0) {
|
|
|
ae23c9 |
- error_report_err(local_err);
|
|
|
ae23c9 |
blk_unref(blk);
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
- ret = blk_truncate(blk, new_size, PREALLOC_MODE_OFF, &local_err);
|
|
|
ae23c9 |
+ ret = blk_truncate(blk, new_size, PREALLOC_MODE_OFF, errp);
|
|
|
ae23c9 |
blk_unref(blk);
|
|
|
ae23c9 |
if (ret < 0) {
|
|
|
ae23c9 |
- error_report_err(local_err);
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
@@ -4360,7 +4370,7 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
if (new_version < old_version) {
|
|
|
ae23c9 |
helper_cb_info.current_operation = QCOW2_DOWNGRADING;
|
|
|
ae23c9 |
ret = qcow2_downgrade(bs, new_version, &qcow2_amend_helper_cb,
|
|
|
ae23c9 |
- &helper_cb_info);
|
|
|
ae23c9 |
+ &helper_cb_info, errp);
|
|
|
ae23c9 |
if (ret < 0) {
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
diff --git a/include/block/block.h b/include/block/block.h
|
|
|
ae23c9 |
index 06cd772..2d17b09 100644
|
|
|
ae23c9 |
--- a/include/block/block.h
|
|
|
ae23c9 |
+++ b/include/block/block.h
|
|
|
ae23c9 |
@@ -343,7 +343,8 @@ int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix);
|
|
|
ae23c9 |
typedef void BlockDriverAmendStatusCB(BlockDriverState *bs, int64_t offset,
|
|
|
ae23c9 |
int64_t total_work_size, void *opaque);
|
|
|
ae23c9 |
int bdrv_amend_options(BlockDriverState *bs_new, QemuOpts *opts,
|
|
|
ae23c9 |
- BlockDriverAmendStatusCB *status_cb, void *cb_opaque);
|
|
|
ae23c9 |
+ BlockDriverAmendStatusCB *status_cb, void *cb_opaque,
|
|
|
ae23c9 |
+ Error **errp);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/* external snapshots */
|
|
|
ae23c9 |
bool bdrv_recurse_is_first_non_filter(BlockDriverState *bs,
|
|
|
ae23c9 |
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
|
|
ae23c9 |
index c4dd1d4..d913ed1 100644
|
|
|
ae23c9 |
--- a/include/block/block_int.h
|
|
|
ae23c9 |
+++ b/include/block/block_int.h
|
|
|
ae23c9 |
@@ -324,7 +324,8 @@ struct BlockDriver {
|
|
|
ae23c9 |
|
|
|
ae23c9 |
int (*bdrv_amend_options)(BlockDriverState *bs, QemuOpts *opts,
|
|
|
ae23c9 |
BlockDriverAmendStatusCB *status_cb,
|
|
|
ae23c9 |
- void *cb_opaque);
|
|
|
ae23c9 |
+ void *cb_opaque,
|
|
|
ae23c9 |
+ Error **errp);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
void (*bdrv_debug_event)(BlockDriverState *bs, BlkdebugEvent event);
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/qemu-img.c b/qemu-img.c
|
|
|
ae23c9 |
index 2f7c491..e40d6ff 100644
|
|
|
ae23c9 |
--- a/qemu-img.c
|
|
|
ae23c9 |
+++ b/qemu-img.c
|
|
|
ae23c9 |
@@ -3761,10 +3761,10 @@ static int img_amend(int argc, char **argv)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/* In case the driver does not call amend_status_cb() */
|
|
|
ae23c9 |
qemu_progress_print(0.f, 0);
|
|
|
ae23c9 |
- ret = bdrv_amend_options(bs, opts, &amend_status_cb, NULL);
|
|
|
ae23c9 |
+ ret = bdrv_amend_options(bs, opts, &amend_status_cb, NULL, &err;;
|
|
|
ae23c9 |
qemu_progress_print(100.f, 0);
|
|
|
ae23c9 |
if (ret < 0) {
|
|
|
ae23c9 |
- error_report("Error while amending options: %s", strerror(-ret));
|
|
|
ae23c9 |
+ error_report_err(err);
|
|
|
ae23c9 |
goto out;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out
|
|
|
ae23c9 |
index 99234fb..bff023d 100644
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/060.out
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/060.out
|
|
|
ae23c9 |
@@ -129,7 +129,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
|
ae23c9 |
wrote 65536/65536 bytes at offset 0
|
|
|
ae23c9 |
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
ae23c9 |
qcow2: Marking image as corrupt: L2 table offset 0x42a00 unaligned (L1 index: 0); further corruption events will be suppressed
|
|
|
ae23c9 |
-qemu-img: Error while amending options: Input/output error
|
|
|
ae23c9 |
+qemu-img: Failed to turn zero into data clusters: Input/output error
|
|
|
ae23c9 |
|
|
|
ae23c9 |
=== Testing unaligned L2 entry ===
|
|
|
ae23c9 |
|
|
|
ae23c9 |
@@ -145,7 +145,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
|
ae23c9 |
wrote 65536/65536 bytes at offset 0
|
|
|
ae23c9 |
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
ae23c9 |
qcow2: Marking image as corrupt: Cluster allocation offset 0x52a00 unaligned (L2 offset: 0x40000, L2 index: 0); further corruption events will be suppressed
|
|
|
ae23c9 |
-qemu-img: Error while amending options: Input/output error
|
|
|
ae23c9 |
+qemu-img: Failed to turn zero into data clusters: Input/output error
|
|
|
ae23c9 |
|
|
|
ae23c9 |
=== Testing unaligned reftable entry ===
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out
|
|
|
ae23c9 |
index e857ef9..183f7dd 100644
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/061.out
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/061.out
|
|
|
ae23c9 |
@@ -358,18 +358,12 @@ No errors were found on the image.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
|
ae23c9 |
qemu-img: Lazy refcounts only supported with compatibility level 1.1 and above (use compat=1.1 or greater)
|
|
|
ae23c9 |
-qemu-img: Error while amending options: Invalid argument
|
|
|
ae23c9 |
qemu-img: Lazy refcounts only supported with compatibility level 1.1 and above (use compat=1.1 or greater)
|
|
|
ae23c9 |
-qemu-img: Error while amending options: Invalid argument
|
|
|
ae23c9 |
qemu-img: Unknown compatibility level 0.42
|
|
|
ae23c9 |
-qemu-img: Error while amending options: Invalid argument
|
|
|
ae23c9 |
qemu-img: Invalid parameter 'foo'
|
|
|
ae23c9 |
qemu-img: Changing the cluster size is not supported
|
|
|
ae23c9 |
-qemu-img: Error while amending options: Operation not supported
|
|
|
ae23c9 |
qemu-img: Changing the encryption flag is not supported
|
|
|
ae23c9 |
-qemu-img: Error while amending options: Operation not supported
|
|
|
ae23c9 |
qemu-img: Cannot change preallocation mode
|
|
|
ae23c9 |
-qemu-img: Error while amending options: Operation not supported
|
|
|
ae23c9 |
|
|
|
ae23c9 |
=== Testing correct handling of unset value ===
|
|
|
ae23c9 |
|
|
|
ae23c9 |
@@ -377,7 +371,6 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
|
ae23c9 |
Should work:
|
|
|
ae23c9 |
Should not work:
|
|
|
ae23c9 |
qemu-img: Changing the cluster size is not supported
|
|
|
ae23c9 |
-qemu-img: Error while amending options: Operation not supported
|
|
|
ae23c9 |
|
|
|
ae23c9 |
=== Testing zero expansion on inactive clusters ===
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/080.out b/tests/qemu-iotests/080.out
|
|
|
ae23c9 |
index 4e0f7f7..281c7e0 100644
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/080.out
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/080.out
|
|
|
ae23c9 |
@@ -65,7 +65,7 @@ wrote 512/512 bytes at offset 0
|
|
|
ae23c9 |
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
ae23c9 |
qemu-img: Failed to load snapshot: Snapshot L1 table offset invalid
|
|
|
ae23c9 |
qemu-img: Snapshot L1 table offset invalid
|
|
|
ae23c9 |
-qemu-img: Error while amending options: Invalid argument
|
|
|
ae23c9 |
+qemu-img: Failed to turn zero into data clusters: Invalid argument
|
|
|
ae23c9 |
Failed to flush the refcount block cache: Invalid argument
|
|
|
ae23c9 |
write failed: Invalid argument
|
|
|
ae23c9 |
qemu-img: Snapshot L1 table offset invalid
|
|
|
ae23c9 |
@@ -88,7 +88,7 @@ wrote 512/512 bytes at offset 0
|
|
|
ae23c9 |
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
ae23c9 |
qemu-img: Failed to load snapshot: Snapshot L1 table too large
|
|
|
ae23c9 |
qemu-img: Snapshot L1 table too large
|
|
|
ae23c9 |
-qemu-img: Error while amending options: File too large
|
|
|
ae23c9 |
+qemu-img: Failed to turn zero into data clusters: File too large
|
|
|
ae23c9 |
Failed to flush the refcount block cache: File too large
|
|
|
ae23c9 |
write failed: File too large
|
|
|
ae23c9 |
qemu-img: Snapshot L1 table too large
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/112.out b/tests/qemu-iotests/112.out
|
|
|
ae23c9 |
index 86f0410..ae0318c 100644
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/112.out
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/112.out
|
|
|
ae23c9 |
@@ -99,13 +99,11 @@ refcount bits: 64
|
|
|
ae23c9 |
=== Amend to compat=0.10 ===
|
|
|
ae23c9 |
|
|
|
ae23c9 |
qemu-img: compat=0.10 requires refcount_bits=16
|
|
|
ae23c9 |
-qemu-img: Error while amending options: Operation not supported
|
|
|
ae23c9 |
refcount bits: 64
|
|
|
ae23c9 |
No errors were found on the image.
|
|
|
ae23c9 |
refcount bits: 16
|
|
|
ae23c9 |
refcount bits: 16
|
|
|
ae23c9 |
-qemu-img: Different refcount widths than 16 bits require compatibility level 1.1 or above (use compat=1.1 or greater)
|
|
|
ae23c9 |
-qemu-img: Error while amending options: Invalid argument
|
|
|
ae23c9 |
+qemu-img: Refcount widths other than 16 bits require compatibility level 1.1 or above (use compat=1.1 or greater)
|
|
|
ae23c9 |
refcount bits: 16
|
|
|
ae23c9 |
|
|
|
ae23c9 |
=== Amend with snapshot ===
|
|
|
ae23c9 |
@@ -113,7 +111,6 @@ refcount bits: 16
|
|
|
ae23c9 |
wrote 16777216/16777216 bytes at offset 0
|
|
|
ae23c9 |
16 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
ae23c9 |
qemu-img: Cannot decrease refcount entry width to 1 bits: Cluster at offset 0x50000 has a refcount of 2
|
|
|
ae23c9 |
-qemu-img: Error while amending options: Invalid argument
|
|
|
ae23c9 |
No errors were found on the image.
|
|
|
ae23c9 |
refcount bits: 16
|
|
|
ae23c9 |
No errors were found on the image.
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|