multi-process: QMP/HMP commands to remove device from the remote process
RFC PATCH 22/37 multi-process: QMP/HMP commands to remove device from the remote process
From: Jagannathan Raman <[email protected]>
Add rdevice_del QMP & HMP commands to hot-unplug device from remote device.
--- hmp-commands.hx | 14 ++++++++++++++ hmp.h | 1 + hw/proxy/monitor.c | 22 ++++++++++++++++++++++ include/hw/qdev-core.h | 1 + include/io/proxy-link.h | 2 ++ include/monitor/qdev.h | 1 + monitor.c | 2 ++ qapi/misc.json | 27 +++++++++++++++++++++++++++ qdev-monitor.c | 2 +- remote/remote-main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 116 insertions(+), 1 deletion(-)
hmp-commands.hx +14 -0
@@ -741,6 +741,20 @@ Add device to remote proc. ETEXI { + .name = "rdevice_del", + .args_type = "rdev_id:s,id:s", + .params = "rdev_id id", + .help = "remove device from remote proc", + .cmd = hmp_rdevice_del, + }, + +STEXI +@item rdevice_del @var{rdev_id} @var{id} +@findex rdevice_del +Remove device from remote proc. +ETEXI + + { .name = "remote_proc_list", .args_type = "", .params = "",
hmp.h +1 -0
@@ -151,5 +151,6 @@ void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict);void hmp_info_sev (Monitor *mon,const QDict *qdict);void hmp_remote_proc_list (Monitor *mon,const QDict *qdict);void hmp_rdevice_add (Monitor *mon,const QDict *qdict); +void hmp_rdevice_del (Monitor *mon,const QDict *qdict);#endif
hw/proxy/monitor.c +22 -0
@@ -158,6 +158,8 @@ static void rdevice_add_del(QDict *qdict, proc_cmd_t cmd, Error **errp)if (cmd ==DEVICE_ADD ) { (void )g_hash_table_insert (pcms->remote_devs, (gpointer )g_strdup (id), (gpointer )pdev); + }else { + (void )g_hash_table_remove (pcms->remote_devs, (gpointer )id); } }
@@ -179,3 +181,23 @@ void hmp_rdevice_add(Monitor *mon, const QDict *qdict)error_free (err); } } + +void qmp_rdevice_del (QDict *qdict,QObject **ret_data,Error **errp) +{ +rdevice_add_del (qdict,DEVICE_DEL , errp); +} + +void hmp_rdevice_del (Monitor *mon,const QDict *qdict) +{ +Error *err =NULL ; + +/* TODO: Is it OK to modify the QDict argument from HMP? */ +rdevice_add_del ((QDict *)qdict,DEVICE_DEL , &err); + +if (err) { +monitor_printf (mon,"rdevice_del error: %s\n" , +error_get_pretty (err)); +error_free (err); + } +} +
include/hw/qdev-core.h +1 -0
@@ -358,6 +358,7 @@ BusState *qdev_get_parent_bus(DeviceState *dev);/*** BUS API. ***/ DeviceState *qdev_find_recursive (BusState *bus,const char *id); +DeviceState *find_device_state (const char *id,Error **errp);/* Returns 0 to walk children, > 0 to skip walk, < 0 to terminate walk. */ typedef int (qbus_walkerfn )(BusState *bus,void *opaque);
include/io/proxy-link.h +2 -0
@@ -61,6 +61,7 @@ typedef struct ProxyLinkState ProxyLinkState;* SET_IRQFD Sets the IRQFD to be used to raise interrupts directly * from remote device * DEVICE_ADD QMP/HMP command to hotplug device +* DEVICE_DEL QMP/HMP command to hot-unplug device * */ typedef enum {
@@ -72,6 +73,7 @@ typedef enum {BAR_READ ,SET_IRQFD ,DEVICE_ADD , +DEVICE_DEL ,MAX , } proc_cmd_t;
include/monitor/qdev.h +1 -0
@@ -12,6 +12,7 @@ void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp);#ifdef CONFIG_MPQEMU void qmp_rdevice_add (QDict *qdict,QObject **ret_data,Error **errp); +void qmp_rdevice_del (QDict *qdict,QObject **ret_data,Error **errp);#endif int qdev_device_help (QemuOpts *opts);
monitor.c +2 -0
@@ -1158,6 +1158,8 @@ static void monitor_init_qmp_commands(void)#ifdef CONFIG_MPQEMU qmp_register_command (&qmp_commands,"rdevice_add" , qmp_rdevice_add,QCO_NO_OPTIONS ); +qmp_register_command (&qmp_commands,"rdevice_del" , qmp_rdevice_del, +QCO_NO_OPTIONS );#endif QTAILQ_INIT (&qmp_cap_negotiation_commands);
qapi/misc.json +27 -0
@@ -1717,6 +1717,33 @@ { 'command': 'device_del', 'data': {'id': 'str'} } ## +# @rdevice_del: +# +# Remove a device from a guest +# +# @rdev_id: ID of the remote device root +# +# @id: the device's ID +# +# Returns: Nothing on success +# If @id is not a valid device, DeviceNotFound +# +# 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. Completion of the device removal process is signaled with a +# DEVICE_DELETED event. Guest reset will automatically complete removal +# for all devices. +# +# Since: 3.0 +# +## +{ 'command': 'rdevice_del', + 'data': {'rdev_id': 'str', 'id': 'str'}, + 'if': 'defined(CONFIG_MPQEMU)', + 'gen': false } + +## # @DEVICE_DELETED: # # Emitted whenever the device removal completion is acknowledged by the guest.
qdev-monitor.c +1 -1
@@ -828,7 +828,7 @@ void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp)object_unref (OBJECT (dev)); } -static DeviceState *find_device_state (const char *id,Error **errp) +DeviceState *find_device_state (const char *id,Error **errp) {Object *obj;
remote/remote-main.c +45 -0
63 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 9 lines · On 3/7/19 1:22 AM, [email protected] wrote:
From: Jagannathan Raman <[email protected]>
Add
rdevice_delQMP & HMP commands to hot-unplug device from remote device.Signed-off-by Jagannathan Raman <[email protected]>Signed-off-by John G Johnson <[email protected]>Signed-off-by Elena Ufimtseva <[email protected]>---
Similar to my other mail (it will probably get hard to track whether I've replied everywhere or in order, thanks to the threading, but I see that's already been mentioned):
qapi/misc.json line 1721
Quoted 7 lines
+++
b/qapi/misc.jsonqapi/misc.json +2
-0@@ -1717,6 +1717,33 @@ { 'command': 'device_del', 'data': {'id': 'str'} } ## +# @rdevice_del: +#
New QMP commands should favor '-' over '_'; if we add it at all, it should be 'rdevice-del'.
Quoted 7 lines
qapi/misc.json +7
-0+# Remove a device from a guest +# +# @rdev_id: ID of the remote device root +# +# @id: the device's ID +# +# Returns: Nothing on success
qapi/misc.json line 1738
Quoted 10 lines
qapi/misc.json +10
-0+# If @id is not a valid device, DeviceNotFound +# +# 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. Completion of the device removal process is signaled with a +# DEVICE_DELETED event. Guest reset will automatically complete removal +# for all devices. +# +# Since: 3.0
and the soonest you're likely to get this in is 4.1.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org