提交 cd34d667 编写于 作者: A Anthony Liguori

qdev: add a qdev_get_type() function and expose as a 'type' property

Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 6a146eba
......@@ -110,6 +110,8 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info)
qdev_property_add_legacy(dev, prop, NULL);
}
qdev_property_add_str(dev, "type", qdev_get_type, NULL, NULL);
return dev;
}
......@@ -1031,6 +1033,11 @@ char* qdev_get_fw_dev_path(DeviceState *dev)
return strdup(path);
}
char *qdev_get_type(DeviceState *dev, Error **errp)
{
return g_strdup(dev->info->name);
}
void qdev_ref(DeviceState *dev)
{
dev->ref++;
......
......@@ -596,4 +596,18 @@ void qdev_property_add_str(DeviceState *dev, const char *name,
void (*set)(DeviceState *, const char *, Error **),
Error **errp);
/**
* @qdev_get_type
*
* Returns the string representation of the type of this object.
*
* @dev - the device
*
* @errp - if an error occurs, a pointer to an area to store the error
*
* Returns: a string representing the type. This must be freed by the caller
* with g_free().
*/
char *qdev_get_type(DeviceState *dev, Error **errp);
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册