Signed-off-by: Anthony Liguori <aligu...@us.ibm.com> --- monitor.c | 20 ++++++++++++++++++++ qmp-commands.hx | 9 +++++++++ 2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/monitor.c b/monitor.c index e53808a..549251a 100644 --- a/monitor.c +++ b/monitor.c @@ -1069,6 +1069,26 @@ static int do_plug_create(Monitor *mon, const QDict *qdict, QObject **ret_data) return 0; } +static int do_plug_destroy(Monitor *mon, const QDict *qdict, QObject **ret_data) +{ + const char *id = qdict_get_str(qdict, "id"); + TypeInstance *inst; + Plug *plug; + + inst = type_find_by_id(id); + if (inst == NULL) { + return -1; + } + + plug = PLUG(inst); + + global_plug_list = g_slist_remove(global_plug_list, plug); + + type_delete(inst); + + return 0; +} + static int do_plug_list(Monitor *mon, const QDict *qdict, QObject **ret_data) { QList *qlist = qlist_new(); diff --git a/qmp-commands.hx b/qmp-commands.hx index 6f1091b..8203371 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -112,6 +112,15 @@ Notes: EQMP { + .name = "plug_destroy", + .args_type = "type:s", + .params = "type=value", + .help = "destroy a plug", + .user_print = monitor_user_noop, + .mhandler.cmd_new = do_plug_destroy, + }, + + { .name = "plug_list", .args_type = "type:s?", .params = "", -- 1.7.4.1