diff options
Diffstat (limited to 'softmmu')
-rw-r--r-- | softmmu/qdev-monitor.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 0705f00..3df99ce 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -836,16 +836,12 @@ void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp) static DeviceState *find_device_state(const char *id, Error **errp) { Object *obj; + DeviceState *dev; if (id[0] == '/') { obj = object_resolve_path(id, NULL); } else { - char *root_path = object_get_canonical_path(qdev_get_peripheral()); - char *path = g_strdup_printf("%s/%s", root_path, id); - - g_free(root_path); - obj = object_resolve_path_type(path, TYPE_DEVICE, NULL); - g_free(path); + obj = object_resolve_path_component(qdev_get_peripheral(), id); } if (!obj) { @@ -854,12 +850,13 @@ static DeviceState *find_device_state(const char *id, Error **errp) return NULL; } - if (!object_dynamic_cast(obj, TYPE_DEVICE)) { + dev = (DeviceState *)object_dynamic_cast(obj, TYPE_DEVICE); + if (!dev) { error_setg(errp, "%s is not a hotpluggable device", id); return NULL; } - return DEVICE(obj); + return dev; } void qdev_unplug(DeviceState *dev, Error **errp) |