[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 5/8] qemu-img: img_create(): use Error object
From: |
Luiz Capitulino |
Subject: |
Re: [Qemu-devel] [PATCH 5/8] qemu-img: img_create(): use Error object |
Date: |
Thu, 18 Oct 2012 10:49:41 -0300 |
On Thu, 18 Oct 2012 14:11:40 +0200
Kevin Wolf <address@hidden> wrote:
> Am 17.10.2012 21:35, schrieb Luiz Capitulino:
> > Signed-off-by: Luiz Capitulino <address@hidden>
> > ---
> > 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.
I think we should use something like this for the tools:
static void print_error(const Error **errp)
{
fprintf(stderr, "%s: %s\n", progname, error_get_pretty(errp));
}
Where progname is set during initialization.
[Qemu-devel] [PATCH 7/8] qmp: qmp_transaction(): pass Error object to bdrv_img_create(), Luiz Capitulino, 2012/10/17
[Qemu-devel] [PATCH 6/8] qemu-img: img_create(): simplify, Luiz Capitulino, 2012/10/17
[Qemu-devel] [PATCH 8/8] block: bdrv_img_create(): drop unused error handling code, Luiz Capitulino, 2012/10/17