blockjob: Fix error message for negative speed
diff mbox series

Message ID 20191126134222.16340-1-kwolf@redhat.com
State New
Headers show
Series
  • blockjob: Fix error message for negative speed
Related show

Commit Message

Kevin Wolf Nov. 26, 2019, 1:42 p.m. UTC
The error message for a negative speed uses QERR_INVALID_PARAMETER,
which implies that the 'speed' option doesn't even exist:

    {"error": {"class": "GenericError", "desc": "Invalid parameter 'speed'"}}

Make it use QERR_INVALID_PARAMETER_VALUE instead:

    {"error": {"class": "GenericError", "desc": "Parameter 'speed' expects a non-negative value"}}

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 blockjob.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Alberto Garcia Nov. 26, 2019, 1:44 p.m. UTC | #1
On Tue 26 Nov 2019 02:42:22 PM CET, Kevin Wolf wrote:
> The error message for a negative speed uses QERR_INVALID_PARAMETER,
> which implies that the 'speed' option doesn't even exist:
>
>     {"error": {"class": "GenericError", "desc": "Invalid parameter 'speed'"}}
>
> Make it use QERR_INVALID_PARAMETER_VALUE instead:
>
>     {"error": {"class": "GenericError", "desc": "Parameter 'speed' expects a non-negative value"}}
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto
Max Reitz Dec. 17, 2019, 1:34 p.m. UTC | #2
On 26.11.19 14:42, Kevin Wolf wrote:
> The error message for a negative speed uses QERR_INVALID_PARAMETER,
> which implies that the 'speed' option doesn't even exist:
> 
>     {"error": {"class": "GenericError", "desc": "Invalid parameter 'speed'"}}
> 
> Make it use QERR_INVALID_PARAMETER_VALUE instead:
> 
>     {"error": {"class": "GenericError", "desc": "Parameter 'speed' expects a non-negative value"}}
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  blockjob.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

This needs an update to iotest 030.

Max

Patch
diff mbox series

diff --git a/blockjob.c b/blockjob.c
index c6e20e2fcd..5d63b1e89d 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -261,7 +261,8 @@  void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
         return;
     }
     if (speed < 0) {
-        error_setg(errp, QERR_INVALID_PARAMETER, "speed");
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed",
+                   "a non-negative value");
         return;
     }