All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>, "Jiri Pirko" <jiri@resnulli.us>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"open list:Block layer core" <qemu-block@nongnu.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	qemu-devel@nongnu.org, "Scott Feldman" <sfeldma@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"Richard Henderson" <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v11 18/28] qerror: more error_setg() usage
Date: Wed, 11 Nov 2015 15:21:46 +0100	[thread overview]
Message-ID: <87si4cboqt.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <1447224690-9743-19-git-send-email-eblake@redhat.com> (Eric Blake's message of "Tue, 10 Nov 2015 23:51:20 -0700")

Eric Blake <eblake@redhat.com> writes:

> A few uses of error_set(ERROR_CLASS_GENERIC_ERROR) have snuck in
> since c6bd8c706.  Nuke them.

Doesn't really belong to this series, but that's okay.

> Signed-off-by: Eric Blake <eblake@redhat.com>
>
> ---
> v11: new patch
> ---
>  block.c                       |  3 +--
>  docs/writing-qmp-commands.txt | 20 +++++++++-----------
>  hw/i386/pc.c                  |  2 +-
>  hw/net/rocker/rocker.c        |  6 ++----
>  hw/net/rocker/rocker_of_dpa.c | 12 ++++--------
>  qom/object.c                  |  4 ++--
>  6 files changed, 19 insertions(+), 28 deletions(-)
>
> diff --git a/block.c b/block.c
> index e9f40dc..53a978a 100644
> --- a/block.c
> +++ b/block.c
> @@ -1795,8 +1795,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
>
>      ret = bdrv_flush(reopen_state->bs);
>      if (ret) {
> -        error_set(errp, ERROR_CLASS_GENERIC_ERROR, "Error (%s) flushing drive",
> -                  strerror(-ret));
> +        error_setg_errno(errp, -ret, "Error flushing drive");
>          goto error;
>      }
>
> diff --git a/docs/writing-qmp-commands.txt b/docs/writing-qmp-commands.txt
> index 8647cac..59aa77a 100644
> --- a/docs/writing-qmp-commands.txt
> +++ b/docs/writing-qmp-commands.txt
> @@ -210,7 +210,7 @@ if you don't see these strings, then something went wrong.
>  === Errors ===
>
>  QMP commands should use the error interface exported by the error.h header
> -file. Basically, errors are set by calling the error_set() function.
> +file. Basically, most errors are set by calling the error_setg() function.
>
>  Let's say we don't accept the string "message" to contain the word "love". If
>  it does contain it, we want the "hello-world" command to return an error:
> @@ -219,8 +219,7 @@ void qmp_hello_world(bool has_message, const char *message, Error **errp)
>  {
>      if (has_message) {
>          if (strstr(message, "love")) {
> -            error_set(errp, ERROR_CLASS_GENERIC_ERROR,
> -                      "the word 'love' is not allowed");
> +            error_setg(errp, "the word 'love' is not allowed");
>              return;
>          }
>          printf("%s\n", message);
> @@ -229,10 +228,8 @@ void qmp_hello_world(bool has_message, const char *message, Error **errp)
>      }
>  }
>
> -The first argument to the error_set() function is the Error pointer to pointer,
> -which is passed to all QMP functions. The second argument is a ErrorClass
> -value, which should be ERROR_CLASS_GENERIC_ERROR most of the time (more
> -details about error classes are given below). The third argument is a human
> +The first argument to the error_setg() function is the Error pointer
> +to pointer, which is passed to all QMP functions. The next argument is a human
>  description of the error, this is a free-form printf-like string.
>
>  Let's test the example above. Build qemu, run it as defined in the "Testing"
> @@ -249,8 +246,9 @@ The QMP server's response should be:
>      }
>  }
>
> -As a general rule, all QMP errors should use ERROR_CLASS_GENERIC_ERROR. There
> -are two exceptions to this rule:
> +As a general rule, all QMP errors should use ERROR_CLASS_GENERIC_ERROR
> +(done by default when using error_setg()). There are two exceptions to
> +this rule:
>
>   1. A non-generic ErrorClass value exists* for the failure you want to report
>      (eg. DeviceNotFound)
> @@ -259,8 +257,8 @@ are two exceptions to this rule:
>      want to report, hence you have to add a new ErrorClass value so that they
>      can check for it
>
> -If the failure you want to report doesn't fall in one of the two cases above,
> -just report ERROR_CLASS_GENERIC_ERROR.
> +If the failure you want to report falls into one of the two cases above,
> +use error_set() with a second argument of an ErrorClass value.
>
>   * All existing ErrorClass values are defined in the qapi-schema.json file
>

Thanks a lot for this doc update!

> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 0cb8afd..dfb57a8 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1795,7 +1795,7 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
>          return;
>      }
>      if (value > (1ULL << 32)) {
> -        error_set(&error, ERROR_CLASS_GENERIC_ERROR,
> +        error_setg(&error,
>                    "Machine option 'max-ram-below-4g=%"PRIu64
>                    "' expects size less than or equal to 4G", value);

Indentation is now off.  Can tidy up in my tree.

>          error_propagate(errp, error);
[Rest snipped, it looks good]

  parent reply	other threads:[~2015-11-11 14:21 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-11  6:51 [Qemu-devel] [PATCH v11 00/28] qapi member collision, alternate layout (post-introspection cleanups, subset D) Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 01/28] qapi: Track simple union tag in object.local_members Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 02/28] qapi-types: Consolidate gen_struct() and gen_union() Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 03/28] qapi-types: Simplify gen_struct_field[s] Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 04/28] qapi: Drop obsolete tag value collision assertions Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 05/28] qapi: Simplify QAPISchemaObjectTypeMember.check() Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 06/28] qapi: Clean up after previous commit Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 07/28] qapi: Fix up commit 7618b91's clash sanity checking change Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 08/28] qapi: Eliminate QAPISchemaObjectType.check() variable members Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 09/28] qapi: Factor out QAPISchemaObjectTypeMember.check_clash() Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 10/28] qapi: Simplify QAPISchemaObjectTypeVariants.check() Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 11/28] qapi: Check for qapi collisions of flat union branches Eric Blake
2015-11-11 13:42   ` Markus Armbruster
2015-11-11 15:49     ` Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 12/28] qapi: Factor out QAPISchemaObjectType.check_clash() Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 13/28] qapi: Hoist tag collision check to Variants.check() Eric Blake
2015-11-11 13:56   ` Markus Armbruster
2015-11-11 16:11     ` Eric Blake
2015-11-11 17:03       ` Markus Armbruster
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 14/28] qapi: Remove outdated tests related to QMP/branch collisions Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 15/28] qapi: Track owner of each object member Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 16/28] qapi: Detect collisions in C member names Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 17/28] cpu: Convert CpuInfo into flat union Eric Blake
2015-11-11 14:13   ` Markus Armbruster
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 18/28] qerror: more error_setg() usage Eric Blake
2015-11-11 13:26   ` Andreas Färber
2015-11-11 14:21   ` Markus Armbruster [this message]
2015-11-11 14:23     ` Andreas Färber
2015-11-11 15:51       ` Eric Blake
2015-11-11 16:19     ` Eric Blake
2015-11-11 17:31       ` Markus Armbruster
2015-11-11 17:44         ` Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 19/28] qapi: Change munging of CamelCase enum values Eric Blake
2015-11-11 13:29   ` Andreas Färber
2015-11-11 14:50   ` Markus Armbruster
2015-11-11 16:03     ` Eric Blake
2015-11-11 17:11       ` Markus Armbruster
2015-11-12  8:34         ` Gerd Hoffmann
2015-11-12 11:16           ` Markus Armbruster
2015-11-12  8:29       ` Gerd Hoffmann
2015-11-11 16:06     ` Eric Blake
2015-11-13 17:46   ` Eric Blake
2015-11-13 18:13     ` Markus Armbruster
2015-11-13 21:37       ` Eric Blake
2015-11-16 14:30         ` Markus Armbruster
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 20/28] qapi: Forbid case-insensitive clashes Eric Blake
2015-11-11 14:53   ` Markus Armbruster
2015-11-13  5:32     ` Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 21/28] qapi: Convert qtype_code into qapi enum type Eric Blake
2015-11-11 16:42   ` Markus Armbruster
2015-11-11 17:03     ` Eric Blake
2015-11-12 13:16       ` Markus Armbruster
2015-11-18  6:27         ` Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 22/28] qapi: Simplify visiting of alternate types Eric Blake
2015-11-12 14:21   ` Markus Armbruster
2015-11-12 15:54   ` Markus Armbruster
2015-11-13 23:54   ` Eric Blake
2015-11-16 14:31     ` Markus Armbruster
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 23/28] qapi: Fix alternates that accept 'number' but not 'int' Eric Blake
2015-11-12 15:01   ` Markus Armbruster
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 24/28] qapi: Add positive tests to qapi-schema-test Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 25/28] qapi: Simplify visits of optional fields Eric Blake
2015-11-12 15:11   ` Markus Armbruster
2015-11-12 15:30     ` Eric Blake
2015-11-12 16:20       ` Markus Armbruster
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 26/28] qapi: Move duplicate member checks to schema check() Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 27/28] qapi: Move duplicate enum value " Eric Blake
2015-11-12 15:46   ` Markus Armbruster
2015-11-12 16:08     ` Eric Blake
2015-11-18  6:48     ` Eric Blake
2015-11-11  6:51 ` [Qemu-devel] [PATCH v11 28/28] qapi: Detect base class loops Eric Blake
2015-11-12 16:06   ` Markus Armbruster

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=87si4cboqt.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=afaerber@suse.de \
    --cc=eblake@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=sfeldma@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.