From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=48130 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQ1Og-00068C-0U for qemu-devel@nongnu.org; Tue, 07 Dec 2010 12:32:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PQ1Oe-0007NK-L3 for qemu-devel@nongnu.org; Tue, 07 Dec 2010 12:32:13 -0500 Received: from e5.ny.us.ibm.com ([32.97.182.145]:49451) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PQ1Oe-0007Mh-I8 for qemu-devel@nongnu.org; Tue, 07 Dec 2010 12:32:12 -0500 Received: from d01dlp02.pok.ibm.com (d01dlp02.pok.ibm.com [9.56.224.85]) by e5.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oB7H9uT0007042 for ; Tue, 7 Dec 2010 12:09:59 -0500 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 7B6BC4DE8041 for ; Tue, 7 Dec 2010 12:30:18 -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 oB7HW6Ge2355358 for ; Tue, 7 Dec 2010 12:32:06 -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 oB7HW5lk011605 for ; Tue, 7 Dec 2010 12:32:06 -0500 Message-ID: <4CFE6F94.7090208@linux.vnet.ibm.com> Date: Tue, 07 Dec 2010 11:32:04 -0600 From: Michael Roth MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [RFC][PATCH v5 09/21] virtagent: add va.getdmesg RPC References: <1291399402-20366-1-git-send-email-mdroth@linux.vnet.ibm.com> <1291399402-20366-10-git-send-email-mdroth@linux.vnet.ibm.com> <4CFE4699.5070000@redhat.com> In-Reply-To: <4CFE4699.5070000@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jes Sorensen Cc: agl@linux.vnet.ibm.com, stefanha@linux.vnet.ibm.com, abeekhof@redhat.com, qemu-devel@nongnu.org, aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com On 12/07/2010 08:37 AM, Jes Sorensen wrote: > On 12/03/10 19:03, Michael Roth wrote: >> 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); > > What happens if the guest's dmesg buffer is larger than your hardcoded > value? It'll end up getting truncated by the fread() later: ret = fread(dmesg_buf, sizeof(char), VA_DMESG_LEN, pipe); That's where the dmesg -s VA_DMESG_LEN comes into play, it should size things such that we can buffer up till the end of the dmesg output. This param is kind of quirky though, size doesn't seem to have an affect for anything below 4KB, but if we stick with VA_DMESG_LEN >= 4KB this should cover us, unless it's a distro-specific. But it should blow anything up, at least. > > Jes > >