summary refs log tree commit diff stats
path: root/hw/qdev.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-12-15 14:40:29 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2012-01-27 10:50:46 -0600
commit3cc90eb2b7c0810fb23ceed57c1f50683ee803fd (patch)
treeb6194aded9070101c6dab9390e31f5cd480d0eec /hw/qdev.c
parent94afdadcb3ab71f5123f719d74065c6f4cc837ea (diff)
downloadfocaccia-qemu-3cc90eb2b7c0810fb23ceed57c1f50683ee803fd.tar.gz
focaccia-qemu-3cc90eb2b7c0810fb23ceed57c1f50683ee803fd.zip
qdev: add a interface to register subclasses
In order to introduce inheritance while still using the qdev registration
interfaces, we need to be able to use a parent other than TYPE_DEVICE.  Add a
new interface that allows this.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/qdev.c')
-rw-r--r--hw/qdev.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/hw/qdev.c b/hw/qdev.c
index a80ca7ccbc..c4b5284fdc 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -61,7 +61,7 @@ DeviceInfo *qdev_get_info(DeviceState *dev)
     return DEVICE_GET_CLASS(dev)->info;
 }
 
-void qdev_register(DeviceInfo *info)
+void qdev_register_subclass(DeviceInfo *info, const char *parent)
 {
     TypeInfo type_info = {};
 
@@ -69,7 +69,7 @@ void qdev_register(DeviceInfo *info)
     assert(!info->next);
 
     type_info.name = info->name;
-    type_info.parent = TYPE_DEVICE;
+    type_info.parent = parent;
     type_info.instance_size = info->size;
     type_info.class_init = qdev_subclass_init;
     type_info.class_data = info;
@@ -80,6 +80,11 @@ void qdev_register(DeviceInfo *info)
     device_info_list = info;
 }
 
+void qdev_register(DeviceInfo *info)
+{
+    qdev_register_subclass(info, TYPE_DEVICE);
+}
+
 static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name)
 {
     DeviceInfo *info;