提交 a15fef21 编写于 作者: L Luiz Capitulino

qapi: convert device_del

Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
Signed-off-by: NLuiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
上级 56f9107e
...@@ -622,8 +622,7 @@ ETEXI ...@@ -622,8 +622,7 @@ ETEXI
.args_type = "id:s", .args_type = "id:s",
.params = "device", .params = "device",
.help = "remove device", .help = "remove device",
.user_print = monitor_user_noop, .mhandler.cmd = hmp_device_del,
.mhandler.cmd_new = do_device_del,
}, },
STEXI STEXI
......
...@@ -934,3 +934,12 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) ...@@ -934,3 +934,12 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
qemu_mod_timer(status->timer, qemu_get_clock_ms(rt_clock)); qemu_mod_timer(status->timer, qemu_get_clock_ms(rt_clock));
} }
} }
void hmp_device_del(Monitor *mon, const QDict *qdict)
{
const char *id = qdict_get_str(qdict, "id");
Error *err = NULL;
qmp_device_del(id, &err);
hmp_handle_error(mon, &err);
}
...@@ -60,5 +60,6 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict); ...@@ -60,5 +60,6 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict);
void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict); void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict);
void hmp_block_job_cancel(Monitor *mon, const QDict *qdict); void hmp_block_job_cancel(Monitor *mon, const QDict *qdict);
void hmp_migrate(Monitor *mon, const QDict *qdict); void hmp_migrate(Monitor *mon, const QDict *qdict);
void hmp_device_del(Monitor *mon, const QDict *qdict);
#endif #endif
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "qdev.h" #include "qdev.h"
#include "monitor.h" #include "monitor.h"
#include "qmp-commands.h"
/* /*
* Aliases were a bad idea from the start. Let's keep them * Aliases were a bad idea from the start. Let's keep them
...@@ -570,26 +571,17 @@ int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data) ...@@ -570,26 +571,17 @@ int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
return 0; return 0;
} }
int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data) void qmp_device_del(const char *id, Error **errp)
{ {
const char *id = qdict_get_str(qdict, "id");
Error *local_err = NULL;
DeviceState *dev; DeviceState *dev;
dev = qdev_find_recursive(sysbus_get_default(), id); dev = qdev_find_recursive(sysbus_get_default(), id);
if (NULL == dev) { if (NULL == dev) {
qerror_report(QERR_DEVICE_NOT_FOUND, id); error_set(errp, QERR_DEVICE_NOT_FOUND, id);
return -1; return;
}
qdev_unplug(dev, &local_err);
if (error_is_set(&local_err)) {
qerror_report_err(local_err);
error_free(local_err);
return -1;
} }
return 0; qdev_unplug(dev, errp);
} }
void qdev_machine_init(void) void qdev_machine_init(void)
......
...@@ -1701,3 +1701,23 @@ ...@@ -1701,3 +1701,23 @@
# Since: 1.1 # Since: 1.1
## ##
{ 'command': 'xen-save-devices-state', 'data': {'filename': 'str'} } { 'command': 'xen-save-devices-state', 'data': {'filename': 'str'} }
##
# @device_del:
#
# Remove a device from a guest
#
# @id: the name of the device
#
# Returns: Nothing on success
# If @id is not a valid device, DeviceNotFound
# If the device does not support unplug, BusNoHotplug
#
# Notes: When this command completes, the device may not be removed from the
# guest. Hot removal is an operation that requires guest cooperation.
# This command merely requests that the guest begin the hot removal
# process.
#
# Since: 0.14.0
##
{ 'command': 'device_del', 'data': {'id': 'str'} }
...@@ -314,10 +314,7 @@ EQMP ...@@ -314,10 +314,7 @@ EQMP
{ {
.name = "device_del", .name = "device_del",
.args_type = "id:s", .args_type = "id:s",
.params = "device", .mhandler.cmd_new = qmp_marshal_input_device_del,
.help = "remove device",
.user_print = monitor_user_noop,
.mhandler.cmd_new = do_device_del,
}, },
SQMP SQMP
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册