From patchwork Fri Dec 3 18:03:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 74200 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BD3D6B708B for ; Sat, 4 Dec 2010 05:53:52 +1100 (EST) Received: from localhost ([127.0.0.1]:43687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POa8a-0005Vv-Lj for incoming@patchwork.ozlabs.org; Fri, 03 Dec 2010 13:13:40 -0500 Received: from [140.186.70.92] (port=44487 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POZzI-000237-RN for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:04:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1POZzG-0003E9-H8 for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:04:04 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:38077) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1POZzG-0003E4-DV for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:04:02 -0500 Received: from d01dlp01.pok.ibm.com (d01dlp01.pok.ibm.com [9.56.224.56]) by e7.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oB3HkbCC020406 for ; Fri, 3 Dec 2010 12:46:37 -0500 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 538FC728047 for ; Fri, 3 Dec 2010 13:04:01 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oB3I3wHK1822800 for ; Fri, 3 Dec 2010 13:03:58 -0500 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oB3I3wAV013567 for ; Fri, 3 Dec 2010 13:03:58 -0500 Received: from localhost.localdomain (sig-9-65-101-53.mts.ibm.com [9.65.101.53]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id oB3I3S9g011647; Fri, 3 Dec 2010 13:03:57 -0500 From: Michael Roth To: qemu-devel@nongnu.org Date: Fri, 3 Dec 2010 12:03:10 -0600 Message-Id: <1291399402-20366-10-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1291399402-20366-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1291399402-20366-1-git-send-email-mdroth@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: agl@linux.vnet.ibm.com, stefanha@linux.vnet.ibm.com, Jes.Sorensen@redhat.com, mdroth@linux.vnet.ibm.com, aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com, abeekhof@redhat.com Subject: [Qemu-devel] [RFC][PATCH v5 09/21] virtagent: add va.getdmesg RPC X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add RPC to view guest dmesg output. Signed-off-by: Michael Roth --- 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[] = {