aboutsummaryrefslogtreecommitdiff
path: root/block/commit.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2017-01-13 19:02:32 +0100
committerKevin Wolf <kwolf@redhat.com>2017-02-28 20:40:36 +0100
commitd7086422b1c1e75e320519cfe26176db6ec97a37 (patch)
tree5b8cc8a489ee05f6432288590f1b621bccfa39c4 /block/commit.c
parent6d0eb64d5c6d57017c52a4f36ccae1db79215ee1 (diff)
downloadqemu-d7086422b1c1e75e320519cfe26176db6ec97a37.zip
qemu-d7086422b1c1e75e320519cfe26176db6ec97a37.tar.gz
qemu-d7086422b1c1e75e320519cfe26176db6ec97a37.tar.bz2
block: Add error parameter to blk_insert_bs()
Now that blk_insert_bs() requests the BlockBackend permissions for the node it attaches to, it can fail. Instead of aborting, pass the errors to the callers. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Acked-by: Fam Zheng <famz@redhat.com>
Diffstat (limited to 'block/commit.c')
-rw-r--r--block/commit.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/block/commit.c b/block/commit.c
index 1897e98..2ad8138 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -220,6 +220,7 @@ void commit_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *iter;
BlockDriverState *overlay_bs;
Error *local_err = NULL;
+ int ret;
assert(top != bs);
if (top == base) {
@@ -256,8 +257,7 @@ void commit_start(const char *job_id, BlockDriverState *bs,
bdrv_reopen_multiple(bdrv_get_aio_context(bs), reopen_queue, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
- block_job_unref(&s->common);
- return;
+ goto fail;
}
}
@@ -277,11 +277,17 @@ void commit_start(const char *job_id, BlockDriverState *bs,
/* FIXME Use real permissions */
s->base = blk_new(0, BLK_PERM_ALL);
- blk_insert_bs(s->base, base);
+ ret = blk_insert_bs(s->base, base, errp);
+ if (ret < 0) {
+ goto fail;
+ }
/* FIXME Use real permissions */
s->top = blk_new(0, BLK_PERM_ALL);
- blk_insert_bs(s->top, top);
+ ret = blk_insert_bs(s->top, top, errp);
+ if (ret < 0) {
+ goto fail;
+ }
s->active = bs;
@@ -294,6 +300,16 @@ void commit_start(const char *job_id, BlockDriverState *bs,
trace_commit_start(bs, base, top, s);
block_job_start(&s->common);
+ return;
+
+fail:
+ if (s->base) {
+ blk_unref(s->base);
+ }
+ if (s->top) {
+ blk_unref(s->top);
+ }
+ block_job_unref(&s->common);
}
@@ -332,11 +348,17 @@ int bdrv_commit(BlockDriverState *bs)
/* FIXME Use real permissions */
src = blk_new(0, BLK_PERM_ALL);
- blk_insert_bs(src, bs);
-
- /* FIXME Use real permissions */
backing = blk_new(0, BLK_PERM_ALL);
- blk_insert_bs(backing, bs->backing->bs);
+
+ ret = blk_insert_bs(src, bs, NULL);
+ if (ret < 0) {
+ goto ro_cleanup;
+ }
+
+ ret = blk_insert_bs(backing, bs->backing->bs, NULL);
+ if (ret < 0) {
+ goto ro_cleanup;
+ }
length = blk_getlength(src);
if (length < 0) {