From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:55256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlAFR-0006ho-Fr for qemu-devel@nongnu.org; Sun, 24 Jul 2011 21:46:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QlAFQ-0005pQ-HT for qemu-devel@nongnu.org; Sun, 24 Jul 2011 21:46:21 -0400 Received: from e2.ny.us.ibm.com ([32.97.182.142]:50366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlAFQ-0005pM-Ex for qemu-devel@nongnu.org; Sun, 24 Jul 2011 21:46:20 -0400 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by e2.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p6P1P5gb022323 for ; Sun, 24 Jul 2011 21:25:05 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p6P1j3c3151036 for ; Sun, 24 Jul 2011 21:45:03 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p6P1j3wB007666 for ; Sun, 24 Jul 2011 21:45:03 -0400 From: Anthony Liguori Date: Sun, 24 Jul 2011 20:44:41 -0500 Message-Id: <1311558293-5855-10-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1311558293-5855-1-git-send-email-aliguori@us.ibm.com> References: <1311558293-5855-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 09/21] qom: add plug_list QMP command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori Signed-off-by: Anthony Liguori --- 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