[PATCH 6/7] balloon: Fix a misleading error message

Markus Armbruster posted 7 patches 1 year ago
Maintainers: Nicholas Piggin <npiggin@gmail.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, "Cédric Le Goater" <clg@kaod.org>, David Gibson <david@gibson.dropbear.id.au>, Harsh Prateek Bora <harshpb@linux.ibm.com>, "Dr. David Alan Gilbert" <dave@treblig.org>, Jason Wang <jasowang@redhat.com>, Michael Roth <michael.roth@amd.com>, Konstantin Kostiuk <kkostiuk@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, David Hildenbrand <david@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>
[PATCH 6/7] balloon: Fix a misleading error message
Posted by Markus Armbruster 1 year ago
The error message

    {"execute": "balloon", "arguments":{"value": -1}}
    {"error": {"class": "GenericError", "desc": "Parameter 'target' expects a size"}}

points to 'target' instead of 'value'.  Fix:

    {"error": {"class": "GenericError", "desc": "Parameter 'value' expects a size"}}

Root cause: qmp_balloon()'s parameter is named @target.  Rename it to
@value to match the QAPI schema.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 system/balloon.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/system/balloon.c b/system/balloon.c
index e0e8969a4b..fda7af832e 100644
--- a/system/balloon.c
+++ b/system/balloon.c
@@ -90,17 +90,17 @@ BalloonInfo *qmp_query_balloon(Error **errp)
     return info;
 }
 
-void qmp_balloon(int64_t target, Error **errp)
+void qmp_balloon(int64_t value, Error **errp)
 {
     if (!have_balloon(errp)) {
         return;
     }
 
-    if (target <= 0) {
-        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "target", "a size");
+    if (value <= 0) {
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "value", "a size");
         return;
     }
 
-    trace_balloon_event(balloon_opaque, target);
-    balloon_event_fn(balloon_opaque, target);
+    trace_balloon_event(balloon_opaque, value);
+    balloon_event_fn(balloon_opaque, value);
 }
-- 
2.41.0
Re: [PATCH 6/7] balloon: Fix a misleading error message
Posted by Mario Casquero 1 year ago
This patch has been successfully tested by QE. Start a VM with a
virtio-balloon device and resize it to an invalid value. Check in the
expected error message that now makes reference to 'value' instead of
'target'.

Tested-by: Mario Casquero <mcasquer@redhat.com>

On Tue, Oct 31, 2023 at 12:12 PM Markus Armbruster <armbru@redhat.com> wrote:
>
> The error message
>
>     {"execute": "balloon", "arguments":{"value": -1}}
>     {"error": {"class": "GenericError", "desc": "Parameter 'target' expects a size"}}
>
> points to 'target' instead of 'value'.  Fix:
>
>     {"error": {"class": "GenericError", "desc": "Parameter 'value' expects a size"}}
>
> Root cause: qmp_balloon()'s parameter is named @target.  Rename it to
> @value to match the QAPI schema.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  system/balloon.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/system/balloon.c b/system/balloon.c
> index e0e8969a4b..fda7af832e 100644
> --- a/system/balloon.c
> +++ b/system/balloon.c
> @@ -90,17 +90,17 @@ BalloonInfo *qmp_query_balloon(Error **errp)
>      return info;
>  }
>
> -void qmp_balloon(int64_t target, Error **errp)
> +void qmp_balloon(int64_t value, Error **errp)
>  {
>      if (!have_balloon(errp)) {
>          return;
>      }
>
> -    if (target <= 0) {
> -        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "target", "a size");
> +    if (value <= 0) {
> +        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "value", "a size");
>          return;
>      }
>
> -    trace_balloon_event(balloon_opaque, target);
> -    balloon_event_fn(balloon_opaque, target);
> +    trace_balloon_event(balloon_opaque, value);
> +    balloon_event_fn(balloon_opaque, value);
>  }
> --
> 2.41.0
>
>
Re: [PATCH 6/7] balloon: Fix a misleading error message
Posted by Michael S. Tsirkin 1 year ago
On Tue, Oct 31, 2023 at 12:10:58PM +0100, Markus Armbruster wrote:
> The error message
> 
>     {"execute": "balloon", "arguments":{"value": -1}}
>     {"error": {"class": "GenericError", "desc": "Parameter 'target' expects a size"}}
> 
> points to 'target' instead of 'value'.  Fix:
> 
>     {"error": {"class": "GenericError", "desc": "Parameter 'value' expects a size"}}
> 
> Root cause: qmp_balloon()'s parameter is named @target.  Rename it to
> @value to match the QAPI schema.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

feel free to merge

> ---
>  system/balloon.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/system/balloon.c b/system/balloon.c
> index e0e8969a4b..fda7af832e 100644
> --- a/system/balloon.c
> +++ b/system/balloon.c
> @@ -90,17 +90,17 @@ BalloonInfo *qmp_query_balloon(Error **errp)
>      return info;
>  }
>  
> -void qmp_balloon(int64_t target, Error **errp)
> +void qmp_balloon(int64_t value, Error **errp)
>  {
>      if (!have_balloon(errp)) {
>          return;
>      }
>  
> -    if (target <= 0) {
> -        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "target", "a size");
> +    if (value <= 0) {
> +        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "value", "a size");
>          return;
>      }
>  
> -    trace_balloon_event(balloon_opaque, target);
> -    balloon_event_fn(balloon_opaque, target);
> +    trace_balloon_event(balloon_opaque, value);
> +    balloon_event_fn(balloon_opaque, value);
>  }
> -- 
> 2.41.0