summaryrefslogtreecommitdiff
path: root/block/mirror.c
diff options
context:
space:
mode:
authorJeff Cody <jcody@redhat.com>2014-02-13 09:23:38 -0500
committerStefan Hajnoczi <stefanha@redhat.com>2014-02-14 18:05:39 +0100
commitcc67f4d1f9645e8e6d90aee84ca19162d661f082 (patch)
treefe989e6b91f313eba88caeca2df8adb1f35dfdff /block/mirror.c
parent2aa4a86f59c7093e03d2ec18c5d5f08c957d1a78 (diff)
downloadqemu-cc67f4d1f9645e8e6d90aee84ca19162d661f082.tar.gz
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. Reported-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/mirror.c')
-rw-r--r--block/mirror.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/block/mirror.c b/block/mirror.c
index 26d18e44d7..e683959570 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -634,6 +634,7 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
int64_t length, base_length;
int orig_base_flags;
int ret;
+ Error *local_err = NULL;
orig_base_flags = bdrv_get_flags(base);
@@ -668,9 +669,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;
}