From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPXma-0002mN-1a for qemu-devel@nongnu.org; Wed, 02 May 2012 07:31:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPXmR-0000Gx-91 for qemu-devel@nongnu.org; Wed, 02 May 2012 07:31:43 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:48124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPXmR-0000FY-04 for qemu-devel@nongnu.org; Wed, 02 May 2012 07:31:35 -0400 Received: by mail-pb0-f45.google.com with SMTP id ro12so1148607pbb.4 for ; Wed, 02 May 2012 04:31:34 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 2 May 2012 13:30:54 +0200 Message-Id: <1335958273-769-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1335958273-769-1-git-send-email-pbonzini@redhat.com> References: <1335958273-769-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 02/21] qom: add object_class_get_parent List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, liwp@linux.vnet.ibm.com, afaerber@suse.de This simple bit of functionality was missing and we'll need it soon, so add it. Signed-off-by: Paolo Bonzini --- include/qemu/object.h | 8 ++++++++ qom/object.c | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/qemu/object.h b/include/qemu/object.h index d315dfa..063c817 100644 --- a/include/qemu/object.h +++ b/include/qemu/object.h @@ -548,6 +548,14 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass, const char *typename); /** + * object_class_get_parent: + * @klass: The class to obtain the parent for. + * + * Returns: The parent for @klass. + */ +ObjectClass *object_class_get_parent(ObjectClass *klass); + +/** * object_class_get_name: * @klass: The class to obtain the QOM typename for. * diff --git a/qom/object.c b/qom/object.c index e721fc2..3e9fed7 100644 --- a/qom/object.c +++ b/qom/object.c @@ -545,6 +545,19 @@ ObjectClass *object_class_by_name(const char *typename) return type->class; } +ObjectClass *object_class_get_parent(ObjectClass *class) +{ + TypeImpl *type = type_get_parent(class->type); + + if (!type) { + return NULL; + } + + type_initialize(type); + + return type->class; +} + typedef struct OCFData { void (*fn)(ObjectClass *klass, void *opaque); -- 1.7.9.3