Received: from eggs.gnu.org ([208.118.235.92]:42261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPb8P-0002Fw-17 for qemu-devel@nongnu.org; Tue, 09 Apr 2013 12:11:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPb8N-0005kU-OJ for qemu-devel@nongnu.org; Tue, 09 Apr 2013 12:11:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56544) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPb8N-0005kF-Ee for qemu-devel@nongnu.org; Tue, 09 Apr 2013 12:10:59 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r39GAwWS004533 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Apr 2013 12:10:58 -0400 From: Markus Armbruster References: <6d3caeb8c5fdb663a24c9549ef6d74db77823516.1364565637.git.phrdina@redhat.com> Date: Tue, 09 Apr 2013 18:10:56 +0200 In-Reply-To: <6d3caeb8c5fdb663a24c9549ef6d74db77823516.1364565637.git.phrdina@redhat.com> (Pavel Hrdina's message of "Fri, 29 Mar 2013 15:12:35 +0100") Message-ID: <878v4r65wv.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v4 08/11] qemu-img: introduce qemu_img_handle_error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Hrdina Cc: qemu-devel@nongnu.org, lcapitulino@redhat.com Pavel Hrdina writes: > Signed-off-by: Pavel Hrdina > Reviewed-by: Eric Blake > --- > qemu-img.c | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) > > diff --git a/qemu-img.c b/qemu-img.c > index 21d02bf..d5f81cc 100644 > --- a/qemu-img.c > +++ b/qemu-img.c > @@ -322,6 +322,17 @@ static int add_old_style_options(const char *fmt, QEMUOptionParameter *list, > return 0; > } > > +static int qemu_img_handle_error(Error *err) > +{ > + if (error_is_set(&err)) { > + error_report("%s", error_get_pretty(err)); > + error_free(err); > + return 1; > + } > + > + return 0; > +} > + > static int img_create(int argc, char **argv) > { > int c; > @@ -400,13 +411,8 @@ static int img_create(int argc, char **argv) > > bdrv_img_create(filename, fmt, base_filename, base_fmt, > options, img_size, BDRV_O_FLAGS, &local_err, quiet); > - if (error_is_set(&local_err)) { > - error_report("%s", error_get_pretty(local_err)); > - error_free(local_err); > - return 1; > - } > > - return 0; > + return qemu_img_handle_error(local_err); > } > > static void dump_json_image_check(ImageCheck *check, bool quiet) If you put this before PATCH 1, you can use qemu_img_handle_error() in PATCH 01 for reporting bdrv_snapshot_create() failure the right way right away. You do it in PATCH 09 now.