From patchwork Tue Jan 3 00:52:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [13/30] qdev: add class_init to DeviceInfo X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 133935 Message-Id: <1325551939-24749-14-git-send-email-aliguori@us.ibm.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Anthony Liguori , Markus Armbruster , =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 2 Jan 2012 18:52:02 -0600 From: Anthony Liguori List-Id: 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 7c4d3ca..c6a6d20 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 742f421..6e86826 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;