TYPE_USER_CREATABLE types expose all QOM properties through `-object` and `object-add`. Lock the properties on TYPE_USER_CREATABLE so we will never add new writable instance properties to those types.
Signed-off-by: Eduardo Habkost <ehabk...@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_interfaces.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index e8e1523960..40123d4b50 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -293,6 +293,16 @@ bool user_creatable_del(const char *id, Error **errp) return true; } +static void user_creatable_class_init(ObjectClass *klass, void *data) +{ + /* + * User-creatable QOM types expose all writable QOM properties + * to the external world through `-object` and `object-add`, + * so all writable properties must be registered at class level. + */ + object_class_lock_properties(klass); +} + void user_creatable_cleanup(void) { object_unparent(object_get_objects_root()); @@ -304,6 +314,7 @@ static void register_types(void) .name = TYPE_USER_CREATABLE, .parent = TYPE_INTERFACE, .class_size = sizeof(UserCreatableClass), + .class_init = user_creatable_class_init, }; type_register_static(&uc_interface_info); -- 2.26.2