All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: Fix block-set-write-threshold not to use funky error class
@ 2015-03-13 17:51 Markus Armbruster
  2015-03-13 19:11 ` Eric Blake
  2015-03-16 15:04 ` Kevin Wolf
  0 siblings, 2 replies; 4+ messages in thread
From: Markus Armbruster @ 2015-03-13 17:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, fromani, stefanha, qemu-block

Error classes are a leftover from the days of "rich" error objects.
New code should always use ERROR_CLASS_GENERIC_ERROR.  Commit e246211
added a use of ERROR_CLASS_DEVICE_NOT_FOUND.  Replace it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 block/write-threshold.c | 2 +-
 qapi/block-core.json    | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/block/write-threshold.c b/block/write-threshold.c
index c2cd517..a53c1f5 100644
--- a/block/write-threshold.c
+++ b/block/write-threshold.c
@@ -112,7 +112,7 @@ void qmp_block_set_write_threshold(const char *node_name,
 
     bs = bdrv_find_node(node_name);
     if (!bs) {
-        error_set(errp, QERR_DEVICE_NOT_FOUND, node_name);
+        error_setg(errp, "Device '%s' not found", node_name);
         return;
     }
 
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 90586a5..42c8850 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1961,10 +1961,6 @@
 # @write-threshold: configured threshold for the block device, bytes.
 #                   Use 0 to disable the threshold.
 #
-# Returns: Nothing on success
-#          If @node name is not found on the block device graph,
-#          DeviceNotFound
-#
 # Since: 2.3
 ##
 { 'command': 'block-set-write-threshold',
-- 
1.9.3

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

* Re: [Qemu-devel] [PATCH] block: Fix block-set-write-threshold not to use funky error class
  2015-03-13 17:51 [Qemu-devel] [PATCH] block: Fix block-set-write-threshold not to use funky error class Markus Armbruster
@ 2015-03-13 19:11 ` Eric Blake
  2015-03-13 20:17   ` Markus Armbruster
  2015-03-16 15:04 ` Kevin Wolf
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Blake @ 2015-03-13 19:11 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kwolf, fromani, stefanha, qemu-block

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

On 03/13/2015 11:51 AM, Markus Armbruster wrote:
> Error classes are a leftover from the days of "rich" error objects.
> New code should always use ERROR_CLASS_GENERIC_ERROR.

More precisely, new code should use ERROR_CLASS_GENERIC_ERROR unless
there is a good reason where a caller knowing a different error class is
likely to react differently as a result (for example, with
'drive-mirror', libvirt DOES rely on QERR_DEVICE_NOT_FOUND as a witness
that the command supports an optional 'top' argument, vs.
ERROR_CLASS_GENERIC_ERROR to state that 'top' was still mandatory).

But I agree that this situation is one unlikely to be where libvirt
cares what error class was used.

>  Commit e246211
> added a use of ERROR_CLASS_DEVICE_NOT_FOUND.  Replace it.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  block/write-threshold.c | 2 +-
>  qapi/block-core.json    | 4 ----
>  2 files changed, 1 insertion(+), 5 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
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 --]

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

* Re: [Qemu-devel] [PATCH] block: Fix block-set-write-threshold not to use funky error class
  2015-03-13 19:11 ` Eric Blake
@ 2015-03-13 20:17   ` Markus Armbruster
  0 siblings, 0 replies; 4+ messages in thread
From: Markus Armbruster @ 2015-03-13 20:17 UTC (permalink / raw)
  To: Eric Blake; +Cc: kwolf, fromani, qemu-block, qemu-devel, stefanha

Eric Blake <eblake@redhat.com> writes:

> On 03/13/2015 11:51 AM, Markus Armbruster wrote:
>> Error classes are a leftover from the days of "rich" error objects.
>> New code should always use ERROR_CLASS_GENERIC_ERROR.
>
> More precisely, new code should use ERROR_CLASS_GENERIC_ERROR unless
> there is a good reason where a caller knowing a different error class is
> likely to react differently as a result (for example, with
> 'drive-mirror', libvirt DOES rely on QERR_DEVICE_NOT_FOUND as a witness
> that the command supports an optional 'top' argument, vs.
> ERROR_CLASS_GENERIC_ERROR to state that 'top' was still mandatory).

In my experience, a caller / client wanting to figure out what exactly
failed is often a sign of a function / command trying to do too much at
once.

Using error classes to introspect is trickery, committed out of
desperation.  We should offer proper introspection instead.

That said, "always" is rather strong language.  No rule without
exceptions.  If it bothers you, perhaps the word can be dropped on
commit.

> But I agree that this situation is one unlikely to be where libvirt
> cares what error class was used.
>
>>  Commit e246211
>> added a use of ERROR_CLASS_DEVICE_NOT_FOUND.  Replace it.
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  block/write-threshold.c | 2 +-
>>  qapi/block-core.json    | 4 ----
>>  2 files changed, 1 insertion(+), 5 deletions(-)
>
> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks!

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

* Re: [Qemu-devel] [PATCH] block: Fix block-set-write-threshold not to use funky error class
  2015-03-13 17:51 [Qemu-devel] [PATCH] block: Fix block-set-write-threshold not to use funky error class Markus Armbruster
  2015-03-13 19:11 ` Eric Blake
@ 2015-03-16 15:04 ` Kevin Wolf
  1 sibling, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2015-03-16 15:04 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: stefanha, qemu-devel, qemu-block, fromani

Am 13.03.2015 um 18:51 hat Markus Armbruster geschrieben:
> Error classes are a leftover from the days of "rich" error objects.
> New code should always use ERROR_CLASS_GENERIC_ERROR.  Commit e246211
> added a use of ERROR_CLASS_DEVICE_NOT_FOUND.  Replace it.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Thanks, applied to the block branch.

Kevin

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

end of thread, other threads:[~2015-03-16 15:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-13 17:51 [Qemu-devel] [PATCH] block: Fix block-set-write-threshold not to use funky error class Markus Armbruster
2015-03-13 19:11 ` Eric Blake
2015-03-13 20:17   ` Markus Armbruster
2015-03-16 15:04 ` Kevin Wolf

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.