qdev: add class_init to DeviceInfo 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 <aliguori@us.ibm.com>
diff --git a/hw/qdev.c b/hw/qdev.c index c4b5284..81996bb 100644 --- a/hw/qdev.c +++ b/hw/qdev.c
@@ -54,6 +54,10 @@ /* 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 48f80a5..c9572a5 100644 --- a/hw/qdev.h +++ b/hw/qdev.h
@@ -231,6 +231,11 @@ /* 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;