object_set_properties_from_qdict() serves as the common entry point for
parsing and setting properties from qdict (and keyval).
This function is primarily utilized for external user configuration:
1. User Creatable Objects (via user_creatable_add_type()):
- QMP: object-add
- HMP: object_add
- CLI: -object (qemu), --object (qemu-img * / qemu-io / qemu-nbd /
qemu-storage-daemon)
- Authz list files ("authz-list-file")
2. Device and Machine creation (keyval-based):
- CLI: -machine / -device
- QMP/HMP: device_add
- Failover devices: virtio_net parses user's "qdict" in
failover_add_primary().
3. Built-in default machine options (MachineClass::default_machine_opts):
- These hardcoded defaults simulate CLI arguments and are parsed via
sugar property way or keyval. Treating them as USER_SET is
acceptable as they emulate user behavior.
There are a few internal corner cases where devices are created using an
internal qdict:
- Xen USB (usbback_portid_add())
- Intel HDA (intel_hda_and_codec_init())
Creating devices via internal qdict should be considered as legacy
technical debt and this should be refactored in future work. For these
cases, applying the USER_SET flag is a temporary and acceptable side
effect.
Therefor, update object_set_properties_from_qdict() to explicitly mark
properties as USER_SET.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
qom/object_interfaces.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 415cbee8c5cf..f0d5f9d84300 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -56,6 +56,11 @@ static void object_set_properties_from_qdict(Object *obj, const QDict *qdict,
if (!object_property_set(obj, e->key, v, errp)) {
goto out;
}
+
+ if (!object_property_set_flags(obj, e->key,
+ OBJ_PROP_FLAG_USER_SET, errp)) {
+ goto out;
+ }
}
visit_check_struct(v, errp);
out:
--
2.34.1