From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com,
agl@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com,
abeekhof@redhat.com
Subject: [Qemu-devel] [RFC][PATCH v4 12/18] virtagent: add agent_ping monitor command
Date: Tue, 16 Nov 2010 10:01:54 -0600 [thread overview]
Message-ID: <1289923320-5638-13-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1289923320-5638-1-git-send-email-mdroth@linux.vnet.ibm.com>
Monitor command to ping the RPC server.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
hmp-commands.hx | 16 ++++++++++
qmp-commands.hx | 32 +++++++++++++++++++++
virtagent.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
virtagent.h | 3 ++
4 files changed, 135 insertions(+), 0 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 3250e41..d3f642f 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1260,6 +1260,22 @@ STEXI
Shutdown/reboot a guest locally
ETEXI
+ {
+ .name = "agent_ping",
+ .args_type = "",
+ .params = "",
+ .help = "Ping a guest",
+ .user_print = do_agent_ping_print,
+ .mhandler.cmd_async = do_agent_ping,
+ .flags = MONITOR_CMD_ASYNC,
+ },
+
+STEXI
+@item agent_ping
+@findex agent_ping
+Ping a guest
+ETEXI
+
STEXI
@end table
ETEXI
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 0f983cc..1e798f5 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -838,6 +838,38 @@ Example:
EQMP
{
+ .name = "agent_ping",
+ .args_type = "",
+ .params = "",
+ .help = "Ping a guest",
+ .user_print = do_agent_ping_print,
+ .mhandler.cmd_async = do_agent_ping,
+ .flags = MONITOR_CMD_ASYNC,
+ },
+
+STEXI
+@item agent_ping
+@findex agent_ping
+Ping a guest
+ETEXI
+SQMP
+agent_ping
+--------
+
+Ping a guest
+
+Arguments:
+
+(none)
+
+Example:
+
+-> { "execute": "agent_ping" }
+<- { "return": { "response":"ok" } }
+
+EQMP
+
+ {
.name = "qmp_capabilities",
.args_type = "",
.params = "",
diff --git a/virtagent.c b/virtagent.c
index a56aeac..9071131 100644
--- a/virtagent.c
+++ b/virtagent.c
@@ -503,3 +503,87 @@ int do_agent_shutdown(Monitor *mon, const QDict *mon_params,
return 0;
}
+
+void do_agent_ping_print(Monitor *mon, const QObject *data)
+{
+ QDict *qdict;
+ const char *response;
+
+ TRACE("called");
+
+ qdict = qobject_to_qdict(data);
+ response = qdict_get_str(qdict, "response");
+ if (qdict_haskey(qdict, "response")) {
+ monitor_printf(mon, "%s", response);
+ }
+
+ monitor_printf(mon, "\n");
+}
+
+static void do_agent_ping_cb(void *opaque)
+{
+ VARPCData *rpc_data = opaque;
+ xmlrpc_value *resp = NULL;
+ xmlrpc_env env;
+ QDict *qdict = qdict_new();
+
+ TRACE("called");
+
+ if (rpc_data->status != VA_RPC_STATUS_OK) {
+ LOG("error handling RPC request");
+ qdict_put(qdict, "response", qstring_from_str("error"));
+ goto out_no_resp;
+ }
+
+ xmlrpc_env_init(&env);
+ resp = xmlrpc_parse_response(&env, rpc_data->resp_xml,
+ rpc_data->resp_xml_len);
+ if (rpc_has_error(&env)) {
+ qdict_put(qdict, "response", qstring_from_str("error"));
+ goto out_no_resp;
+ }
+ qdict_put(qdict, "response", qstring_from_str("ok"));
+
+ xmlrpc_DECREF(resp);
+out_no_resp:
+ if (rpc_data->mon_cb) {
+ rpc_data->mon_cb(rpc_data->mon_data, QOBJECT(qdict));
+ }
+ qobject_decref(QOBJECT(qdict));
+}
+
+/*
+ * do_agent_ping(): Ping a guest
+ */
+int do_agent_ping(Monitor *mon, const QDict *mon_params,
+ MonitorCompletion cb, void *opaque)
+{
+ xmlrpc_env env;
+ xmlrpc_value *params;
+ VARPCData *rpc_data;
+ int ret;
+
+ xmlrpc_env_init(&env);
+
+ params = xmlrpc_build_value(&env, "(n)");
+ if (rpc_has_error(&env)) {
+ return -1;
+ }
+
+ rpc_data = qemu_mallocz(sizeof(VARPCData));
+ rpc_data->cb = do_agent_ping_cb;
+ rpc_data->mon_cb = cb;
+ rpc_data->mon_data = opaque;
+
+ ret = rpc_execute(&env, "va_ping", params, rpc_data);
+ if (ret == -EREMOTE) {
+ monitor_printf(mon, "RPC Failed (%i): %s\n", env.fault_code,
+ env.fault_string);
+ return -1;
+ } else if (ret == -1) {
+ monitor_printf(mon, "RPC communication error\n");
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/virtagent.h b/virtagent.h
index 96c6260..071530c 100644
--- a/virtagent.h
+++ b/virtagent.h
@@ -31,5 +31,8 @@ int do_agent_viewdmesg(Monitor *mon, const QDict *mon_params,
MonitorCompletion cb, void *opaque);
int do_agent_shutdown(Monitor *mon, const QDict *mon_params,
MonitorCompletion cb, void *opaque);
+void do_agent_ping_print(Monitor *mon, const QObject *qobject);
+int do_agent_ping(Monitor *mon, const QDict *mon_params,
+ MonitorCompletion cb, void *opaque);
#endif /* VIRTAGENT_H */
--
1.7.0.4
next prev parent reply other threads:[~2010-11-16 16:02 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-16 16:01 [Qemu-devel] [RFC][PATCH v4 00/18] virtagent: host/guest RPC communication agent Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 01/18] virtagent: add common rpc transport defs Michael Roth
2010-11-18 13:53 ` Jes Sorensen
2010-11-18 16:33 ` Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 02/18] virtagent: base definitions for host/guest RPC server Michael Roth
2010-11-18 13:57 ` Jes Sorensen
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 03/18] virtagent: qemu-vp, integrate virtagent server Michael Roth
2010-11-18 14:02 ` Jes Sorensen
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 04/18] virtagent: base RPC client definitions Michael Roth
2010-11-18 14:10 ` Jes Sorensen
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 05/18] virtagent: add getfile RPC Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 06/18] virtagent: add agent_viewfile command Michael Roth
2010-11-18 14:13 ` Jes Sorensen
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 07/18] virtagent: add getdmesg RPC Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 08/18] virtagent: add agent_viewdmesg command Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 09/18] virtagent: add va_shutdown RPC Michael Roth
2010-11-18 14:17 ` Jes Sorensen
2010-11-18 15:35 ` Anthony Liguori
2010-11-18 15:41 ` Jes Sorensen
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 10/18] virtagent: add agent_shutdown monitor command Michael Roth
2010-11-18 14:19 ` Jes Sorensen
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 11/18] virtagent: add va_ping RPC Michael Roth
2010-11-16 16:01 ` Michael Roth [this message]
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 13/18] virtagent: add agent_capabilities monitor function Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 14/18] virtagent: add client capabilities init function Michael Roth
2010-11-18 14:22 ` Jes Sorensen
2010-11-18 16:43 ` Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 15/18] virtagent: add va_hello RPC function Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 16/18] virtagent: add va_send_hello() client function Michael Roth
2010-11-16 16:01 ` [Qemu-devel] [RFC][PATCH v4 17/18] virtagent: qemu-vp, va_send_hello() on startup Michael Roth
2010-11-18 14:22 ` Jes Sorensen
2010-11-16 16:02 ` [Qemu-devel] [RFC][PATCH v4 18/18] virtagent: Makefile/configure changes to build virtagent bits Michael Roth
2010-11-18 13:50 ` [Qemu-devel] [RFC][PATCH v4 00/18] virtagent: host/guest RPC communication agent Jes Sorensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1289923320-5638-13-git-send-email-mdroth@linux.vnet.ibm.com \
--to=mdroth@linux.vnet.ibm.com \
--cc=abeekhof@redhat.com \
--cc=agl@linux.vnet.ibm.com \
--cc=aliguori@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=ryanh@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).