From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: agl@linux.vnet.ibm.com, abeekhof@redhat.com,
mdroth@linux.vnet.ibm.com, aliguori@linux.vnet.ibm.com,
ryanh@us.ibm.com, amit.shah@redhat.com
Subject: [Qemu-devel] [RFC][PATCH v3 07/11] virtagent: add getdmesg RPC
Date: Wed, 10 Nov 2010 19:37:26 -0600 [thread overview]
Message-ID: <1289439450-23556-8-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1289439450-23556-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 3615e8a..51e4e0f 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 6c3436a..09b0097 100644
--- a/virtagent-daemon.h
+++ b/virtagent-daemon.h
@@ -18,5 +18,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_init(VPDriver *vp_drv, bool is_host);
--
1.7.0.4
next prev parent reply other threads:[~2010-11-11 1:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-11 1:37 [Qemu-devel] [RFC][PATCH v3 00/11] virtagent: host/guest RPC communication agent Michael Roth
2010-11-11 1:37 ` [Qemu-devel] [RFC][PATCH v3 01/11] virtagent: add common rpc transport defs Michael Roth
2010-11-11 1:37 ` [Qemu-devel] [RFC][PATCH v3 02/11] virtagent: base definitions for host/guest RPC server Michael Roth
2010-11-11 1:37 ` [Qemu-devel] [RFC][PATCH v3 03/11] virtagent: qemu-vp, integrate virtagent server Michael Roth
2010-11-11 1:37 ` [Qemu-devel] [RFC][PATCH v3 04/11] virtagent: base RPC client definitions Michael Roth
2010-11-11 1:37 ` [Qemu-devel] [RFC][PATCH v3 05/11] virtagent: add getfile RPC Michael Roth
2010-11-11 1:37 ` [Qemu-devel] [RFC][PATCH v3 06/11] virtagent: add agent_viewfile command Michael Roth
2010-11-11 1:37 ` Michael Roth [this message]
2010-11-11 1:37 ` [Qemu-devel] [RFC][PATCH v3 08/11] virtagent: add agent_viewdmesg command Michael Roth
2010-11-11 1:37 ` [Qemu-devel] [RFC][PATCH v3 09/11] virtagent: qemu-vp integration, use virtagent init functions Michael Roth
2010-11-11 1:37 ` [Qemu-devel] [RFC][PATCH v3 10/11] virtagent: qemu integration, add va invocation via virtproxy chardev Michael Roth
2010-11-11 1:37 ` [Qemu-devel] [RFC][PATCH v3 11/11] virtagent: Makefile/configure changes to build virtagent bits Michael Roth
2010-11-25 9:39 ` [Qemu-devel] Re: [RFC][PATCH v3 00/11] virtagent: host/guest RPC communication agent Amit Shah
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=1289439450-23556-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=amit.shah@redhat.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).