qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Peter Crosthwaite <crosthwaitepeter@gmail.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, armbru@redhat.com
Subject: Re: [Qemu-devel] [RFC PATCH v1 04/25] error: Add support for multiple errors
Date: Fri, 11 Sep 2015 09:49:43 -0600	[thread overview]
Message-ID: <55F2F817.3000601@redhat.com> (raw)
In-Reply-To: <19fff9b2e33050c340b1dc0fd5e0dbe4e11a31bf.1441667360.git.crosthwaite.peter@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4061 bytes --]

On 09/10/2015 11:33 PM, Peter Crosthwaite wrote:
> Allow errors to stack. If an error is already set, don't assert,
> instead, form a linked list. Recent errors are at the front of the
> list, older ones at the back.
> 
> The assertion against the destination erro already being set is

s/erro/error/

> removed.

Do we want to do that blindly, or do we want a design where users must
explicitly ask for nested errors?

I'm wondering aloud here: (haven't actually thought too hard, but typing
as I go)

Since your goal was reducing boilerplate, is there some way we could have:

myfunc1(..., error_add(errp));
myfunc2(..., error_add(errp));

be some way to mark errp as allowing error concatenation? That is,
error_add() would return errp; if *errp was NULL it does nothing
further, but *errp is non-NULL it then sets a flag in errp that it is
okay for further errors to be concatenated.  Then when setting or
propagating an error, we can use the flag within errp to determine if
the caller is okay with us appending to the existing error, or whether
there may be a programming error in that we are detecting a followup
error to an errp that wasn't properly cleared earlier.

Or maybe:

error_start_chaining(errp);
myfunc1(..., errp);
myfunc2(..., errp);
error_stop_chaining(errp);

where we use a counter of how many requests (since myfunc1() may itself
call nested start/stop, so chaining is okay if the counter is non-zero).

> 
> copy/free are all to call their functionality recursively.
> 
> Propagation is implemented as concatenation of two error lists.
> 
> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
> ---
> 
>  qapi/common.json |  5 ++++-
>  util/error.c     | 27 +++++++++++++++++++++------
>  2 files changed, 25 insertions(+), 7 deletions(-)
> 
> diff --git a/qapi/common.json b/qapi/common.json
> index bad56bf..04175db 100644
> --- a/qapi/common.json
> +++ b/qapi/common.json
> @@ -22,11 +22,14 @@
>  # @KVMMissingCap: the requested operation can't be fulfilled because a
>  #                 required KVM capability is missing
>  #
> +# @MultipleErrors: Multiple errors have occured

s/occured/occurred/

Missing a (since 2.5) designation.

Do we want to change the QMP wire format when multiple errors have been
chained together, to return a linked list or array of those errors, for
easier machine parsing of the individual errors?  If so, it requires
some documentation updates.  If not, packing the chained error
information into a single string is okay for humans, but not as nice for
computers.

> +#
>  # Since: 1.2
>  ##
>  { 'enum': 'ErrorClass',
>    'data': [ 'GenericError', 'CommandNotFound', 'DeviceEncrypted',
> -            'DeviceNotActive', 'DeviceNotFound', 'KVMMissingCap' ] }
> +            'DeviceNotActive', 'DeviceNotFound', 'KVMMissingCap',
> +            'MultipleErrors' ] }
>  
>  ##
>  # @VersionTriple
> diff --git a/util/error.c b/util/error.c
> index b93e5c8..890ce58 100644
> --- a/util/error.c
> +++ b/util/error.c
> @@ -18,28 +18,25 @@ struct Error
>  {
>      char *msg;
>      ErrorClass err_class;
> +    struct Error *next;
>  };

Merge conflicts in this area; but doesn't hold up review of the concept.

>  
>  Error *error_abort;
>  
>  static void do_error_set(Error **errp, ErrorClass err_class,
>                           void (*mod)(Error *, void *), void *mod_opaque,
> -                         const char *fmt, ...)
> +                         const char *fmt, va_list ap)
>  {
>      Error *err;
> -    va_list ap;
>      int saved_errno = errno;
>  
>      if (errp == NULL) {
>          return;
>      }
> -    assert(*errp == NULL);

Here's where I'm wondering if we can have some sort of flag to say
whether the caller was okay with error concatentation, in which case
this would be something like:

assert(!*errp || errp->chaining_okay);

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2015-09-11 15:49 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-11  5:33 [Qemu-devel] [RFC PATCH v1 00/25] error: Automatic error concatenation and prefixing Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 01/25] exec: convert error_report to error_report_err Peter Crosthwaite
2015-09-11 15:28   ` Eric Blake
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 02/25] s390x: virtio-ccw: Remove un-needed if guard Peter Crosthwaite
2015-09-11 15:28   ` Eric Blake
2015-09-14  7:09   ` Cornelia Huck
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 03/25] error: Factor out common error setter logic Peter Crosthwaite
2015-09-11 15:30   ` Eric Blake
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 04/25] error: Add support for multiple errors Peter Crosthwaite
2015-09-11 15:49   ` Eric Blake [this message]
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 05/25] error: Add error prefix API Peter Crosthwaite
2015-09-11 16:04   ` Eric Blake
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 06/25] error: Add error_printf_fn() Peter Crosthwaite
2015-09-11 16:10   ` Eric Blake
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 07/25] sysbus: mmio_map+mmio_get_region: ignore range OOB errors Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 08/25] memory: nop APIs when they have NULL arguments Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 09/25] qdev: gpio: Ignore unconnectable GPIOs Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 10/25] arm: xlnx-zynqmp: Update error API usages Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 11/25] arm: fsl-imx*: " Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 12/25] arm: netduino: " Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 13/25] arm: allwinner: " Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 14/25] arm: digic: " Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 15/25] cpu: arm: Remove un-needed error checking Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 16/25] ppc: Update error API usages Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 17/25] i386: pc: " Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 18/25] monitor: update " Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 19/25] qdev: Update " Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 20/25] block: " Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 21/25] tests: " Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 22/25] usb: bus: " Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 23/25] scsi: " Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 24/25] migration: savevm: " Peter Crosthwaite
2015-09-11  5:33 ` [Qemu-devel] [RFC PATCH v1 25/25] core: " Peter Crosthwaite
2015-09-11  6:42 ` [Qemu-devel] [RFC PATCH v1 00/25] error: Automatic error concatenation and prefixing Markus Armbruster
2015-09-11 15:53   ` Eric Blake
2015-09-11 15:27 ` Eric Blake

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=55F2F817.3000601@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=crosthwaitepeter@gmail.com \
    --cc=peter.maydell@linaro.org \
    --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).