From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@linux.vnet.ibm.com, agl@linux.vnet.ibm.com,
mdroth@linux.vnet.ibm.com
Subject: [Qemu-devel] [RFC][PATCH v2 07/10] virtagent: add getdmesg RPC
Date: Wed, 3 Nov 2010 06:35:36 -0500 [thread overview]
Message-ID: <1288784139-1110-8-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1288784139-1110-1-git-send-email-mdroth@linux.vnet.ibm.com>
Add RPC to view guest dmesg output.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
virtagent-daemon.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
virtagent-daemon.h | 1 +
2 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/virtagent-daemon.c b/virtagent-daemon.c
index bf28be2..181edac 100644
--- a/virtagent-daemon.c
+++ b/virtagent-daemon.c
@@ -66,6 +66,48 @@ EXIT_CLOSE_BAD:
return result;
}
+/* getdmesg(): return dmesg output
+ * rpc return values:
+ * - dmesg output as a string
+ */
+static xmlrpc_value *getdmesg(xmlrpc_env *env,
+ xmlrpc_value *param,
+ void *user_data)
+{
+ char *dmesg_buf = NULL, cmd[256];
+ int ret;
+ xmlrpc_value *result = NULL;
+ FILE *pipe;
+
+ dmesg_buf = qemu_mallocz(VA_DMESG_LEN + 2048);
+ sprintf(cmd, "dmesg -s %d", VA_DMESG_LEN);
+
+ pipe = popen(cmd, "r");
+ if (pipe == NULL) {
+ LOG("popen failed: %s", strerror(errno));
+ xmlrpc_faultf(env, "popen failed: %s", strerror(errno));
+ goto EXIT_NOCLOSE;
+ }
+
+ ret = fread(dmesg_buf, sizeof(char), VA_DMESG_LEN, pipe);
+ if (!ferror(pipe)) {
+ dmesg_buf[ret] = '\0';
+ TRACE("dmesg:\n%s", dmesg_buf);
+ result = xmlrpc_build_value(env, "s", dmesg_buf);
+ } else {
+ LOG("fread failed");
+ xmlrpc_faultf(env, "popen failed: %s", strerror(errno));
+ }
+
+ pclose(pipe);
+EXIT_NOCLOSE:
+ if (dmesg_buf) {
+ qemu_free(dmesg_buf);
+ }
+
+ return result;
+}
+
static int va_accept(int listen_fd) {
struct sockaddr_in saddr;
struct sockaddr *addr;
@@ -95,6 +137,8 @@ typedef struct RPCFunction {
static RPCFunction guest_functions[] = {
{ .func = getfile,
.func_name = "getfile" },
+ { .func = getdmesg,
+ .func_name = "getdmesg" },
{ NULL, NULL }
};
static RPCFunction host_functions[] = {
diff --git a/virtagent-daemon.h b/virtagent-daemon.h
index da926b3..d19f8e3 100644
--- a/virtagent-daemon.h
+++ b/virtagent-daemon.h
@@ -16,5 +16,6 @@
#define HOST_AGENT_PATH "/tmp/virtagent-host.sock"
#define VA_GETFILE_MAX 1 << 30
#define VA_FILEBUF_LEN 16384
+#define VA_DMESG_LEN 16384
int va_server_start(int listen_fd, bool is_host);
--
1.7.0.4
next prev parent reply other threads:[~2010-11-03 11:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-03 11:35 [Qemu-devel] [RFC][PATCH v2 00/10] virtagent: host/guest RPC communication agent Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 01/10] virtagent: add common rpc transport defs Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 02/10] virtagent: base definitions for host/guest RPC daemon Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 03/10] virtagent: qemu-vp, integrate virtagent server Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 04/10] virtagent: base RPC client definitions Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 05/10] virtagent: add getfile RPC Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 06/10] virtagent: add agent_viewfile command Michael Roth
2010-11-03 11:35 ` Michael Roth [this message]
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 08/10] virtagent: add agent_viewdmesg command Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 09/10] virtagent: Makefile/configure changes to build virtagent bits Michael Roth
2010-11-03 11:35 ` [Qemu-devel] [RFC][PATCH v2 10/10] virtproxy: add compat defs for linking against vl.c Michael Roth
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=1288784139-1110-8-git-send-email-mdroth@linux.vnet.ibm.com \
--to=mdroth@linux.vnet.ibm.com \
--cc=agl@linux.vnet.ibm.com \
--cc=aliguori@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/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).