Skip to contentSkip to conversation

block: More robust error handling around perm check

PATCH Superseded Fam Zheng 3 participants 6 messages Mar 3, 2017 – Mar 6, 2017 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

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
author
#1 lore raw

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
index daa7908..4eab68f 100644
@@ -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
#2 lore raw

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_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 +0 -0
index daa7908..4eab68f 100644

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

author
#3 lore raw

PATCH 2/2 commit: Don't use error_abort in commit_start

In reply to Fam Zheng

bdrv_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
index 22a0a4d..1be19e1 100644
@@ -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
#4 lore raw

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_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 +0 -2
index 22a0a4d..1be19e1 100644
@@ -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

Reviewed-by on the v1 series
#5 lore raw
In reply to Fam Zheng
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 use error_abort in blk_new_open
commit: Don't use error_abort in commit_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