From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48876) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SF1jF-0000js-Ee for qemu-devel@nongnu.org; Tue, 03 Apr 2012 07:16:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SF1jA-0003ES-I5 for qemu-devel@nongnu.org; Tue, 03 Apr 2012 07:16:48 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:59641) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SF1j9-00038a-9S for qemu-devel@nongnu.org; Tue, 03 Apr 2012 07:16:44 -0400 Received: by mail-pz0-f46.google.com with SMTP id z9so4190452dad.33 for ; Tue, 03 Apr 2012 04:16:42 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 3 Apr 2012 13:15:38 +0200 Message-Id: <1333451753-3550-11-git-send-email-pbonzini@redhat.com> In-Reply-To: <1333451753-3550-1-git-send-email-pbonzini@redhat.com> References: <1333451753-3550-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 10/25] qdev: do not propagate properties to subclasses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, afaerber@suse.de As soon as we'll look up properties along the inheritance chain, we will have duplicates if class A defines some properties and its subclass B does not define any, because class_b->props will be left equal to class_a->props. The solution here is to reintroduce the class_base_init TypeInfo callback, that was present in one of the early QOM versions but removed (on my request...) before committing. Signed-off-by: Paolo Bonzini --- hw/qdev.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/qdev.c b/hw/qdev.c index 4ac5616..d2b0134 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -671,6 +671,16 @@ static void device_finalize(Object *obj) QTAILQ_REMOVE(&dev->parent_bus->children, dev, sibling); } +static void device_class_base_init(ObjectClass *class, void *data) +{ + DeviceClass *klass = DEVICE_CLASS(class); + + /* We explicitly look up properties in the superclasses, + * so do not propagate them to the subclasses. + */ + klass->props = NULL; +} + void device_reset(DeviceState *dev) { DeviceClass *klass = DEVICE_GET_CLASS(dev); @@ -697,6 +707,7 @@ static TypeInfo device_type_info = { .instance_size = sizeof(DeviceState), .instance_init = device_initfn, .instance_finalize = device_finalize, + .class_base_init = device_class_base_init, .abstract = true, .class_size = sizeof(DeviceClass), }; -- 1.7.9.3