Skip to contentSkip to conversation

block: mirror - use local_err to avoid NULL errp

PATCH Applied Jeff Cody 4 participants 4 messages Feb 13, 2014 – Feb 14, 2014 Block layer

lore
Share & tools
lore

Jeff Cody

author
#0 lore raw

PATCH v2 1/1 block: mirror - use local_err to avoid NULL errp

When starting a block job, commit_active_start() relies on whether *errp is set by mirror_start_job. This allows it to determine if the mirror job start failed, so that it can clean up any changes to open flags from the bdrv_reopen(). If errp is NULL, then it will not be able to determine if mirror_start_job failed or not.

To avoid this, use a local Error variable, and then propagate the error (if any) to errp.

---
 block/mirror.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
block/mirror.c +5 -2
index 2a43334..ddb5765 100644
@@ -633,6 +633,8 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
 {
     int64_t length, base_length;
     int orig_base_flags;
+    Error *local_err = NULL;
+
 
     orig_base_flags = bdrv_get_flags(base);
 
@@ -663,9 +665,10 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
 
     bdrv_ref(base);
     mirror_start_job(bs, base, speed, 0, 0,
-                     on_error, on_error, cb, opaque, errp,
+                     on_error, on_error, cb, opaque, &local_err,
                      &commit_active_job_driver, false, base);
-    if (error_is_set(errp)) {
+    if (error_is_set(&local_err)) {
+        error_propagate(errp, local_err);
         goto error_restore_flags;
     }
 
Signature · 1 line
1.8.3.1
Reviewed-by on v2 1/1
#1 lore raw

Am 13.02.2014 um 15:23 hat Jeff Cody geschrieben:

Quoted 11 lines

When starting a block job, commit_active_start() relies on whether *errp is set by mirror_start_job. This allows it to determine if the mirror job start failed, so that it can clean up any changes to open flags from the bdrv_reopen(). If errp is NULL, then it will not be able to determine if mirror_start_job failed or not.

To avoid this, use a local Error variable, and then propagate the error (if any) to errp.

Reviewed-by on v2 1/1
#2 lore raw
In reply to Jeff Cody
Quoted 20 lines · Jeff Cody

When starting a block job, commit_active_start() relies on whether *errp is set by mirror_start_job. This allows it to determine if the mirror job start failed, so that it can clean up any changes to open flags from the bdrv_reopen(). If errp is NULL, then it will not be able to determine if mirror_start_job failed or not.

To avoid this, use a local Error variable, and then propagate the error (if any) to errp.

---
 block/mirror.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
block/mirror.c +0 -0
index 2a43334..ddb5765 100644

block/mirror.c void commit_active_start(BlockDriverState *bs, BlockDriverState *base, · line 639

Quoted 7 lines
block/mirror.c +2 -0
@@ -633,6 +633,8 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
 {
     int64_t length, base_length;
     int orig_base_flags;
+    Error *local_err = NULL;
+
 
     orig_base_flags = bdrv_get_flags(base);

Why the double blank line?

Besides that,

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#3 lore raw
In reply to Jeff Cody
Quoted 6 lines · Jeff Cody

When starting a block job, commit_active_start() relies on whether *errp is set by mirror_start_job. This allows it to determine if the mirror job start failed, so that it can clean up any changes to open flags from the bdrv_reopen(). If errp is NULL, then it will not be able to determine if mirror_start_job failed or not.

Quoted 8 lines

To avoid this, use a local Error variable, and then propagate the error (if any) to errp.

---
 block/mirror.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan