From: Keir Fraser Subject: Re: libxc: fix bug of xc_tbuf_get_size() Date: Wed, 10 Feb 2010 09:17:14 +0000 Message-ID: References: <4B713F85.5040103@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4B713F85.5040103@cn.fujitsu.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Yu Zhiguo , "xen-devel@lists.xensource.com" Cc: George Dunlap List-Id: xen-devel@lists.xenproject.org When did this change, and who changed it? It would be good to collect an appropriate Ack, e.g., from George Dunlap, if it was his xentrace changes. I can't take un-acked patches from non-maintainers on stuff I don't have good knowledge of myself, this late in the release cycle. -- Keir On 09/02/2010 10:57, "Yu Zhiguo" wrote: > The size in pages of trace buffer should be t_info->tbuf_size > rather than t_info pages. > > Signed-off-by: Yu Zhiguo > > diff --git a/tools/libxc/xc_tbuf.c b/tools/libxc/xc_tbuf.c > --- a/tools/libxc/xc_tbuf.c > +++ b/tools/libxc/xc_tbuf.c > @@ -15,6 +15,7 @@ > */ > > #include "xc_private.h" > +#include > > static int tbuf_enable(int xc_handle, int enable) > { > @@ -44,6 +45,7 @@ > > int xc_tbuf_get_size(int xc_handle, unsigned long *size) > { > + struct t_info *t_info; > int rc; > DECLARE_SYSCTL; > > @@ -52,9 +54,19 @@ > sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_get_info; > > rc = xc_sysctl(xc_handle, &sysctl); > - if (rc == 0) > - *size = sysctl.u.tbuf_op.size; > - return rc; > + if ( rc != 0 ) > + return rc; > + > + t_info = xc_map_foreign_range(xc_handle, DOMID_XEN, > + sysctl.u.tbuf_op.size, PROT_READ | PROT_WRITE, > + sysctl.u.tbuf_op.buffer_mfn); > + > + if ( t_info == NULL || t_info->tbuf_size == 0 ) > + return -1; > + > + *size = t_info->tbuf_size; > + > + return 0; > } > > int xc_tbuf_enable(int xc_handle, unsigned long pages, unsigned long *mfn, >