From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOqgG-0004K3-U7 for qemu-devel@nongnu.org; Thu, 18 Oct 2012 10:02:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOqg6-0001Ao-5L for qemu-devel@nongnu.org; Thu, 18 Oct 2012 10:02:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29204) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOqg5-0001AY-SY for qemu-devel@nongnu.org; Thu, 18 Oct 2012 10:02:26 -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 q9IE2PEI011818 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Oct 2012 10:02:25 -0400 Message-ID: <50800BEE.9010006@redhat.com> Date: Thu, 18 Oct 2012 16:02:22 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1350502556-4885-1-git-send-email-lcapitulino@redhat.com> <1350502556-4885-6-git-send-email-lcapitulino@redhat.com> <507FF1FC.1060502@redhat.com> <20121018104941.486f1404@doriath.home> In-Reply-To: <20121018104941.486f1404@doriath.home> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 5/8] qemu-img: img_create(): use Error object List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com Am 18.10.2012 15:49, schrieb Luiz Capitulino: > On Thu, 18 Oct 2012 14:11:40 +0200 > Kevin Wolf wrote: > >> Am 17.10.2012 21:35, schrieb Luiz Capitulino: >>> 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)); >> >> This should use error_report() instead of adding the "qemu-img:" manually. > > If you want to do it for consistency with the current code then ok, > I'll do it for v2. But I disagree qemu-img should keep using error_report(), > printing to hmp for example is something beyond the interests of a tool like > qemu-img. qemu-img doesn't have an HMP monitor, so it doesn't hurt either. If you want to replace it, replace it with a copy of qemu-error.c that only removes the monitor_vprintf() case. That is, in particular, leave all of the loc_*() functionality there, because this is something that is meant for use in command line parsers. That qemu-img doesn't use these functions yet should be fixed. It has some good use cases for them. Kevin