There are now two major categories of global properties: One category consists of true global properties collected in global_props(), sourced from CLI options like `-global` and CPU features like `-cpu`. The other category comprises compat properties derived from object_compat_props[]. Within this, object_compat_props[0] and object_compat_props[1] represent compat properties for accelerators and machines, respectively. Meanwhile, object_compat_props[2] collects sugar properties from the CLI. Although sugar properties are also applied for legacy machine options (MachineClass::default_machine_opts), considerring those hardcoded defaults simulate CLI arguments, so treating them as USER_SET is acceptable as they emulate user behavior. Therefore, among all global properties, only those in global_props() and object_compat_props[2] originate from external users. Consequently, when applying global properties via object_apply_global_props(), these two categories of user-provided properties are marked as USER_SET by passing "from_user=true" to object_property_parse(). Signed-off-by: Zhao Liu <zhao1.liu@intel.com> --- hw/core/qdev-properties.c | 2 +- include/qom/object.h | 2 +- qom/object.c | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index c96ccfb26353..696dc5f201d6 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1017,7 +1017,7 @@ int qdev_prop_check_globals(void) void qdev_prop_set_globals(DeviceState *dev) { - object_apply_global_props(OBJECT(dev), global_props(), + object_apply_global_props(OBJECT(dev), global_props(), true, dev->hotplugged ? NULL : &error_fatal); } diff --git a/include/qom/object.h b/include/qom/object.h index c78e1c03a106..b621803f61bb 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -751,7 +751,7 @@ Object *object_new_with_propv(const char *typename, va_list vargs); bool object_apply_global_props(Object *obj, const GPtrArray *props, - Error **errp); + bool from_user, Error **errp); void object_set_machine_compat_props(GPtrArray *compat_props); void object_set_accelerator_compat_props(GPtrArray *compat_props); void object_register_sugar_prop(const char *driver, const char *prop, diff --git a/qom/object.c b/qom/object.c index 7140e3f629aa..4ead0befb351 100644 --- a/qom/object.c +++ b/qom/object.c @@ -441,7 +441,7 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti) } bool object_apply_global_props(Object *obj, const GPtrArray *props, - Error **errp) + bool from_user, Error **errp) { int i; @@ -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, false, &err)) { + if (!object_property_parse(obj, p->property, p->value, + from_user, &err)) { error_prepend(&err, "can't apply global %s.%s=%s: ", p->driver, p->property, p->value); /* @@ -536,6 +537,7 @@ void object_apply_compat_props(Object *obj) for (i = 0; i < ARRAY_SIZE(object_compat_props); i++) { object_apply_global_props(obj, object_compat_props[i], + i == 2 ? true : false, i == 2 ? &error_fatal : &error_abort); } } -- 2.34.1