[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 3/3] qdev: Hook up DeviceClass::init to ObjectCl
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH RFC 3/3] qdev: Hook up DeviceClass::init to ObjectClass::realize |
Date: |
Mon, 26 Mar 2012 15:46:52 +0200 |
On realize, call the qdev init function.
If that returns an error, raise QERR_DEVICE_INIT_FAILED.
Signed-off-by: Andreas Färber <address@hidden>
Cc: Anthony Liguori <address@hidden>
Cc: Paolo Bonzini <address@hidden>
---
hw/qdev.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index ee21d90..c84b656 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -649,6 +649,13 @@ static void device_finalize(Object *obj)
QTAILQ_REMOVE(&dev->parent_bus->children, dev, sibling);
}
+static int device_realize(Object *obj)
+{
+ DeviceState *dev = DEVICE(obj);
+
+ return qdev_init(dev);
+}
+
void device_reset(DeviceState *dev)
{
DeviceClass *klass = DEVICE_GET_CLASS(dev);
@@ -658,6 +665,11 @@ void device_reset(DeviceState *dev)
}
}
+static void device_class_init(ObjectClass *class, void *data)
+{
+ class->realize = device_realize;
+}
+
static TypeInfo device_type_info = {
.name = TYPE_DEVICE,
.parent = TYPE_OBJECT,
@@ -666,6 +678,7 @@ static TypeInfo device_type_info = {
.instance_finalize = device_finalize,
.abstract = true,
.class_size = sizeof(DeviceClass),
+ .class_init = device_class_init,
};
static void qdev_register_types(void)
--
1.7.7