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 08/10] virtagent: add agent_viewdmesg command
Date: Fri, 22 Oct 2010 13:46:03 -0500 [thread overview]
Message-ID: <1287773165-24855-9-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1287773165-24855-1-git-send-email-mdroth@linux.vnet.ibm.com>
Add commands to view guest dmesg output. Currently it is a 16K buffer.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
hmp-commands.hx | 16 +++++++++
qmp-commands.hx | 35 +++++++++++++++++++
virtagent.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
virtagent.h | 3 ++
4 files changed, 154 insertions(+), 0 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index e9a7f4a..0e7a6c9 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1227,6 +1227,22 @@ STEXI
Echo the file identified by @var{filepath} on the guest filesystem
ETEXI
+ {
+ .name = "agent_viewdmesg",
+ .args_type = "",
+ .params = "",
+ .help = "View guest dmesg output",
+ .user_print = do_agent_viewdmesg_print,
+ .mhandler.cmd_async = do_agent_viewdmesg,
+ .flags = MONITOR_CMD_ASYNC,
+ },
+
+STEXI
+@item agent_viewdmesg
+@findex agent_viewdmesg
+View guest dmesg output
+ETEXI
+
STEXI
@end table
ETEXI
diff --git a/qmp-commands.hx b/qmp-commands.hx
index efa2137..dc319b7 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -771,6 +771,41 @@ Example:
EQMP
{
+ .name = "agent_viewdmesg",
+ .args_type = "",
+ .params = "",
+ .help = "View guest dmesg output",
+ .user_print = do_agent_viewdmesg_print,
+ .mhandler.cmd_async = do_agent_viewdmesg,
+ .flags = MONITOR_CMD_ASYNC,
+ },
+
+STEXI
+@item agent_viewdmesg
+@findex agent_viewdmesg
+View guest dmesg output
+ETEXI
+SQMP
+agent_viewdmesg
+--------
+
+View guest dmesg output
+
+Arguments:
+
+(none)
+
+Example:
+
+-> { "execute": "agent_viewdmesg" }
+<- { "return": {
+ "contents": "[353487.942215] usb 1-4: USB disconnect, address 9\n..."
+ }
+ }
+
+EQMP
+
+ {
.name = "qmp_capabilities",
.args_type = "",
.params = "",
diff --git a/virtagent.c b/virtagent.c
index 8059d00..cae9a85 100644
--- a/virtagent.c
+++ b/virtagent.c
@@ -196,3 +196,103 @@ int do_agent_viewfile(Monitor *mon, const QDict *mon_params,
return 0;
}
+
+void do_agent_viewdmesg_print(Monitor *mon, const QObject *data)
+{
+ QDict *qdict;
+ const char *contents = NULL;
+ int i;
+
+ qdict = qobject_to_qdict(data);
+ if (!qdict_haskey(qdict, "contents")) {
+ return;
+ }
+
+ contents = qdict_get_str(qdict, "contents");
+ if (contents != NULL) {
+ /* monitor_printf truncates so do it in chunks. also, file_contents
+ * may not be null-termed at proper location so explicitly calc
+ * last chunk sizes */
+ for (i = 0; i < strlen(contents); i += 1024) {
+ monitor_printf(mon, "%.1024s", contents + i);
+ }
+ }
+ monitor_printf(mon, "\n");
+}
+
+static void do_agent_viewdmesg_cb(void *opaque)
+{
+ RPCRequest *rpc_data = opaque;
+ xmlrpc_value *resp = NULL;
+ char *dmesg = NULL;
+ int ret;
+ xmlrpc_env env;
+ QDict *qdict = qdict_new();
+
+ if (rpc_data->resp_xml == NULL) {
+ monitor_printf(rpc_data->mon, "error handling RPC request");
+ 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)) {
+ ret = -1;
+ goto out_no_resp;
+ }
+
+ xmlrpc_parse_value(&env, resp, "s", &dmesg);
+ if (rpc_has_error(&env)) {
+ ret = -1;
+ goto out;
+ }
+
+ if (dmesg != NULL) {
+ qdict_put(qdict, "contents", qstring_from_str(dmesg));
+ }
+
+out:
+ qemu_free(rpc_data->resp_xml);
+ xmlrpc_DECREF(resp);
+out_no_resp:
+ rpc_data->mon_cb(rpc_data->mon_data, QOBJECT(qdict));
+ qemu_free(rpc_data);
+}
+
+/*
+ * do_agent_viewdmesg(): View guest dmesg output
+ */
+int do_agent_viewdmesg(Monitor *mon, const QDict *mon_params,
+ MonitorCompletion cb, void *opaque)
+{
+ xmlrpc_env env;
+ xmlrpc_value *params;
+ RPCRequest *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(RPCRequest));
+ rpc_data->cb = do_agent_viewdmesg_cb;
+ rpc_data->mon = mon;
+ rpc_data->mon_cb = cb;
+ rpc_data->mon_data = opaque;
+
+ ret = rpc_execute(&env, "getdmesg", 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 d027eac..82a6924 100644
--- a/virtagent.h
+++ b/virtagent.h
@@ -25,5 +25,8 @@
void do_agent_viewfile_print(Monitor *mon, const QObject *qobject);
int do_agent_viewfile(Monitor *mon, const QDict *mon_params,
MonitorCompletion cb, void *opaque);
+void do_agent_viewdmesg_print(Monitor *mon, const QObject *qobject);
+int do_agent_viewdmesg(Monitor *mon, const QDict *mon_params,
+ MonitorCompletion cb, void *opaque);
#endif /* VIRTAGENT_H */
--
1.7.0.4
next prev parent reply other threads:[~2010-10-22 18:46 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-22 18:45 [Qemu-devel] [RFC][PATCH 00/10] virtagent: host/guest RPC communication agent Michael Roth
2010-10-22 18:45 ` [Qemu-devel] [RFC][PATCH 01/10] virtagent: add common rpc transport defs Michael Roth
2010-10-25 21:39 ` Anthony Liguori
2010-10-25 21:54 ` malc
2010-10-25 22:02 ` Anthony Liguori
2010-10-25 22:32 ` malc
2010-10-22 18:45 ` [Qemu-devel] [RFC][PATCH 02/10] virtagent: base definitions for host/guest RPC daemon Michael Roth
2010-10-22 18:45 ` [Qemu-devel] [RFC][PATCH 03/10] virtagent: qemu-vp, integrate virtagent daemon Michael Roth
2010-10-22 18:45 ` [Qemu-devel] [RFC][PATCH 04/10] virtagent: base RPC client definitions Michael Roth
2010-10-22 18:46 ` [Qemu-devel] [RFC][PATCH 05/10] virtagent: add getfile RPC Michael Roth
2010-10-22 18:46 ` [Qemu-devel] [RFC][PATCH 06/10] virtagent: add agent_viewfile command Michael Roth
2010-10-22 18:46 ` [Qemu-devel] [RFC][PATCH 07/10] virtagent: add getdmesg RPC Michael Roth
2010-10-25 21:42 ` Anthony Liguori
2010-10-22 18:46 ` Michael Roth [this message]
2010-10-22 18:46 ` [Qemu-devel] [RFC][PATCH 09/10] virtagent: Makefile/configure changes to build virtagent bits Michael Roth
2010-10-22 18:46 ` [Qemu-devel] [RFC][PATCH 10/10] virtproxy: add compat defs for linking against vl.c Michael Roth
2010-10-23 11:31 ` [Qemu-devel] Re: [RFC][PATCH 00/10] virtagent: host/guest RPC communication agent Andrew Beekhof
2010-10-23 14:41 ` Michael Roth
2010-10-25 9:46 ` Andrew Beekhof
2010-10-25 10:30 ` Andrew Beekhof
2010-10-25 17:06 ` Michael Roth
2010-10-26 7:14 ` Andrew Beekhof
2010-10-25 21:28 ` Anthony Liguori
2010-10-26 7:27 ` Andrew Beekhof
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=1287773165-24855-9-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).