block/qcow2: simplify qcow2_co_invalidate_cache()
qcow2_do_open correctly sets errp on each failure path. So, we can simplify code in qcow2_co_invalidate_cache() and drop explicit error propagation. Add ERRP_GUARD() as mandated by the documentation in include/qapi/error.h so that error_prepend() is actually called even if errp is &error_fatal. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Greg Kurz <groug@kaod.org> Message-Id: <20210202124956.63146-13-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
772c4cad13
commit
e6247c9c9f
@ -2716,11 +2716,11 @@ static void qcow2_close(BlockDriverState *bs)
|
|||||||
static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs,
|
static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
|
ERRP_GUARD();
|
||||||
BDRVQcow2State *s = bs->opaque;
|
BDRVQcow2State *s = bs->opaque;
|
||||||
int flags = s->flags;
|
int flags = s->flags;
|
||||||
QCryptoBlock *crypto = NULL;
|
QCryptoBlock *crypto = NULL;
|
||||||
QDict *options;
|
QDict *options;
|
||||||
Error *local_err = NULL;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2738,16 +2738,11 @@ static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs,
|
|||||||
|
|
||||||
flags &= ~BDRV_O_INACTIVE;
|
flags &= ~BDRV_O_INACTIVE;
|
||||||
qemu_co_mutex_lock(&s->lock);
|
qemu_co_mutex_lock(&s->lock);
|
||||||
ret = qcow2_do_open(bs, options, flags, &local_err);
|
ret = qcow2_do_open(bs, options, flags, errp);
|
||||||
qemu_co_mutex_unlock(&s->lock);
|
qemu_co_mutex_unlock(&s->lock);
|
||||||
qobject_unref(options);
|
qobject_unref(options);
|
||||||
if (local_err) {
|
if (ret < 0) {
|
||||||
error_propagate_prepend(errp, local_err,
|
error_prepend(errp, "Could not reopen qcow2 layer: ");
|
||||||
"Could not reopen qcow2 layer: ");
|
|
||||||
bs->drv = NULL;
|
|
||||||
return;
|
|
||||||
} else if (ret < 0) {
|
|
||||||
error_setg_errno(errp, -ret, "Could not reopen qcow2 layer");
|
|
||||||
bs->drv = NULL;
|
bs->drv = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user