From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlAEH-0003xl-JN for qemu-devel@nongnu.org; Sun, 24 Jul 2011 21:45:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QlAEF-0005Vv-4t for qemu-devel@nongnu.org; Sun, 24 Jul 2011 21:45:09 -0400 Received: from e6.ny.us.ibm.com ([32.97.182.146]:44843) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlAEE-0005UT-1l for qemu-devel@nongnu.org; Sun, 24 Jul 2011 21:45:06 -0400 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by e6.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p6P1KwMU027320 for ; Sun, 24 Jul 2011 21:20:58 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p6P1j4g81691762 for ; Sun, 24 Jul 2011 21:45:04 -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 p6P1j4li007750 for ; Sun, 24 Jul 2011 21:45:04 -0400 From: Anthony Liguori Date: Sun, 24 Jul 2011 20:44:43 -0500 Message-Id: <1311558293-5855-12-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 11/21] qom: add plug_set 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 | 33 +++++++++++++++++++++++++++++++++ qmp-commands.hx | 9 +++++++++ 2 files changed, 42 insertions(+), 0 deletions(-) diff --git a/monitor.c b/monitor.c index 1937e9f..47011dd 100644 --- a/monitor.c +++ b/monitor.c @@ -1129,6 +1129,39 @@ static int do_plug_get(Monitor *mon, const QDict *qdict, QObject **ret_data) return 0; } +static int do_plug_set(Monitor *mon, const QDict *qdict, QObject **ret_data) +{ + const char *id = qdict_get_str(qdict, "id"); + const char *name = qdict_get_str(qdict, "name"); + QObject *value = qdict_get(qdict, "value"); + Error *local_err = NULL; + QmpInputVisitor *qiv; + TypeInstance *inst; + Plug *plug; + Visitor *v; + + qiv = qmp_input_visitor_new(value); + v = qmp_input_get_visitor(qiv); + + inst = type_find_by_id(id); + if (inst == NULL) { + return -1; + } + + plug = PLUG(inst); + + plug_set_property(plug, name, v, &local_err); + if (local_err) { + error_free(local_err); + qmp_input_visitor_cleanup(qiv); + return -1; + } + + qmp_input_visitor_cleanup(qiv); + + return 0; +} + #ifdef CONFIG_VNC static int change_vnc_password(const char *password) { diff --git a/qmp-commands.hx b/qmp-commands.hx index 822d422..1d7e87b 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -130,6 +130,15 @@ EQMP }, { + .name = "plug_set", + .args_type = "options:O", + .params = "", + .help = "set plug property", + .user_print = monitor_user_noop, + .mhandler.cmd_new = do_plug_set, + }, + + { .name = "eject", .args_type = "force:-f,device:B", .params = "[-f] device", -- 1.7.4.1