Received: from eggs.gnu.org ([2001:4830:134:3::10]:39953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDxCe-0001XS-Hy for qemu-devel@nongnu.org; Thu, 13 Feb 2014 09:23:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDxCY-0003Nu-IZ for qemu-devel@nongnu.org; Thu, 13 Feb 2014 09:23:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3724) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDxCY-0003Np-AU for qemu-devel@nongnu.org; Thu, 13 Feb 2014 09:23:42 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1DENfip017793 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 13 Feb 2014 09:23:41 -0500 From: Jeff Cody Date: Thu, 13 Feb 2014 09:23:38 -0500 Message-Id: <20aba630c8a70a11c19404ca7020f3bd6c42f21e.1392301375.git.jcody@redhat.com> Subject: [Qemu-devel] [PATCH v2] block: mirror - use local_err to avoid NULL errp List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, armbru@redhat.com, stefanha@redhat.com 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 Signed-off-by: Jeff Cody --- block/mirror.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 2a43334..ddb5765 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -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; } -- 1.8.3.1