From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFAg8-0007Dw-5X for qemu-devel@nongnu.org; Tue, 03 Apr 2012 16:50:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SFAg6-0006LV-DQ for qemu-devel@nongnu.org; Tue, 03 Apr 2012 16:50:11 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:43492) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SFAg6-0006LN-8x for qemu-devel@nongnu.org; Tue, 03 Apr 2012 16:50:10 -0400 Received: by yenr5 with SMTP id r5so112003yen.4 for ; Tue, 03 Apr 2012 13:50:08 -0700 (PDT) Message-ID: <4F7B627C.8060302@codemonkey.ws> Date: Tue, 03 Apr 2012 15:50:04 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1333451753-3550-1-git-send-email-pbonzini@redhat.com> <1333451753-3550-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1333451753-3550-2-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 01/25] qom: add object_class_get_parent List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org, afaerber@suse.de On 04/03/2012 06:15 AM, Paolo Bonzini wrote: > 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 Regards, Anthony Liguori > --- > include/qemu/object.h | 14 ++++++++++++++ > qom/object.c | 13 +++++++++++++ > 2 files changed, 27 insertions(+) > > diff --git a/include/qemu/object.h b/include/qemu/object.h > index a675937..f814521 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. > * > @@ -555,6 +563,12 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *klass, > */ > const char *object_class_get_name(ObjectClass *klass); > > +/** > + * object_class_by_name: > + * @typename: The QOM typename to obtain the class for. > + * > + * Returns: The class for @typename. > + */ > ObjectClass *object_class_by_name(const char *typename); > > void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), > 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);