提交 da57febf 编写于 作者: P Paolo Bonzini 提交者: Anthony Liguori

qdev: give all devices a canonical path

A strong limitation of QOM right now is that unconverted ports
(e.g. all...) do not give a canonical path to devices that are
part of the board.  This in turn makes it impossible to replace
PROP_PTR with a QOM link for example.
Reviewed-by: NAnthony Liguori <aliguori@us.ibm.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 f424d5c4
......@@ -113,14 +113,14 @@ DeviceState *qdev_create(BusState *bus, const char *name)
return dev;
}
DeviceState *qdev_try_create(BusState *bus, const char *name)
DeviceState *qdev_try_create(BusState *bus, const char *type)
{
DeviceState *dev;
if (object_class_by_name(name) == NULL) {
if (object_class_by_name(type) == NULL) {
return NULL;
}
dev = DEVICE(object_new(name));
dev = DEVICE(object_new(type));
if (!dev) {
return NULL;
}
......@@ -152,6 +152,16 @@ int qdev_init(DeviceState *dev)
qdev_free(dev);
return rc;
}
if (!OBJECT(dev)->parent) {
static int unattached_count = 0;
gchar *name = g_strdup_printf("device[%d]", unattached_count++);
object_property_add_child(container_get("/unattached"), name,
OBJECT(dev), NULL);
g_free(name);
}
if (qdev_get_vmsd(dev)) {
vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
dev->instance_id_alias,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册