From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgcUl-0001bx-3O for qemu-devel@nongnu.org; Mon, 18 Jun 2012 10:00:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SgcUQ-0003V5-Uc for qemu-devel@nongnu.org; Mon, 18 Jun 2012 09:59:54 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53216 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgcUQ-0003Uh-PQ for qemu-devel@nongnu.org; Mon, 18 Jun 2012 09:59:34 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 18 Jun 2012 15:58:53 +0200 Message-Id: <1340027954-19045-2-git-send-email-afaerber@suse.de> In-Reply-To: <1340027954-19045-1-git-send-email-afaerber@suse.de> References: <1340027954-19045-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 01/22] qom: Add object_class_get_parent() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori From: Paolo Bonzini This simple bit of functionality was missing and we'll need it soon, so add it. Signed-off-by: Paolo Bonzini Reviewed-by: Anthony Liguori [AF: Document possible NULL return value] Signed-off-by: Andreas F=C3=A4rber --- include/qemu/object.h | 8 ++++++++ qom/object.c | 13 +++++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/include/qemu/object.h b/include/qemu/object.h index d93b772..487559c 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); =20 /** + * object_class_get_parent: + * @klass: The class to obtain the parent for. + * + * Returns: The parent for @klass or %NULL if none. + */ +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 6f839ad..9582230 100644 --- a/qom/object.c +++ b/qom/object.c @@ -545,6 +545,19 @@ ObjectClass *object_class_by_name(const char *typena= me) return type->class; } =20 +ObjectClass *object_class_get_parent(ObjectClass *class) +{ + TypeImpl *type =3D type_get_parent(class->type); + + if (!type) { + return NULL; + } + + type_initialize(type); + + return type->class; +} + typedef struct OCFData { void (*fn)(ObjectClass *klass, void *opaque); --=20 1.7.7