Signed-off-by: Anthony Liguori <aligu...@us.ibm.com> --- monitor.c | 25 +++++++++++++++++++++++++ qmp-commands.hx | 9 +++++++++ 2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/monitor.c b/monitor.c index 8406b5b..f17eb3a 100644 --- a/monitor.c +++ b/monitor.c @@ -1069,6 +1069,31 @@ static int do_plug_create(Monitor *mon, const QDict *qdict, QObject **ret_data) return 0; } +static int do_plug_list(Monitor *mon, const QDict *qdict, QObject **ret_data) +{ + QList *qlist = qlist_new(); + const char *type = qdict_get_try_str(qdict, "type"); + GSList *i; + + for (i = global_plug_list; i; i = i->next) { + TypeInstance *obj = i->data; + QDict *item = qdict_new(); + + if (type && !type_is_type(obj, type)) { + continue; + } + + qdict_put(item, "id", qstring_from_str(type_get_id(obj))); + qdict_put(item, "type", qstring_from_str(type_get_type(obj))); + + qlist_append(qlist, item); + } + + *ret_data = QOBJECT(qlist); + + return 0; +} + #ifdef CONFIG_VNC static int change_vnc_password(const char *password) { diff --git a/qmp-commands.hx b/qmp-commands.hx index c86d396..16f3f4d 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -112,6 +112,15 @@ Notes: EQMP { + .name = "plug_list", + .args_type = "type:s?", + .params = "", + .help = "list plugs", + .user_print = monitor_user_noop, + .mhandler.cmd_new = do_plug_list, + }, + + { .name = "eject", .args_type = "force:-f,device:B", .params = "[-f] device", -- 1.7.4.1