From patchwork Mon Jul 25 01:44:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 106592 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3B874B6F7D for ; Mon, 25 Jul 2011 12:22:43 +1000 (EST) Received: from localhost ([::1]:55556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlAFB-0005kt-W1 for incoming@patchwork.ozlabs.org; Sun, 24 Jul 2011 21:46:05 -0400 Received: from eggs.gnu.org ([140.186.70.92]:42396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlAEN-00040B-GD for qemu-devel@nongnu.org; Sun, 24 Jul 2011 21:45:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QlAEF-0005Wg-Hx for qemu-devel@nongnu.org; Sun, 24 Jul 2011 21:45:09 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:60617) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlAEE-0005VD-PO for qemu-devel@nongnu.org; Sun, 24 Jul 2011 21:45:07 -0400 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e7.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p6P1JVKO022697 for ; Sun, 24 Jul 2011 21:19:31 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p6P1j5fm136800 for ; Sun, 24 Jul 2011 21:45:05 -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 p6P1j5F9007793 for ; Sun, 24 Jul 2011 21:45:05 -0400 Received: from titi.austin.rr.com (sig-9-65-207-230.mts.ibm.com [9.65.207.230]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p6P1itKr006824; Sun, 24 Jul 2011 21:45:04 -0400 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Sun, 24 Jul 2011 20:44:44 -0500 Message-Id: <1311558293-5855-13-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1311558293-5855-1-git-send-email-aliguori@us.ibm.com> References: <1311558293-5855-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 32.97.182.137 Cc: Anthony Liguori Subject: [Qemu-devel] [PATCH 12/21] qom: add plug_list_props QMP command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Anthony Liguori --- monitor.c | 35 +++++++++++++++++++++++++++++++++++ qmp-commands.hx | 9 +++++++++ 2 files changed, 44 insertions(+), 0 deletions(-) diff --git a/monitor.c b/monitor.c index 47011dd..e53808a 100644 --- a/monitor.c +++ b/monitor.c @@ -1162,6 +1162,41 @@ static int do_plug_set(Monitor *mon, const QDict *qdict, QObject **ret_data) return 0; } +static void plug_list_props_tramp(Plug *plug, const char *name, const char *typename, int flags, void *opaque) +{ + QList *qlist = opaque; + QDict *item = qdict_new(); + + qdict_put(item, "name", qstring_from_str(name)); + qdict_put(item, "type", qstring_from_str(typename)); + qdict_put(item, "readable", qbool_from_int(!!(flags & PROP_F_READ))); + qdict_put(item, "writeable", qbool_from_int(!!(flags & PROP_F_WRITE))); + qdict_put(item, "locked", qbool_from_int(!!(flags & PROP_F_LOCKED))); + + qlist_append(qlist, item); +} + +static int do_plug_list_props(Monitor *mon, const QDict *qdict, QObject **ret_data) +{ + const char *id = qdict_get_str(qdict, "id"); + QList *qlist = qlist_new(); + TypeInstance *inst; + Plug *plug; + + inst = type_find_by_id(id); + if (inst == NULL) { + return -1; + } + + plug = PLUG(inst); + + plug_foreach_property(plug, plug_list_props_tramp, qlist); + + *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 1d7e87b..6f1091b 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -139,6 +139,15 @@ EQMP }, { + .name = "plug_list_props", + .args_type = "id:s", + .params = "", + .help = "list plug properties", + .user_print = monitor_user_noop, + .mhandler.cmd_new = do_plug_list_props, + }, + + { .name = "eject", .args_type = "force:-f,device:B", .params = "[-f] device",