aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_tbuf.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-02-10 13:30:16 +0000
committerKeir Fraser <keir.fraser@citrix.com>2010-02-10 13:30:16 +0000
commit931df711f2b833898038e61f1fa807761aa904d7 (patch)
treec83fc1672452a6b643fb7c4ce71be795a378498c /tools/libxc/xc_tbuf.c
parente1fadda8bd76fab0cc7c3d17e1437151ae8ed647 (diff)
downloadxen-931df711f2b833898038e61f1fa807761aa904d7.tar.gz
xen-931df711f2b833898038e61f1fa807761aa904d7.tar.bz2
xen-931df711f2b833898038e61f1fa807761aa904d7.zip
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>
Diffstat (limited to 'tools/libxc/xc_tbuf.c')
-rw-r--r--tools/libxc/xc_tbuf.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/tools/libxc/xc_tbuf.c b/tools/libxc/xc_tbuf.c
index 3948d0af7d..aa21d849bb 100644
--- a/tools/libxc/xc_tbuf.c
+++ b/tools/libxc/xc_tbuf.c
@@ -15,6 +15,7 @@
*/
#include "xc_private.h"
+#include <xen/trace.h>
static int tbuf_enable(int xc_handle, int enable)
{
@@ -44,6 +45,7 @@ int xc_tbuf_set_size(int xc_handle, unsigned long size)
int xc_tbuf_get_size(int xc_handle, unsigned long *size)
{
+ struct t_info *t_info;
int rc;
DECLARE_SYSCTL;
@@ -52,9 +54,19 @@ int xc_tbuf_get_size(int xc_handle, unsigned long *size)
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,