From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:35377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rd2vL-0005WZ-V0 for qemu-devel@nongnu.org; Tue, 20 Dec 2011 11:52:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rd2vL-0006Ux-68 for qemu-devel@nongnu.org; Tue, 20 Dec 2011 11:52:19 -0500 Received: from cpe-70-123-132-139.austin.res.rr.com ([70.123.132.139]:41625 helo=localhost6.localdomain6) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rd2vL-0006Ur-08 for qemu-devel@nongnu.org; Tue, 20 Dec 2011 11:52:19 -0500 From: Anthony Liguori Date: Tue, 20 Dec 2011 10:51:37 -0600 Message-Id: <1324399916-21315-9-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1324399916-21315-1-git-send-email-aliguori@us.ibm.com> References: <1324399916-21315-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 08/27] qdev: add class_init to DeviceInfo List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Anthony Liguori , Markus Armbruster Since we are still dynamically creating TypeInfo, we need to chain the class_init function in order to be able to make use of it within subclasses of TYPE_DEVICE. This will disappear once we register TypeInfos directly. Signed-off-by: Anthony Liguori --- hw/qdev.c | 4 ++++ hw/qdev.h | 5 +++++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 40ca081..51d4fc5 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -54,6 +54,10 @@ static void qdev_subclass_init(ObjectClass *klass, void *data) /* Poison to try to detect future uses */ dc->info->reset = NULL; + + if (dc->info->class_init) { + dc->info->class_init(klass, data); + } } DeviceInfo *qdev_get_info(DeviceState *dev) diff --git a/hw/qdev.h b/hw/qdev.h index c366174..02567db 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -230,6 +230,11 @@ struct DeviceInfo { /* device state */ const VMStateDescription *vmsd; + /** + * See #TypeInfo::class_init() + */ + void (*class_init)(ObjectClass *klass, void *data); + /* Private to qdev / bus. */ qdev_initfn init; qdev_event unplug; -- 1.7.4.1