| 1 | #ifndef MONITOR_QDEV_H |
| 2 | #define MONITOR_QDEV_H |
| 3 | |
| 4 | #include "hw/core/qdev.h" |
| 5 | #include "monitor/hmp.h" |
| 6 | |
| 7 | /*** monitor commands ***/ |
| 8 | |
| 9 | void hmp_info_qtree(MonitorHMP *hmp, const QDict *qdict); |
| 10 | void hmp_info_qdm(MonitorHMP *hmp, const QDict *qdict); |
| 11 | void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp); |
| 12 | |
| 13 | int qdev_device_help(QemuOpts *opts); |
| 14 | DeviceState *qdev_device_add(QemuOpts *opts, Error **errp); |
| 15 | DeviceState *qdev_device_add_from_qdict(const QDict *opts, |
| 16 | bool from_json, Error **errp); |
| 17 | BusState *qdev_find_default_bus(DeviceClass *dc, Error **errp); |
| 18 | |
| 19 | /** |
| 20 | * qdev_set_id: parent the device and set its id if provided. |
| 21 | * @dev: device to handle |
| 22 | * @id: id to be given to the device, or NULL. |
| 23 | * |
| 24 | * Returns: the id of the device in case of success; otherwise NULL. |
| 25 | * |
| 26 | * @dev must be unrealized, unparented and must not have an id. |
| 27 | * |
| 28 | * If @id is non-NULL, this function tries to setup @dev qom path as |
| 29 | * "/peripheral/id". If @id is already taken, it fails. If it succeeds, |
| 30 | * the id field of @dev is set to @id (@dev now owns the given @id |
| 31 | * parameter). |
| 32 | * |
| 33 | * If @id is NULL, this function generates a unique name and setups @dev |
| 34 | * qom path as "/peripheral-anon/name". This name is not set as the id |
| 35 | * of @dev. |
| 36 | * |
| 37 | * Upon success, it returns the id/name (generated or provided). The |
| 38 | * returned string is owned by the corresponding child property and must |
| 39 | * not be freed by the caller. |
| 40 | */ |
| 41 | const char *qdev_set_id(DeviceState *dev, char *id, Error **errp); |
| 42 | |
| 43 | #endif |