diff mbox series

qom: Improve error message displayed with missing object properties

Message ID 20200920155340.401482-1-f4bug@amsat.org
State New
Headers show
Series qom: Improve error message displayed with missing object properties | expand

Commit Message

Philippe Mathieu-Daudé Sept. 20, 2020, 3:53 p.m. UTC
Instead of only displaying the property missing, also display
the object name. This help developer to quickly figure out the
mistake without opening a debugger.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 qom/object.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Li Qiang Sept. 20, 2020, 4:08 p.m. UTC | #1
Philippe Mathieu-Daudé <f4bug@amsat.org> 于2020年9月20日周日 下午11:54写道:
>

> Instead of only displaying the property missing, also display

> the object name. This help developer to quickly figure out the

> mistake without opening a debugger.

>

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


Reviewed-by: Li Qiang <liq3ea@gmail.com>


> ---

>  qom/object.c | 3 ++-

>  1 file changed, 2 insertions(+), 1 deletion(-)

>

> diff --git a/qom/object.c b/qom/object.c

> index 387efb25ebe..257914b1fe3 100644

> --- a/qom/object.c

> +++ b/qom/object.c

> @@ -1259,7 +1259,8 @@ ObjectProperty *object_property_find(Object *obj, const char *name,

>          return prop;

>      }

>

> -    error_setg(errp, "Property '.%s' not found", name);

> +    error_setg(errp, "Property '%s.%s' not found",

> +               object_get_typename(obj), name);

>      return NULL;

>  }

>

> --

> 2.26.2

>

>
Philippe Mathieu-Daudé Oct. 5, 2020, 7:42 a.m. UTC | #2
Eduardo, can you take this patch, or can it goes via qemu-trivial?

On 9/20/20 5:53 PM, Philippe Mathieu-Daudé wrote:
> Instead of only displaying the property missing, also display

> the object name. This help developer to quickly figure out the

> mistake without opening a debugger.

> 

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---

>  qom/object.c | 3 ++-

>  1 file changed, 2 insertions(+), 1 deletion(-)

> 

> diff --git a/qom/object.c b/qom/object.c

> index 387efb25ebe..257914b1fe3 100644

> --- a/qom/object.c

> +++ b/qom/object.c

> @@ -1259,7 +1259,8 @@ ObjectProperty *object_property_find(Object *obj, const char *name,

>          return prop;

>      }

>  

> -    error_setg(errp, "Property '.%s' not found", name);

> +    error_setg(errp, "Property '%s.%s' not found",

> +               object_get_typename(obj), name);

>      return NULL;

>  }

>  

>
Paolo Bonzini Oct. 5, 2020, 8:46 a.m. UTC | #3
On 20/09/20 17:53, Philippe Mathieu-Daudé wrote:
> Instead of only displaying the property missing, also display

> the object name. This help developer to quickly figure out the

> mistake without opening a debugger.

> 

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---

>  qom/object.c | 3 ++-

>  1 file changed, 2 insertions(+), 1 deletion(-)

> 

> diff --git a/qom/object.c b/qom/object.c

> index 387efb25ebe..257914b1fe3 100644

> --- a/qom/object.c

> +++ b/qom/object.c

> @@ -1259,7 +1259,8 @@ ObjectProperty *object_property_find(Object *obj, const char *name,

>          return prop;

>      }

>  

> -    error_setg(errp, "Property '.%s' not found", name);

> +    error_setg(errp, "Property '%s.%s' not found",

> +               object_get_typename(obj), name);

>      return NULL;

>  }

>  

> 


Acked-by: Paolo Bonzini <pbonzini@redhat.com>


I think it's okay for qemu-trivial.
Eduardo Habkost Oct. 5, 2020, 4:42 p.m. UTC | #4
On Mon, Oct 05, 2020 at 10:46:38AM +0200, Paolo Bonzini wrote:
> On 20/09/20 17:53, Philippe Mathieu-Daudé wrote:

> > Instead of only displaying the property missing, also display

> > the object name. This help developer to quickly figure out the

> > mistake without opening a debugger.

> > 

> > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> > ---

> >  qom/object.c | 3 ++-

> >  1 file changed, 2 insertions(+), 1 deletion(-)

> > 

> > diff --git a/qom/object.c b/qom/object.c

> > index 387efb25ebe..257914b1fe3 100644

> > --- a/qom/object.c

> > +++ b/qom/object.c

> > @@ -1259,7 +1259,8 @@ ObjectProperty *object_property_find(Object *obj, const char *name,

> >          return prop;

> >      }

> >  

> > -    error_setg(errp, "Property '.%s' not found", name);

> > +    error_setg(errp, "Property '%s.%s' not found",

> > +               object_get_typename(obj), name);

> >      return NULL;

> >  }

> >  

> > 

> 

> Acked-by: Paolo Bonzini <pbonzini@redhat.com>

> 

> I think it's okay for qemu-trivial.


It would be okay, but it doesn't apply on master anymore due to
the object_propert_find_err() refactor.  I've fixed the conflicts
and queued it on machine-next.

-- 
Eduardo
Philippe Mathieu-Daudé Oct. 5, 2020, 5:20 p.m. UTC | #5
On 10/5/20 6:42 PM, Eduardo Habkost wrote:
> On Mon, Oct 05, 2020 at 10:46:38AM +0200, Paolo Bonzini wrote:

>> On 20/09/20 17:53, Philippe Mathieu-Daudé wrote:

>>> Instead of only displaying the property missing, also display

>>> the object name. This help developer to quickly figure out the

>>> mistake without opening a debugger.

>>>

>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

>>> ---

>>>  qom/object.c | 3 ++-

>>>  1 file changed, 2 insertions(+), 1 deletion(-)

>>>

>>> diff --git a/qom/object.c b/qom/object.c

>>> index 387efb25ebe..257914b1fe3 100644

>>> --- a/qom/object.c

>>> +++ b/qom/object.c

>>> @@ -1259,7 +1259,8 @@ ObjectProperty *object_property_find(Object *obj, const char *name,

>>>          return prop;

>>>      }

>>>  

>>> -    error_setg(errp, "Property '.%s' not found", name);

>>> +    error_setg(errp, "Property '%s.%s' not found",

>>> +               object_get_typename(obj), name);

>>>      return NULL;

>>>  }

>>>  

>>>

>>

>> Acked-by: Paolo Bonzini <pbonzini@redhat.com>

>>

>> I think it's okay for qemu-trivial.

> 

> It would be okay, but it doesn't apply on master anymore due to

> the object_propert_find_err() refactor.  I've fixed the conflicts

> and queued it on machine-next.


Oh sorry I didn't noticed, thanks for fixing/queuing!

Phil.
diff mbox series

Patch

diff --git a/qom/object.c b/qom/object.c
index 387efb25ebe..257914b1fe3 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1259,7 +1259,8 @@  ObjectProperty *object_property_find(Object *obj, const char *name,
         return prop;
     }
 
-    error_setg(errp, "Property '.%s' not found", name);
+    error_setg(errp, "Property '%s.%s' not found",
+               object_get_typename(obj), name);
     return NULL;
 }