From patchwork Thu Oct 11 21:27:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 191006 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 A49002C0083 for ; Fri, 12 Oct 2012 08:42:32 +1100 (EST) Received: from localhost ([::1]:34377 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMQHn-0001rW-UQ for incoming@patchwork.ozlabs.org; Thu, 11 Oct 2012 17:27:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMQGt-0007pB-Tz for qemu-devel@nongnu.org; Thu, 11 Oct 2012 17:26:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMQGs-0005Zh-39 for qemu-devel@nongnu.org; Thu, 11 Oct 2012 17:26:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56870) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMQGr-0005Ye-Pl for qemu-devel@nongnu.org; Thu, 11 Oct 2012 17:26:21 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9BLQLE4008864 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 11 Oct 2012 17:26:21 -0400 Received: from localhost (ovpn-113-113.phx2.redhat.com [10.3.113.113]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9BLQKe5021029; Thu, 11 Oct 2012 17:26:20 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 11 Oct 2012 18:27:03 -0300 Message-Id: <1349990825-2659-6-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1349990825-2659-1-git-send-email-lcapitulino@redhat.com> References: <1349990825-2659-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 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] [RFC 5/7] 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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 99b8ad1..18885c6 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 && params) { + 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 create: %s\n", error_get_pretty(local_err)); + error_free(local_err); + } else if (params) { printf("Formatting '%s', fmt=%s ", filename, fmt); print_option_parameters(params); free_option_parameters(params); @@ -372,7 +376,7 @@ static int img_create(int argc, char **argv) } out: - if (ret) { + if (ret || error_is_set(&local_err)) { return 1; } return 0;