]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qdev: add class_init to DeviceInfo
authorAnthony Liguori <aliguori@us.ibm.com>
Sun, 4 Dec 2011 20:37:06 +0000 (14:37 -0600)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 27 Jan 2012 16:50:46 +0000 (10:50 -0600)
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>
hw/qdev.c
hw/qdev.h

index c4b5284fdc07d03689fb814af5dcb5fc5bd08dd8..81996bbc3662af80cda655cf8d48376423e3c3b2 100644 (file)
--- 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)
index 48f80a5cce222fe764c2d2a085669707c79f6cc5..c9572a546cb86fe38f47e8e44bfb301e6171303a 100644 (file)
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -231,6 +231,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;