From 684546d8e9b5adefa5b499d4371b83f9163593b6 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Thu, 6 Sep 2018 17:37:36 +0400 Subject: qom/object: fix iterating properties over a class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit object_class_property_iter_init() starts from the given class, so the next class should continue with the parent class. Signed-off-by: Marc-André Lureau Reviewed-by: Paolo Bonzini --- qom/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qom/object.c') diff --git a/qom/object.c b/qom/object.c index 9222b23172..9eaf08a53c 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1115,7 +1115,7 @@ void object_class_property_iter_init(ObjectPropertyIterator *iter, ObjectClass *klass) { g_hash_table_iter_init(&iter->iter, klass->properties); - iter->nextclass = klass; + iter->nextclass = object_class_get_parent(klass); } ObjectProperty *object_class_property_find(ObjectClass *klass, const char *name, -- cgit 1.4.1 From 7439a036d58f0def85751d6d4d3232461a35ebee Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Thu, 6 Sep 2018 18:09:32 +0400 Subject: qom/object: register 'type' property as class property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let's save a few byte in each object instance. Signed-off-by: Marc-André Lureau Reviewed-by: Paolo Bonzini --- qom/object.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'qom/object.c') diff --git a/qom/object.c b/qom/object.c index 9eaf08a53c..547dcf97c3 100644 --- a/qom/object.c +++ b/qom/object.c @@ -2430,9 +2430,10 @@ void object_class_property_set_description(ObjectClass *klass, op->description = g_strdup(description); } -static void object_instance_init(Object *obj) +static void object_class_init(ObjectClass *klass, void *data) { - object_property_add_str(obj, "type", qdev_get_type, NULL, NULL); + object_class_property_add_str(klass, "type", qdev_get_type, + NULL, &error_abort); } static void register_types(void) @@ -2446,7 +2447,7 @@ static void register_types(void) static TypeInfo object_info = { .name = TYPE_OBJECT, .instance_size = sizeof(Object), - .instance_init = object_instance_init, + .class_init = object_class_init, .abstract = true, }; -- cgit 1.4.1