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 07/10] virtagent: add getdmesg RPC
Date: Fri, 22 Oct 2010 13:46:02 -0500 [thread overview]
Message-ID: <1287773165-24855-8-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1287773165-24855-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 | 45 +++++++++++++++++++++++++++++++++++++++++++++
virtagent-daemon.h | 1 +
2 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/virtagent-daemon.c b/virtagent-daemon.c
index fad0f64..6aaa987 100644
--- a/virtagent-daemon.c
+++ b/virtagent-daemon.c
@@ -72,6 +72,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];
+ char c;
+ int pos = 0;
+ 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");
+ pipe = popen("dmesg -s 16000", "r");
+ if (pipe == NULL) {
+ LOG("popen failed: %s", strerror(errno));
+ xmlrpc_faultf(env, "popen failed: %s", strerror(errno));
+ goto EXIT_NOCLOSE;
+ }
+
+ while ((c = fgetc(pipe)) != EOF && pos < VA_DMESG_LEN) {
+ dmesg_buf[pos] = c;
+ pos++;
+ }
+ dmesg_buf[pos++] = '\0';
+ TRACE("dmesg:\n%s", dmesg_buf);
+
+ result = xmlrpc_build_value(env, "s", dmesg_buf);
+ 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;
@@ -101,6 +143,8 @@ typedef struct RPCFunction {
static RPCFunction guest_functions[] = {
{ .func = getfile,
.func_name = "getfile" },
+ { .func = getdmesg,
+ .func_name = "getdmesg" },
{ NULL, NULL }
};
static RPCFunction host_functions[] = {
@@ -165,6 +209,7 @@ int va_server_loop(int listen_fd, bool is_host)
XMLRPC_MEMBLOCK_FREE(char, rpc_response);
out:
closesocket(fd);
+ xmlrpc_env_clean(&env);
}
return 0;
diff --git a/virtagent-daemon.h b/virtagent-daemon.h
index bb197d0..adcbc9a 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_loop(int listen_fd, bool is_host);
--
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 ` Michael Roth [this message]
2010-10-25 21:42 ` [Qemu-devel] [RFC][PATCH 07/10] virtagent: add getdmesg RPC Anthony Liguori
2010-10-22 18:46 ` [Qemu-devel] [RFC][PATCH 08/10] virtagent: add agent_viewdmesg command Michael Roth
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-8-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).