From patchwork Wed Oct 17 19:35:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 192133 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 C788F2C0091 for ; Thu, 18 Oct 2012 06:55:44 +1100 (EST) Received: from localhost ([::1]:42457 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOZPD-00030N-3l for incoming@patchwork.ozlabs.org; Wed, 17 Oct 2012 15:35:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOZOd-0001dh-N2 for qemu-devel@nongnu.org; Wed, 17 Oct 2012 15:35:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOZOc-0001Zf-DY for qemu-devel@nongnu.org; Wed, 17 Oct 2012 15:35:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2324) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOZOb-0001ZZ-WA for qemu-devel@nongnu.org; Wed, 17 Oct 2012 15:35:14 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9HJZDUX014721 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 17 Oct 2012 15:35:13 -0400 Received: from localhost (ovpn-113-93.phx2.redhat.com [10.3.113.93]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9HJZC6q031446; Wed, 17 Oct 2012 15:35:12 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2012 16:35:53 -0300 Message-Id: <1350502556-4885-6-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1350502556-4885-1-git-send-email-lcapitulino@redhat.com> References: <1350502556-4885-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, armbru@redhat.com Subject: [Qemu-devel] [PATCH 5/8] qemu-img: img_create(): use Error object 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: Luiz Capitulino --- qemu-img.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 12fb6c2..dfde588 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -302,6 +302,7 @@ static int img_create(int argc, char **argv) const char *base_filename = NULL; char *options = NULL; QEMUOptionParameter *params = NULL; + Error *local_err = NULL; for(;;) { c = getopt(argc, argv, "F:b:f:he6o:"); @@ -362,9 +363,12 @@ static int img_create(int argc, char **argv) goto out; } - ret = bdrv_img_create(filename, fmt, base_filename, base_fmt, - options, img_size, BDRV_O_FLAGS, ¶ms, NULL); - if (ret < 0) { + bdrv_img_create(filename, fmt, base_filename, base_fmt, + options, img_size, BDRV_O_FLAGS, ¶ms, &local_err); + if (error_is_set(&local_err)) { + fprintf(stderr, "qemu-img: %s\n", error_get_pretty(local_err)); + error_free(local_err); + ret = -1; goto out; }