On Fri, 30 Oct 2020 16:21:12 -0400 Eduardo Habkost <ehabk...@redhat.com> wrote:
> Make object_property_parse() automatically add a error message > prefix mentioning the QOM type and property name when > encountering errors. > > As we have a large number of functions that add their own > "Property '...'" to the error messages, add a temporary check for > existing prefixes before prepending our own. > > Signed-off-by: Eduardo Habkost <ehabk...@redhat.com> Reviewed-by: Igor Mammedov <imamm...@redhat.com> > --- > Cc: Paolo Bonzini <pbonz...@redhat.com> > Cc: "Daniel P. Berrangé" <berra...@redhat.com> > Cc: Eduardo Habkost <ehabk...@redhat.com> > Cc: qemu-devel@nongnu.org > --- > qom/object.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/qom/object.c b/qom/object.c > index 20726e4584..6fb1657724 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -1635,9 +1635,20 @@ int object_property_get_enum(Object *obj, const char > *name, > bool object_property_parse(Object *obj, const char *name, > const char *string, Error **errp) > { > + ERRP_GUARD(); > Visitor *v = string_input_visitor_new(string); > bool ok = object_property_set(obj, name, v, errp); > > + if (!ok) { > + /* > + * Temporary check for existing prefix, until all error reporting > + * functions remove their own prefix. > + */ > + if (!g_str_has_prefix(error_get_pretty(*errp), "Property '")) { > + error_prepend(errp, "Property '%s.%s' can't take value '%s': ", > + object_get_typename(obj), name, string); > + } > + } > visit_free(v); > return ok; > }