diff mbox

[v4,08/29] qmp: improve error reporting for -object and object-add

Message ID dce8cb1156be24a1030d8385951def731c19442e.1402299637.git.hutao@cn.fujitsu.com
State New
Headers show

Commit Message

Hu Tao June 9, 2014, 10:25 a.m. UTC
From: Paolo Bonzini <pbonzini@redhat.com>

Use QERR_INVALID_PARAMETER_VALUE for consistency.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qmp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Igor Mammedov June 9, 2014, 3:57 p.m. UTC | #1
On Mon, 9 Jun 2014 18:25:13 +0800
Hu Tao <hutao@cn.fujitsu.com> wrote:

> From: Paolo Bonzini <pbonzini@redhat.com>
> 
> Use QERR_INVALID_PARAMETER_VALUE for consistency.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  qmp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/qmp.c b/qmp.c
> index b722dbe..cef60fb 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -540,7 +540,8 @@ void object_add(const char *type, const char *id, const QDict *qdict,
>  
>      klass = object_class_by_name(type);
>      if (!klass) {
> -        error_setg(errp, "invalid class name");
> +        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
> +                  "qom-type", "a valid class name");
With implicit "qom-type" on CLI it might be not clear to user what value is
wrong. Perhaps following would be better:

error_setg(errp, "Invalid object type name: %s", type);
 
>          return;
>      }
>  
> -- 
> 1.9.3
>
Hu Tao June 10, 2014, 2:07 a.m. UTC | #2
On Mon, Jun 09, 2014 at 05:57:20PM +0200, Igor Mammedov wrote:
> On Mon, 9 Jun 2014 18:25:13 +0800
> Hu Tao <hutao@cn.fujitsu.com> wrote:
> 
> > From: Paolo Bonzini <pbonzini@redhat.com>
> > 
> > Use QERR_INVALID_PARAMETER_VALUE for consistency.
> > 
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> > Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> >  qmp.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/qmp.c b/qmp.c
> > index b722dbe..cef60fb 100644
> > --- a/qmp.c
> > +++ b/qmp.c
> > @@ -540,7 +540,8 @@ void object_add(const char *type, const char *id, const QDict *qdict,
> >  
> >      klass = object_class_by_name(type);
> >      if (!klass) {
> > -        error_setg(errp, "invalid class name");
> > +        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
> > +                  "qom-type", "a valid class name");
> With implicit "qom-type" on CLI it might be not clear to user what value is
> wrong. Perhaps following would be better:
> 
> error_setg(errp, "Invalid object type name: %s", type);

Looks better for user to understand. Thanks.

Hu
diff mbox

Patch

diff --git a/qmp.c b/qmp.c
index b722dbe..cef60fb 100644
--- a/qmp.c
+++ b/qmp.c
@@ -540,7 +540,8 @@  void object_add(const char *type, const char *id, const QDict *qdict,
 
     klass = object_class_by_name(type);
     if (!klass) {
-        error_setg(errp, "invalid class name");
+        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
+                  "qom-type", "a valid class name");
         return;
     }