debuggers.hg

changeset 20968:4b2aa9c350e6

libxc: fix bug in xc_tbuf_get_size()

The size in pages of trace buffer should be t_info->tbuf_size
rather than t_info pages.

Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Feb 10 13:30:16 2010 +0000 (2010-02-10)
parents f5fba6214a20
children b4ad00da6960
files tools/libxc/xc_tbuf.c
line diff
     1.1 --- a/tools/libxc/xc_tbuf.c	Wed Feb 10 13:27:55 2010 +0000
     1.2 +++ b/tools/libxc/xc_tbuf.c	Wed Feb 10 13:30:16 2010 +0000
     1.3 @@ -15,6 +15,7 @@
     1.4   */
     1.5  
     1.6  #include "xc_private.h"
     1.7 +#include <xen/trace.h>
     1.8  
     1.9  static int tbuf_enable(int xc_handle, int enable)
    1.10  {
    1.11 @@ -44,6 +45,7 @@ int xc_tbuf_set_size(int xc_handle, unsi
    1.12  
    1.13  int xc_tbuf_get_size(int xc_handle, unsigned long *size)
    1.14  {
    1.15 +    struct t_info *t_info;
    1.16      int rc;
    1.17      DECLARE_SYSCTL;
    1.18  
    1.19 @@ -52,9 +54,19 @@ int xc_tbuf_get_size(int xc_handle, unsi
    1.20      sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_get_info;
    1.21  
    1.22      rc = xc_sysctl(xc_handle, &sysctl);
    1.23 -    if (rc == 0)
    1.24 -        *size = sysctl.u.tbuf_op.size;
    1.25 -    return rc;
    1.26 +    if ( rc != 0 )
    1.27 +        return rc;
    1.28 +
    1.29 +    t_info = xc_map_foreign_range(xc_handle, DOMID_XEN,
    1.30 +                    sysctl.u.tbuf_op.size, PROT_READ | PROT_WRITE,
    1.31 +                    sysctl.u.tbuf_op.buffer_mfn);
    1.32 +
    1.33 +    if ( t_info == NULL || t_info->tbuf_size == 0 )
    1.34 +        return -1;
    1.35 +
    1.36 +    *size = t_info->tbuf_size;
    1.37 +
    1.38 +    return 0;
    1.39  }
    1.40  
    1.41  int xc_tbuf_enable(int xc_handle, unsigned long pages, unsigned long *mfn,