From patchwork Thu Mar 28 16:47:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Hrdina X-Patchwork-Id: 232137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8B1F72C00A8 for ; Fri, 29 Mar 2013 04:13:41 +1100 (EST) Received: from localhost ([::1]:55381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULG3o-0004ax-GW for incoming@patchwork.ozlabs.org; Thu, 28 Mar 2013 12:52:20 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULFzH-00079u-Hj for qemu-devel@nongnu.org; Thu, 28 Mar 2013 12:47:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ULFzF-0004M6-41 for qemu-devel@nongnu.org; Thu, 28 Mar 2013 12:47:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULFzE-0004Lo-Sw for qemu-devel@nongnu.org; Thu, 28 Mar 2013 12:47:37 -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 r2SGlaKw017258 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 28 Mar 2013 12:47:36 -0400 Received: from localhost.localdomain.com (dhcp-27-230.brq.redhat.com [10.34.27.230]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2SGlIRI018303; Thu, 28 Mar 2013 12:47:34 -0400 From: Pavel Hrdina To: qemu-devel@nongnu.org Date: Thu, 28 Mar 2013 17:47:12 +0100 Message-Id: <624f54b5c269178e6fb4b212de05ceda59c3d009.1364487348.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: phrdina@redhat.com, armbru@redhat.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH v3 08/11] qemu-img: introduce qemu_img_handle_error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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)