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 From: Luiz Capitulino 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> Subject: [Qemu-devel] [RFC 5/7] qemu-img: img_create(): use Error object List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, armbru@redhat.com 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; -- 1.7.12.315.g682ce8b