block: More robust error handling around perm check
cover block: More robust error handling around perm check
These are a couple cases added with the op blocker changes, where errp is available but we still use error_abort. Fix them for obvious reasons.
Fam Zheng (2):
block: Don't use error_abort in blk_new_open
commit: Don't use error_abort in commit_start
block/block-backend.c | 6 +++++- block/commit.c | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/2 block: Don't use error_abort in blk_new_open
We have an errp and bdrv_root_attach_child can fail permission check, error_abort is not the best choice here.
--- block/block-backend.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
block/block-backend.c +5 -1
@@ -213,7 +213,11 @@ BlockBackend *blk_new_open(const char *filename, const char *reference, } blk->root =bdrv_root_attach_child (bs,"root" , &child_root, - perm,BLK_PERM_ALL , blk, &error_abort); + perm,BLK_PERM_ALL , blk, errp); +if (!blk->root) { +blk_unref (blk); +return NULL ; + }return blk; }
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 1/2] block: Don't use error_abort in blk_new_open
Am 03.03.2017 um 14:38 hat Fam Zheng geschrieben:
Quoted 13 lines
We have an errp and
bdrv_root_attach_childcan fail permission check,error_abortis not the best choice here.Signed-off-by Fam Zheng <[email protected]>--- block/block-backend.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)block/block-backend.c +0
-0
block/block-backend.c BlockBackend *blk_new_open(const char *filename, const char *reference, · line 220
Quoted 9 lines
block/block-backend.c +5
-1@@ -213,7 +213,11 @@ BlockBackend *blk_new_open(const char *filename, const char *reference, } blk->root =bdrv_root_attach_child (bs,"root" , &child_root, - perm,BLK_PERM_ALL , blk, &error_abort); + perm,BLK_PERM_ALL , blk, errp); +if (!blk->root) { +blk_unref (blk); +return NULL ; + }
Shouldn't we bdrv_unref(bs), too?
Kevin
PATCH 2/2 commit: Don't use error_abort in commit_start
In reply to Fam Zhengbdrv_set_backing_hd failure needn't be abort. Since we already have error parameter, use it.
--- block/commit.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
block/commit.c +10 -2
@@ -316,8 +316,16 @@ void commit_start(const char *job_id, BlockDriverState *bs, goto fail; } -bdrv_set_backing_hd (commit_top_bs, top, &error_abort); -bdrv_set_backing_hd (overlay_bs, commit_top_bs, &error_abort); +bdrv_set_backing_hd (commit_top_bs, top, &local_err); +if (local_err) { +error_propagate (errp, local_err); + goto fail; + } +bdrv_set_backing_hd (overlay_bs, commit_top_bs, &local_err); +if (local_err) { +error_propagate (errp, local_err); + goto fail; + } s->commit_top_bs = commit_top_bs;bdrv_unref (commit_top_bs);
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 2/2] commit: Don't use error_abort in commit_start
Am 03.03.2017 um 14:38 hat Fam Zheng geschrieben:
Quoted 18 lines
bdrv_set_backing_hdfailure needn't be abort. Since we already have error parameter, use it.Signed-off-by Fam Zheng <[email protected]>--- block/commit.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)block/commit.c +0
-2@@ -316,8 +316,16 @@ void commit_start(const char *job_id, BlockDriverState *bs, goto fail; } -bdrv_set_backing_hd (commit_top_bs, top, &error_abort); -bdrv_set_backing_hd (overlay_bs, commit_top_bs, &error_abort);
block/commit.c void commit_start(const char *job_id, BlockDriverState *bs, · line 328
Quoted 10 lines
block/commit.c +10
-0+bdrv_set_backing_hd (commit_top_bs, top, &local_err); +if (local_err) { +error_propagate (errp, local_err); + goto fail; + } +bdrv_set_backing_hd (overlay_bs, commit_top_bs, &local_err); +if (local_err) { +error_propagate (errp, local_err); + goto fail; + }
In these error paths, bdrv_unref(commit_top_bs) seems to missing.
Kevin
Quoted 6 lines · Fam Zheng
These are a couple cases added with the op blocker changes, where errp is available but we still use
error_abort. Fix them for obvious reasons.Fam Zheng (2):
block: Don't useerror_abortinblk_new_open
commit: Don't useerror_abortincommit_start
Quoted 5 lines
block/block-backend.c | 6 +++++- block/commit.c | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org