All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL v2 0/1] error: More error_setg() usage
@ 2015-11-11 17:59 Markus Armbruster
  2015-11-11 17:59 ` [Qemu-devel] [PULL v2 1/1] " Markus Armbruster
  2015-11-12 10:28 ` [Qemu-devel] [PULL v2 0/1] " Peter Maydell
  0 siblings, 2 replies; 5+ messages in thread
From: Markus Armbruster @ 2015-11-11 17:59 UTC (permalink / raw)
  To: qemu-devel

v2: Indentation touched up

The following changes since commit 3c07587d49458341510360557c849e93e9afaf59:

  Merge remote-tracking branch 'remotes/dgibson/tags/ppc-next-20151111' into staging (2015-11-11 09:34:18 +0000)

are available in the git repository at:

  git://repo.or.cz/qemu/armbru.git tags/pull-error-2015-11-11

for you to fetch changes up to 455b0fde8c38a0794743e2e7c1a40018b7bee9f6:

  error: More error_setg() usage (2015-11-11 18:56:26 +0100)

----------------------------------------------------------------
error: More error_setg() usage

----------------------------------------------------------------
Eric Blake (1):
      error: More error_setg() usage

 block.c                       |  3 +--
 docs/writing-qmp-commands.txt | 20 +++++++++-----------
 hw/i386/pc.c                  |  6 +++---
 hw/net/rocker/rocker.c        |  6 ++----
 hw/net/rocker/rocker_of_dpa.c | 12 ++++--------
 qom/object.c                  |  4 ++--
 6 files changed, 21 insertions(+), 30 deletions(-)

Eric Blake (1):
  error: More error_setg() usage

 block.c                       |  3 +--
 docs/writing-qmp-commands.txt | 20 +++++++++-----------
 hw/i386/pc.c                  |  6 +++---
 hw/net/rocker/rocker.c        |  6 ++----
 hw/net/rocker/rocker_of_dpa.c | 12 ++++--------
 qom/object.c                  |  4 ++--
 6 files changed, 21 insertions(+), 30 deletions(-)

-- 
2.4.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PULL v2 1/1] error: More error_setg() usage
  2015-11-11 17:59 [Qemu-devel] [PULL v2 0/1] error: More error_setg() usage Markus Armbruster
@ 2015-11-11 17:59 ` Markus Armbruster
  2015-11-12 10:28 ` [Qemu-devel] [PULL v2 0/1] " Peter Maydell
  1 sibling, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2015-11-11 17:59 UTC (permalink / raw)
  To: qemu-devel

From: Eric Blake <eblake@redhat.com>

A few uses of error_set(ERROR_CLASS_GENERIC_ERROR) were missed in
c6bd8c706, or have snuck in since.  Nuke them.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447224690-9743-19-git-send-email-eblake@redhat.com>
Acked-by: Andreas Färber <afaerber@suse.de>
[Indentation tidied up, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 block.c                       |  3 +--
 docs/writing-qmp-commands.txt | 20 +++++++++-----------
 hw/i386/pc.c                  |  6 +++---
 hw/net/rocker/rocker.c        |  6 ++----
 hw/net/rocker/rocker_of_dpa.c | 12 ++++--------
 qom/object.c                  |  4 ++--
 6 files changed, 21 insertions(+), 30 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
 
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 0cb8afd..5e20e07 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1795,9 +1795,9 @@ 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,
-                  "Machine option 'max-ram-below-4g=%"PRIu64
-                  "' expects size less than or equal to 4G", value);
+        error_setg(&error,
+                   "Machine option 'max-ram-below-4g=%"PRIu64
+                   "' expects size less than or equal to 4G", value);
         error_propagate(errp, error);
         return;
     }
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
index bb6fdc3..c57f1a6 100644
--- a/hw/net/rocker/rocker.c
+++ b/hw/net/rocker/rocker.c
@@ -101,8 +101,7 @@ RockerSwitch *qmp_query_rocker(const char *name, Error **errp)
 
     r = rocker_find(name);
     if (!r) {
-        error_set(errp, ERROR_CLASS_GENERIC_ERROR,
-                  "rocker %s not found", name);
+        error_setg(errp, "rocker %s not found", name);
         return NULL;
     }
 
@@ -122,8 +121,7 @@ RockerPortList *qmp_query_rocker_ports(const char *name, Error **errp)
 
     r = rocker_find(name);
     if (!r) {
-        error_set(errp, ERROR_CLASS_GENERIC_ERROR,
-                  "rocker %s not found", name);
+        error_setg(errp, "rocker %s not found", name);
         return NULL;
     }
 
diff --git a/hw/net/rocker/rocker_of_dpa.c b/hw/net/rocker/rocker_of_dpa.c
index 1ad2791..3cf1d61 100644
--- a/hw/net/rocker/rocker_of_dpa.c
+++ b/hw/net/rocker/rocker_of_dpa.c
@@ -2462,15 +2462,13 @@ RockerOfDpaFlowList *qmp_query_rocker_of_dpa_flows(const char *name,
 
     r = rocker_find(name);
     if (!r) {
-        error_set(errp, ERROR_CLASS_GENERIC_ERROR,
-                  "rocker %s not found", name);
+        error_setg(errp, "rocker %s not found", name);
         return NULL;
     }
 
     w = rocker_get_world(r, ROCKER_WORLD_TYPE_OF_DPA);
     if (!w) {
-        error_set(errp, ERROR_CLASS_GENERIC_ERROR,
-                  "rocker %s doesn't have OF-DPA world", name);
+        error_setg(errp, "rocker %s doesn't have OF-DPA world", name);
         return NULL;
     }
 
@@ -2597,15 +2595,13 @@ RockerOfDpaGroupList *qmp_query_rocker_of_dpa_groups(const char *name,
 
     r = rocker_find(name);
     if (!r) {
-        error_set(errp, ERROR_CLASS_GENERIC_ERROR,
-                  "rocker %s not found", name);
+        error_setg(errp, "rocker %s not found", name);
         return NULL;
     }
 
     w = rocker_get_world(r, ROCKER_WORLD_TYPE_OF_DPA);
     if (!w) {
-        error_set(errp, ERROR_CLASS_GENERIC_ERROR,
-                  "rocker %s doesn't have OF-DPA world", name);
+        error_setg(errp, "rocker %s doesn't have OF-DPA world", name);
         return NULL;
     }
 
diff --git a/qom/object.c b/qom/object.c
index fc6e161..c0decb6 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1330,8 +1330,8 @@ static Object *object_resolve_link(Object *obj, const char *name,
     target = object_resolve_path_type(path, target_type, &ambiguous);
 
     if (ambiguous) {
-        error_set(errp, ERROR_CLASS_GENERIC_ERROR,
-                  "Path '%s' does not uniquely identify an object", path);
+        error_setg(errp, "Path '%s' does not uniquely identify an object",
+                   path);
     } else if (!target) {
         target = object_resolve_path(path, &ambiguous);
         if (target || ambiguous) {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PULL v2 0/1] error: More error_setg() usage
  2015-11-11 17:59 [Qemu-devel] [PULL v2 0/1] error: More error_setg() usage Markus Armbruster
  2015-11-11 17:59 ` [Qemu-devel] [PULL v2 1/1] " Markus Armbruster
@ 2015-11-12 10:28 ` Peter Maydell
  2015-11-12 10:38   ` Peter Maydell
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2015-11-12 10:28 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU Developers

On 11 November 2015 at 17:59, Markus Armbruster <armbru@redhat.com> wrote:
> v2: Indentation touched up
>
> The following changes since commit 3c07587d49458341510360557c849e93e9afaf59:
>
>   Merge remote-tracking branch 'remotes/dgibson/tags/ppc-next-20151111' into staging (2015-11-11 09:34:18 +0000)
>
> are available in the git repository at:
>
>   git://repo.or.cz/qemu/armbru.git tags/pull-error-2015-11-11
>
> for you to fetch changes up to 455b0fde8c38a0794743e2e7c1a40018b7bee9f6:
>
>   error: More error_setg() usage (2015-11-11 18:56:26 +0100)
>
> ----------------------------------------------------------------
> error: More error_setg() usage
>
> ----------------------------------------------------------------
> Eric Blake (1):
>       error: More error_setg() usage
>
>  block.c                       |  3 +--
>  docs/writing-qmp-commands.txt | 20 +++++++++-----------
>  hw/i386/pc.c                  |  6 +++---
>  hw/net/rocker/rocker.c        |  6 ++----
>  hw/net/rocker/rocker_of_dpa.c | 12 ++++--------
>  qom/object.c                  |  4 ++--
>  6 files changed, 21 insertions(+), 30 deletions(-)
>
> Eric Blake (1):
>   error: More error_setg() usage


Not clear whether this is the fault of these patches, but I get
'make check' failures on OSX:

GTESTER check-qtest-x86_64
blkdebug: Suspended request 'A'
blkdebug: Resuming request 'A'
qemu: qemu_mutex_lock: Invalid argument
Broken pipe
qemu-system-x86_64: Not a migration stream
qemu-system-x86_64: load of migration failed: Invalid argument
GTester: last random seed: R02Sfbfcf20abd428e92977792ecfb04e311
qemu: qemu_mutex_lock: Invalid argument
Broken pipe
qemu-system-x86_64: Not a migration stream
qemu-system-x86_64: load of migration failed: Invalid argument
GTester: last random seed: R02Sbc275d87280c5e0eda57526587e420e4
qemu: qemu_mutex_lock: Invalid argument
Broken pipe
qemu-system-x86_64: Not a migration stream
qemu-system-x86_64: load of migration failed: Invalid argument
GTester: last random seed: R02S55750416b970f9148f3a7f8b815fb4bb
qemu: qemu_mutex_lock: Invalid argument
Broken pipe
qemu-system-x86_64: Not a migration stream
qemu-system-x86_64: load of migration failed: Invalid argument
GTester: last random seed: R02Se63079ce2611c8d190cd8a8e977115b2
qemu: qemu_mutex_lock: Invalid argument
qemu-system-x86_64:Broken pipe
 Not a migration stream
qemu-system-x86_64: load of migration failed: Invalid argument
GTester: last random seed: R02S1fe6070267b9d10875b202681749a522
qemu: qemu_mutex_lock: Invalid argument
Broken pipe
qemu-system-x86_64: Not a migration stream
qemu-system-x86_64: load of migration failed: Invalid argument
GTester: last random seed: R02S0016ce2e45736aa3a77c29dac76ded01
[vmxnet3][WR][vmxnet3_peer_has_vnet_hdr]: Peer has no virtio
extension. Task offloads will be emulated.


thanks
-- PMM

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PULL v2 0/1] error: More error_setg() usage
  2015-11-12 10:28 ` [Qemu-devel] [PULL v2 0/1] " Peter Maydell
@ 2015-11-12 10:38   ` Peter Maydell
  2015-11-12 11:55     ` Peter Maydell
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2015-11-12 10:38 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU Developers

On 12 November 2015 at 10:28, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 11 November 2015 at 17:59, Markus Armbruster <armbru@redhat.com> wrote:
>> v2: Indentation touched up
>>
>> The following changes since commit 3c07587d49458341510360557c849e93e9afaf59:
>>
>>   Merge remote-tracking branch 'remotes/dgibson/tags/ppc-next-20151111' into staging (2015-11-11 09:34:18 +0000)
>>
>> are available in the git repository at:
>>
>>   git://repo.or.cz/qemu/armbru.git tags/pull-error-2015-11-11
>>
>> for you to fetch changes up to 455b0fde8c38a0794743e2e7c1a40018b7bee9f6:
>>
>>   error: More error_setg() usage (2015-11-11 18:56:26 +0100)
>>
>> ----------------------------------------------------------------
>> error: More error_setg() usage
>>
>> ----------------------------------------------------------------
>> Eric Blake (1):
>>       error: More error_setg() usage
>>
>>  block.c                       |  3 +--
>>  docs/writing-qmp-commands.txt | 20 +++++++++-----------
>>  hw/i386/pc.c                  |  6 +++---
>>  hw/net/rocker/rocker.c        |  6 ++----
>>  hw/net/rocker/rocker_of_dpa.c | 12 ++++--------
>>  qom/object.c                  |  4 ++--
>>  6 files changed, 21 insertions(+), 30 deletions(-)
>>
>> Eric Blake (1):
>>   error: More error_setg() usage
>
>
> Not clear whether this is the fault of these patches, but I get
> 'make check' failures on OSX:

...almost certainly not these patches. For some reason these
don't actually cause 'make check' to return non-zero, and
my "grep logs for warning/error etc" workflow wouldn't catch
them. I just happened to look at this log by hand.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PULL v2 0/1] error: More error_setg() usage
  2015-11-12 10:38   ` Peter Maydell
@ 2015-11-12 11:55     ` Peter Maydell
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2015-11-12 11:55 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU Developers

On 12 November 2015 at 10:38, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 12 November 2015 at 10:28, Peter Maydell <peter.maydell@linaro.org> wrote:
>> On 11 November 2015 at 17:59, Markus Armbruster <armbru@redhat.com> wrote:
>>> v2: Indentation touched up
>>>
>>> The following changes since commit 3c07587d49458341510360557c849e93e9afaf59:
>>>
>>>   Merge remote-tracking branch 'remotes/dgibson/tags/ppc-next-20151111' into staging (2015-11-11 09:34:18 +0000)
>>>
>>> are available in the git repository at:
>>>
>>>   git://repo.or.cz/qemu/armbru.git tags/pull-error-2015-11-11
>>>
>>> for you to fetch changes up to 455b0fde8c38a0794743e2e7c1a40018b7bee9f6:
>>>
>>>   error: More error_setg() usage (2015-11-11 18:56:26 +0100)
>>>
>>> ----------------------------------------------------------------
>>> error: More error_setg() usage
>>>
>>> ----------------------------------------------------------------
>>> Eric Blake (1):
>>>       error: More error_setg() usage
>>>
>>>  block.c                       |  3 +--
>>>  docs/writing-qmp-commands.txt | 20 +++++++++-----------
>>>  hw/i386/pc.c                  |  6 +++---
>>>  hw/net/rocker/rocker.c        |  6 ++----
>>>  hw/net/rocker/rocker_of_dpa.c | 12 ++++--------
>>>  qom/object.c                  |  4 ++--
>>>  6 files changed, 21 insertions(+), 30 deletions(-)
>>>
>>> Eric Blake (1):
>>>   error: More error_setg() usage
>>
>>
>> Not clear whether this is the fault of these patches, but I get
>> 'make check' failures on OSX:
>
> ...almost certainly not these patches. For some reason these
> don't actually cause 'make check' to return non-zero, and
> my "grep logs for warning/error etc" workflow wouldn't catch
> them. I just happened to look at this log by hand.

Tracked the failure down to something in the migration pull.
Since that's already in master and we have rc0 scheduled for today
I'm going to keep applying pullreqs for now.

Applied this one to master, thanks.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-12 11:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-11 17:59 [Qemu-devel] [PULL v2 0/1] error: More error_setg() usage Markus Armbruster
2015-11-11 17:59 ` [Qemu-devel] [PULL v2 1/1] " Markus Armbruster
2015-11-12 10:28 ` [Qemu-devel] [PULL v2 0/1] " Peter Maydell
2015-11-12 10:38   ` Peter Maydell
2015-11-12 11:55     ` Peter Maydell

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.