qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Amos Kong <kongjianjun@gmail.com>
Cc: kwolf@redhat.com, akong@redhat.com,
	Markus Armbruster <armbru@redhat.com>,
	Anthony Liguori <anthony@codemonkey.ws>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 09/19] sockets: Chardev open error reporting, sockets part
Date: Wed, 5 Sep 2012 15:52:06 -0300	[thread overview]
Message-ID: <20120905155206.3635f034@doriath.home> (raw)
In-Reply-To: <CAFeW=pYh0csc7U=j7-WPSOMe4g=k6gJaYUX99+tsDD-tk+j_yw@mail.gmail.com>

On Wed, 5 Sep 2012 10:19:22 +0800
Amos Kong <kongjianjun@gmail.com> wrote:

> On Thu, Aug 30, 2012 at 12:04 AM, Amos Kong <kongjianjun@gmail.com> wrote:
> 
> > On Wed, Aug 29, 2012 at 11:15 PM, Amos Kong <kongjianjun@gmail.com> wrote:
> > > On Thu, Feb 23, 2012 at 4:15 PM, Markus Armbruster <armbru@redhat.com>
> > wrote:
> > >>
> > >> Anthony Liguori <anthony@codemonkey.ws> writes:
> > >>
> > >> > On 02/15/2012 07:33 AM, Markus Armbruster wrote:
> > >> >> Anthony Liguori<anthony@codemonkey.ws>  writes:
> > >> >>
> > >> >>> On 02/14/2012 11:24 AM, Markus Armbruster wrote:
> > >> >>>> Markus Armbruster<armbru@redhat.com>   writes:
> > >> >>>>
> > >> >>>>> Anthony Liguori<aliguori@us.ibm.com>   writes:
> > >> >>>> [Anthony asking for error_set() instead of error_report()...]
> > >> >>>>>> Basically, same thing here and the remaining functions.  Let's
> > not
> > >> >>>>>> introduce additional uses of error_report().
> > >> >>>>>>
> > >> >>>>>> That said, I imagine you don't want to introduce a bunch of error
> > >> >>>>>> types for these different things and that's probably not
> > productive
> > >> >>>>>> anyway.
> > >> >>>> [...]
> > >> >>>>>> So let's compromise and introduce a generic QERR_INTERNAL_ERROR
> > that
> > >> >>>>>> takes a single human readable string as an argument.  We can
> > have a
> > >> >>>>>> wrapper for it that also records location information in the
> > error
> > >> >>>>>> object.
> > >
> > >
> > >
> > >
> > >
> > >>
> > >> >>>>> This series goes from stderr to error_report().  That's a
> > relatively
> > >> >>>>> simple step, which makes it relatively easy to review.  I'm afraid
> > >> >>>>> moving all the way to error.h in one step wouldn't be as easy.
> >  Kevin
> > >> >>>>> suggests to do it in a follow-up series, and I agree.
> > >> >>>
> > >> >>> The trouble I have is not about doing things incrementally, but
> > rather
> > >> >>> touching a lot of code incrementally.  Most of the code you touch
> > >> >>> could be done incrementally with error_set().
> > >> >>>
> > >> >>> For instance, you could touch inet_listen_opts() and just add an
> > Error
> > >> >>> ** as the last argument.  You can change all callers to simply do:
> > >> >>>
> > >> >>> Error *err = NULL;
> > >> >>>
> > >> >>> ...
> > >> >>> inet_listen_opts(...,&err);
> > >> >>> if (err) {
> > >> >>>     error_report_err(err);
> > >> >>>     return -1;
> > >> >>> }
> > >> >>>
> > >> >>> And it's not really all that different from the series as it stands
> > >> >>> today.  I agree that aggressively refactoring error propagation is
> > >> >>> probably not necessary as a first step, but if we're going to touch
> > a
> > >> >>> lot of code, we should do it in a way that we don't have to
> > >> >>> immediately touch it again next.
> > >> >>
> > >> >> Well, the series adds 47 calls of error_report() to five files out of
> > >> >> 1850.
> > >> >>
> > >> >>>>> Can you point to an existing conversion from error_report() to
> > error.h,
> > >> >>>>> to give us an idea how it's supposed to be done?
> > >> >>>>
> > >> >>>> Ping?
> > >> >>>
> > >> >>> Sorry, I mentally responded bug neglected to actually respond.
> > >> >>>
> > >> >>> All of the QMP work that Luiz is doing effectively does this so
> > there
> > >> >>> are ample examples right now.  The change command is probably a good
> > >> >>> place to start.
> > >> >>
> > >> >> Thanks.
> > >> >>
> > >> >> Unfortunately, I'm out of time on this one, so if you're unwilling to
> > >> >> accept this admittedly incremental improvement without substantial
> > >> >> rework, I'll have to let it rot in peace.
> > >> >>
> > >> >> We might want a QMP commands to add character devices some day.
> >  Perhaps
> > >> >> the person doing it will still be able to find these patches, and get
> > >> >> some use out of them.
> > >> >>
> > >> >> Patches 01-08,14 don't add error_report() calls.  What about
> > committing
> > >> >> them?  The commit messages would need to be reworded not to promise
> > >> >> goodies from the other patches, though.
> > >> >
> > >> > I'm sorry to hear that you can't continue working on this.
> > >>
> > >> Can't be helped.
> > >
> > >
> > >
> > > I want to continue working on this work (patch 9~13,15~19).
> >
> 
> 
> FYI, URL of the old thread:
> http://lists.nongnu.org/archive/html/qemu-devel/2012-02/msg00714.html
> 
> 
> 
> > > Makus used error_report() to output the rich/meaningful error message
> > > to monitor,
> > > but Anthony prefers to use error_set(), right?
> > >
> > > I would like to introduce a generic QERR_INTERNAL_ERROR as Anthony
> > > said to replace error_report().
> >
> >
> > error_report() can be used many times/places, we might see many error
> > in monitor.
> > but error_set() can only set one kind of error when internal error
> > occurs, and only
> > one error will be printed into monitor.
> >
> > output final/important error by error_set()/error_report_err(), and
> > output other error to stdio?
> >
> > ---
> > There are some 'GENERIC ERROR CLASS' in qerror.h, which are not used
> > very frequently, we can convert them to 'QERR_INTERNAL_ERROR'.
> >
> > Or convert all 'GENERIC ERROR CLASS' to  'QERR_INTERNAL_ERROR',
> > and use a single human readable string?
> >
> > > Please help to review below RFC patch, thanks.
> >
> >
> Anthony, Luiz, other
> 
> any comments?
> 
> archive of this patch:
> http://lists.nongnu.org/archive/html/qemu-devel/2012-08/msg04927.html

That thread is too old, that work should be re-done on top of the new
error format.

However, we have bug 603266 for that and it has been assigned to me. And
I have started working on it already...

> 
> 
> > From 4b8200ce662dd375819fd24cb932e70131ce0bd3 Mon Sep 17 00:00:00 2001
> > > From: Amos Kong <akong@redhat.com>
> > > Date: Wed, 29 Aug 2012 22:52:48 +0800
> > > Subject: [PATCH RFC] qerror: introduce QERR_INTERNAL_ERROR
> > >
> > > Current qerror reporting infrastructure isn't agile,
> > > we have to add a new Class for a new error.
> > >
> > > This patch introduced a generic QERR_INTERNAL_ERROR
> > > that takes a single human readable string as an argument.
> > >
> > > This patch is a RFC, so I only changed some code of
> > > inet_connect() as an example.
> > >
> > > hmp:
> > > (qemu) migrate -d tcp:noname:4446
> > > migrate: Can't resolve noname:4446: Name or service not known
> > >
> > > qmp:
> > > { "execute": "migrate", "arguments": { "uri": "tcp:noname:4446" } }
> > > {"error": {"class": "GenericError", "desc": "Can't resolve noname:4446:
> > > Name or service not known"}}
> > >
> > > Signed-off-by: Amos Kong <akong@redhat.com>
> > > ---
> > >  qemu-sockets.c |    9 +++++----
> > >  qerror.h       |    3 +++
> > >  2 files changed, 8 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/qemu-sockets.c b/qemu-sockets.c
> > > index 361d890..e528288 100644
> > > --- a/qemu-sockets.c
> > > +++ b/qemu-sockets.c
> > > @@ -244,9 +244,9 @@ int inet_connect_opts(QemuOpts *opts, bool
> > > *in_progress, Error **errp)
> > >
> > >      /* lookup */
> > >      if (0 != (rc = getaddrinfo(addr, port, &ai, &res))) {
> > > -        fprintf(stderr,"getaddrinfo(%s,%s): %s\n", addr, port,
> > > -                gai_strerror(rc));
> > > -        error_set(errp, QERR_SOCKET_CREATE_FAILED);
> > > +        char err[50];
> > > +        sprintf(err, "Can't resolve %s:%s: %s", addr, port,
> > gai_strerror(rc));
> > > +        error_set(errp, QERR_INTERNAL_ERROR, err);
> > >         return -1;
> > >      }
> > >
> > > @@ -505,7 +505,8 @@ int inet_connect(const char *str, bool block, bool
> > > *in_progress, Error **errp)
> > >          }
> > >          sock = inet_connect_opts(opts, in_progress, errp);
> > >      } else {
> > > -        error_set(errp, QERR_SOCKET_CREATE_FAILED);
> > > +        error_set(errp, QERR_INTERNAL_ERROR,
> > > +                  "inet_connect: failed to parse address");
> > >      }
> > >      qemu_opts_del(opts);
> > >      return sock;
> > > diff --git a/qerror.h b/qerror.h
> > > index d0a76a4..97bf5e0 100644
> > > --- a/qerror.h
> > > +++ b/qerror.h
> > > @@ -246,4 +246,7 @@ void assert_no_error(Error *err);
> > >  #define QERR_SOCKET_CREATE_FAILED \
> > >      ERROR_CLASS_GENERIC_ERROR, "Failed to create socket"
> > >
> > > +#define QERR_INTERNAL_ERROR \
> > > +    ERROR_CLASS_GENERIC_ERROR, "%s"
> > > +
> > >  #endif /* QERROR_H */
> > > --
> > > 1.7.1
> > >
> > >
> > >
> > >>
> > >>
> > >> > I'll focus on applying the patches you mentioned.
> > >>
> > >> Suggest to reword the commit messages not to promise the parts you don't
> > >> apply.
> > >>
> > >> > While I admit that it seems counter intuitive to not want to improve
> > >> > error messages (and I fully admit, that this is an improvement), I'm
> > >> > more concerned that this digs us deeper into the
> > >> > qerror_report/error_report hole that we're trying to dig our way out
> > >> > of.
> > >> >
> > >> > If you want to add chardevs dynamically, then I assume your next patch
> > >>
> > >> Not a priority at this time, I'm afraid.  If it becomes one, I might be
> > >> able to work on it.
> > >>
> > >> > would be switching error_report to qerror_report such that the errors
> > >> > appeared in the monitor.  But this is wrong.  New QMP functions are
> > >> > not allowed to use qerror_report anymore.  So all of this code would
> > >> > need to get changed again anyway.
> > >>
> > >> No, the next step for errors would be error_report() -> error_set(),
> > >> precisely because qerror_report() can't be used anymore.
> > >>
> > >> Yes, that means the five files that report chardev open errors will need
> > >> to be touched again.  But that'll be a bog-standard error_report() ->
> > >> error_set() conversion.  Easier to code, test and review than combined
> > >> "track down all the error paths that fail to report errors, or report
> > >> non-sensical errors" + "convert from fprintf() to error_set() in one
> > >> go".
> > >>
> > >> In my opinion, the "have to touch five files again" developer burden
> > >> compares quite favorably with "have to check all the error paths again"
> > >> developer burden.  And in any case it's dwarved by the "have to use a
> > >> debugger to find out what's wrong" user burden.
> > >>
> > >> [...]
> > >>
> >

  reply	other threads:[~2012-09-05 18:51 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-07 14:09 [Qemu-devel] [PATCH 00/19] Fix and improve chardev open error messages Markus Armbruster
2012-02-07 14:09 ` [Qemu-devel] [PATCH 01/19] Revert "qemu-char: Print strerror message on failure" and deps Markus Armbruster
2012-02-07 15:06   ` Anthony Liguori
2012-02-07 14:09 ` [Qemu-devel] [PATCH 02/19] qemu-char: Use qemu_open() to avoid leaking fds to children Markus Armbruster
2012-02-07 15:07   ` Anthony Liguori
2012-02-07 14:09 ` [Qemu-devel] [PATCH 03/19] qemu-char: Re-apply style fixes from just reverted aad04cd0 Markus Armbruster
2012-02-07 15:07   ` Anthony Liguori
2012-02-07 14:09 ` [Qemu-devel] [PATCH 04/19] qemu-char: qemu_chr_open_fd() can't fail, don't check Markus Armbruster
2012-02-07 15:24   ` Anthony Liguori
2012-02-07 14:09 ` [Qemu-devel] [PATCH 05/19] vl.c: Error locations for options using add_device_config() Markus Armbruster
2012-02-07 14:09 ` [Qemu-devel] [PATCH 06/19] gdbstub: Error locations for -gdb Markus Armbruster
2012-02-07 15:32   ` Kevin Wolf
2012-02-09 15:08     ` Markus Armbruster
2012-02-07 14:09 ` [Qemu-devel] [PATCH 07/19] sockets: Drop sockets_debug debug code Markus Armbruster
2012-02-07 14:09 ` [Qemu-devel] [PATCH 08/19] sockets: Clean up inet_listen_opts()'s convoluted bind() loop Markus Armbruster
2012-02-07 14:09 ` [Qemu-devel] [PATCH 09/19] sockets: Chardev open error reporting, sockets part Markus Armbruster
2012-02-07 15:13   ` Anthony Liguori
2012-02-09 16:05     ` Markus Armbruster
2012-02-14 17:24       ` Markus Armbruster
2012-02-14 19:05         ` Anthony Liguori
2012-02-15 13:33           ` Markus Armbruster
2012-02-22 20:28             ` Anthony Liguori
2012-02-23  8:15               ` Markus Armbruster
2012-08-29 15:15                 ` Amos Kong
2012-08-29 16:04                   ` Amos Kong
2012-09-05  2:19                     ` Amos Kong
2012-09-05 18:52                       ` Luiz Capitulino [this message]
2012-02-07 14:09 ` [Qemu-devel] [PATCH 10/19] qemu-char: Chardev open error reporting, !_WIN32 part Markus Armbruster
2012-02-07 15:52   ` Kevin Wolf
2012-02-09 15:16     ` Markus Armbruster
2012-02-09 15:39       ` Kevin Wolf
2012-02-09 16:19         ` Markus Armbruster
2012-02-09 16:31           ` Luiz Capitulino
2012-02-09 17:08             ` Markus Armbruster
2012-02-07 14:09 ` [Qemu-devel] [PATCH 11/19] qemu-char: Chardev open error reporting, _WIN32 part Markus Armbruster
2012-02-07 14:09 ` [Qemu-devel] [PATCH 12/19] qemu-char: Chardev open error reporting, tty part Markus Armbruster
2012-02-07 14:09 ` [Qemu-devel] [PATCH 13/19] qemu-char: Chardev open error reporting, parport part Markus Armbruster
2012-02-07 14:09 ` [Qemu-devel] [PATCH 14/19] console: Eliminate text_consoles[] Markus Armbruster
2012-02-07 14:09 ` [Qemu-devel] [PATCH 15/19] console: Chardev open error reporting, console part Markus Armbruster
2012-02-07 14:09 ` [Qemu-devel] [PATCH 16/19] spice-qemu-char: Chardev open error reporting, spicevmc part Markus Armbruster
2012-02-07 14:09 ` [Qemu-devel] [PATCH 17/19] baum: Chardev open error reporting, braille part Markus Armbruster
2012-02-07 14:09 ` [Qemu-devel] [PATCH 18/19] qemu-char: Chardev open error reporting, generic part Markus Armbruster
2012-02-07 14:09 ` [Qemu-devel] [PATCH 19/19] qemu-char: Fix legacy chardev syntax error reporting Markus Armbruster
2012-02-07 16:05 ` [Qemu-devel] [PATCH 00/19] Fix and improve chardev open error messages Kevin Wolf
2012-02-24 15:30 ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120905155206.3635f034@doriath.home \
    --to=lcapitulino@redhat.com \
    --cc=akong@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=armbru@redhat.com \
    --cc=kongjianjun@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).