Global properties can be set up in these cases: 1) external global properties: * -global command line option. * -cpu command line features. * suger properties from object_compat_props[2] 2) internal global properties: * compat properties from object_compat_props[0,1]. In principle, when a compat property is marked as deprecated, it should not be added to any object_compat_props[] as a compat "fix". Therefore, internal compat "global" property use cases should also be considered. All of these global cases are using object_property_parse() to parse and set propertyies, ao add a object_property_parse_with_check() to enable deprecation checks for global properties. Signed-off-by: Zhao Liu <zhao1.liu@intel.com> --- include/qom/object.h | 20 ++++++++++++++++++++ qom/object.c | 13 ++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/include/qom/object.h b/include/qom/object.h index 8f4c2f44d835..bdeba113f40f 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1555,6 +1555,26 @@ bool object_property_set_full(Object *obj, const char *name, bool object_property_parse(Object *obj, const char *name, const char *string, Error **errp); +/** + * object_property_parse_with_check: + * + * Same as object_property_parse() with extra check over property flags + * (ObjectPropertyFlags). This interface should be used to handle + * property settings for external users or internal legacy or compatibility + * cases. + * + * @obj: the object + * @name: the name of the property + * @string: the string that will be used to parse the property value. + * @errp: returns an error if this function fails + * + * Parses a string and writes the result into a property of an object. + * + * Returns: %true on success, %false on failure. + */ +bool object_property_parse_with_check(Object *obj, const char *name, + const char *string, Error **errp); + /** * object_property_print: * @obj: the object diff --git a/qom/object.c b/qom/object.c index 184afc6730dd..2973d8876555 100644 --- a/qom/object.c +++ b/qom/object.c @@ -460,7 +460,8 @@ bool object_apply_global_props(Object *obj, const GPtrArray *props, continue; } p->used = true; - if (!object_property_parse(obj, p->property, p->value, &err)) { + if (!object_property_parse_with_check(obj, p->property, + p->value, &err)) { error_prepend(&err, "can't apply global %s.%s=%s: ", p->driver, p->property, p->value); /* @@ -1745,6 +1746,16 @@ bool object_property_parse(Object *obj, const char *name, return ok; } +bool object_property_parse_with_check(Object *obj, const char *name, + const char *string, Error **errp) +{ + Visitor *v = string_input_visitor_new(string); + bool ok = object_property_set_full(obj, name, v, true, errp); + + visit_free(v); + return ok; +} + char *object_property_print(Object *obj, const char *name, bool human, Error **errp) { -- 2.34.1