block: More robust error handling around perm check
v2 cover block: More robust error handling around perm check
v2: Fix error handling in both patches. [Kevin]
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 | 7 ++++++- block/commit.c | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-)
Signature · 1 line
2.9.3
PATCH v2 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
block/block-backend.c +6 -1
@@ -213,7 +213,12 @@ 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) { +bdrv_unref (bs); +blk_unref (blk); +return NULL ; + }return blk; }
Signature · 1 line
2.9.3
PATCH v2 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 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
block/commit.c +14 -2
@@ -316,8 +316,20 @@ 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) { +bdrv_unref (commit_top_bs); + commit_top_bs =NULL ; +error_propagate (errp, local_err); + goto fail; + } +bdrv_set_backing_hd (overlay_bs, commit_top_bs, &local_err); +if (local_err) { +bdrv_unref (commit_top_bs); + commit_top_bs =NULL ; +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
Kevin Wolf
AppliedAm 07.03.2017 um 12:07 hat Fam Zheng geschrieben:
Quoted 4 lines
v2: Fix error handling in both patches. [Kevin]
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.
Thanks, applied to the block branch.
Kevin