[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC][PATCH v5 09/21] virtagent: add va.getdmesg RPC
From: |
Michael Roth |
Subject: |
[Qemu-devel] [RFC][PATCH v5 09/21] virtagent: add va.getdmesg RPC |
Date: |
Fri, 3 Dec 2010 12:03:10 -0600 |
Add RPC to view guest dmesg output.
Signed-off-by: Michael Roth <address@hidden>
---
virtagent-server.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/virtagent-server.c b/virtagent-server.c
index a430b58..aac8f70 100644
--- a/virtagent-server.c
+++ b/virtagent-server.c
@@ -83,6 +83,50 @@ EXIT_CLOSE_BAD:
return result;
}
+/* va_getdmesg(): return dmesg output
+ * rpc return values:
+ * - dmesg output as a string
+ */
+static xmlrpc_value *va_getdmesg(xmlrpc_env *env,
+ xmlrpc_value *param,
+ void *user_data)
+{
+ char *dmesg_buf = NULL, cmd[256];
+ int ret;
+ xmlrpc_value *result = NULL;
+ FILE *pipe;
+
+ SLOG("va_getdmesg()");
+
+ 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;
+}
+
typedef struct RPCFunction {
xmlrpc_value *(*func)(xmlrpc_env *env, xmlrpc_value *param, void *unused);
const char *func_name;
@@ -91,6 +135,8 @@ typedef struct RPCFunction {
static RPCFunction guest_functions[] = {
{ .func = va_getfile,
.func_name = "va.getfile" },
+ { .func = va_getdmesg,
+ .func_name = "va.getdmesg" },
{ NULL, NULL }
};
static RPCFunction host_functions[] = {
--
1.7.0.4
- Re: [Qemu-devel] Re: [RFC][PATCH v5 03/21] virtagent: common code for managing client/server rpc jobs, (continued)
- [Qemu-devel] [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Michael Roth, 2010/12/03
- [Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Adam Litke, 2010/12/06
- [Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Jes Sorensen, 2010/12/07
- [Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Adam Litke, 2010/12/07
- [Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Jes Sorensen, 2010/12/08
- [Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Adam Litke, 2010/12/09
- [Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Michael Roth, 2010/12/09
- [Qemu-devel] Re: [RFC][PATCH v5 07/21] virtagent: add va.getfile RPC, Jes Sorensen, 2010/12/10
[Qemu-devel] [RFC][PATCH v5 09/21] virtagent: add va.getdmesg RPC,
Michael Roth <=
[Qemu-devel] [RFC][PATCH v5 08/21] virtagent: add agent_viewfile qmp/hmp command, Michael Roth, 2010/12/03