From patchwork Wed Apr 11 21:30:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 151904 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 68A03B703B for ; Thu, 12 Apr 2012 08:11:19 +1000 (EST) Received: from localhost ([::1]:35622 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SI595-00014V-Eq for incoming@patchwork.ozlabs.org; Wed, 11 Apr 2012 17:32:07 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SI582-0007A7-As for qemu-devel@nongnu.org; Wed, 11 Apr 2012 17:31:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SI580-0002Z8-JU for qemu-devel@nongnu.org; Wed, 11 Apr 2012 17:31:01 -0400 Received: from mail-wg0-f41.google.com ([74.125.82.41]:57046) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SI580-0002Yo-AI for qemu-devel@nongnu.org; Wed, 11 Apr 2012 17:31:00 -0400 Received: by wgbds1 with SMTP id ds1so4435982wgb.4 for ; Wed, 11 Apr 2012 14:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=UmMu0rrTaih0YA/T5e2BEBkDrf+RHQl3i1ELYMuaiuc=; b=W7R8axOeLCUicvKZylqwzR6+dq5UialmxpNUKsPsBTtQjM9EWi4hFGmf2zX/ADganQ xoZaX/T5+f4K8pYnu6H2cccfTkNx8yG7JUrrMRWAZWrStnhSpSHDQvY11DcQGlkc2i75 gsgqRT2rK5pnSU3xvVswMrgyqWjeYQEyzMvGM9rDGoLaMxirrWeAaQBB/eGAD6T/45zN oG6Uuk4dfz4ign5quDjdn/Wgm9HM8NzdCG4aAIuLSQGu9oorRpwG3kkc/QlmnogFfJnp L63wwROO7Ei/nMnkjzSeloOjgvu/x4ia714lnrTfq8HCjAZuSFGNGe5RZUGmJyqUV2S5 DwQg== Received: by 10.180.102.100 with SMTP id fn4mr113745wib.1.1334179858343; Wed, 11 Apr 2012 14:30:58 -0700 (PDT) Received: from yakj.lan (93-34-182-16.ip50.fastwebnet.it. [93.34.182.16]) by mx.google.com with ESMTPS id h8sm13849678wix.4.2012.04.11.14.30.57 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 11 Apr 2012 14:30:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 11 Apr 2012 23:30:27 +0200 Message-Id: <1334179842-6061-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.9.3 In-Reply-To: <1334179793-5914-1-git-send-email-pbonzini@redhat.com> References: <1334179793-5914-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.82.41 Cc: aliguori@us.ibm.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v2 09/24] qdev: do not propagate properties to subclasses X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 bb6c1aa..d622dd7 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -653,6 +653,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); @@ -679,6 +689,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), };