[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/33] qdev-monitor: Factor out find_device_state()
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 13/33] qdev-monitor: Factor out find_device_state() |
Date: |
Thu, 22 Sep 2016 18:29:14 +0200 |
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
qdev-monitor.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/qdev-monitor.c b/qdev-monitor.c
index e19617f..bc0213f 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -801,7 +801,7 @@ void qmp_device_add(QDict *qdict, QObject **ret_data, Error
**errp)
object_unref(OBJECT(dev));
}
-void qmp_device_del(const char *id, Error **errp)
+static DeviceState *find_device_state(const char *id, Error **errp)
{
Object *obj;
@@ -819,15 +819,23 @@ void qmp_device_del(const char *id, Error **errp)
if (!obj) {
error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", id);
- return;
+ return NULL;
}
if (!object_dynamic_cast(obj, TYPE_DEVICE)) {
error_setg(errp, "%s is not a hotpluggable device", id);
- return;
+ return NULL;
}
- qdev_unplug(DEVICE(obj), errp);
+ return DEVICE(obj);
+}
+
+void qmp_device_del(const char *id, Error **errp)
+{
+ DeviceState *dev = find_device_state(id, errp);
+ if (dev != NULL) {
+ qdev_unplug(dev, errp);
+ }
}
void qdev_machine_init(void)
--
1.8.3.1
- [Qemu-devel] [PULL 02/33] hmp: Remove dead code in hmp_qemu_io(), (continued)
- [Qemu-devel] [PULL 02/33] hmp: Remove dead code in hmp_qemu_io(), Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 04/33] block: Remove bdrv_is_snapshot, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 05/33] block: Set BDRV_O_ALLOW_RDWR and snapshot_options before storing the flags, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 03/33] tests: allow to specify list of formats to test for check-block.sh, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 06/33] block: Update bs->open_flags earlier in bdrv_open_common(), Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 08/33] block: Don't queue the same BDS twice in bdrv_reopen_queue_child(), Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 10/33] block: rename "read-only" to BDRV_OPT_READ_ONLY, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 07/33] block: Add "read-only" to the options QDict, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 09/33] commit: Add 'base' to the reopen queue before 'overlay_bs', Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 11/33] block: Fix 'since' for compressed Drive/BlockdevBackup, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 13/33] qdev-monitor: Factor out find_device_state(),
Kevin Wolf <=
- [Qemu-devel] [PULL 12/33] block: Add blk_by_dev(), Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 14/33] qdev-monitor: Add blk_by_qdev_id(), Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 16/33] block: Accept device model name for x-blockdev-insert-medium, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 15/33] block: Accept device model name for blockdev-open/close-tray, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 17/33] block: Accept device model name for x-blockdev-remove-medium, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 18/33] block: Accept device model name for eject, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 19/33] block: Accept device model name for blockdev-change-medium, Kevin Wolf, 2016/09/22
- [Qemu-devel] [PULL 21/33] qemu-iotests/118: Test media change with qdev name, Kevin Wolf, 2016/09/22