[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Fix xentrace to initialise the trace buffers if they are not set up.



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 7f98c67636f4824467d47b608c108e9b1959b7e6
# Parent  1b55b85f8cb2f303209d81aa374abd2119f50d07
Fix xentrace to initialise the trace buffers if they are not set up.
Signed-off-by: Atsushi SAKAI <sakaia@xxxxxxxxxxxxxx>
---
 tools/xentrace/xentrace.c |   65 ++++++++++++++++++++++++++++++++++++----------
 1 files changed, 51 insertions(+), 14 deletions(-)

diff -r 1b55b85f8cb2 -r 7f98c67636f4 tools/xentrace/xentrace.c
--- a/tools/xentrace/xentrace.c Fri May 12 15:17:21 2006 +0100
+++ b/tools/xentrace/xentrace.c Fri May 12 15:19:37 2006 +0100
@@ -28,6 +28,8 @@
 
 #include <xenctrl.h>
 
+#include "xc_private.h"
+
 #define PERROR(_m, _a...)                                       \
 do {                                                            \
     int __saved_errno = errno;                                  \
@@ -46,7 +48,7 @@ extern FILE *stderr;
 /* sleep for this long (milliseconds) between checking the trace buffers */
 #define POLL_SLEEP_MILLIS 100
 
-
+#define DEFAULT_TBUF_SIZE 20
 /***** The code **************************************************************/
 
 typedef struct settings_st {
@@ -101,6 +103,26 @@ void write_rec(unsigned int cpu, struct 
     }
 }
 
+void enable_tracing_or_die(int xc_handle) 
+{
+  int enable = 1;
+  int tbsize = DEFAULT_TBUF_SIZE;
+  
+  if (xc_tbuf_enable(xc_handle, enable) != 0) {
+    if (xc_tbuf_set_size(xc_handle, tbsize) != 0) {
+      perror("set_size Hypercall failure");
+      exit(1);
+    }
+    printf("Set default trace buffer allocation (%d pages)\n", tbsize);
+    if (xc_tbuf_enable(xc_handle, enable) != 0) {
+      perror("Could not enable trace buffers\n");
+      exit(1);
+    }
+  }
+  else
+    printf("Tracing enabled\n");
+}
+
 /**
  * get_tbufs - get pointer to and size of the trace buffers
  * @mfn:  location to store mfn of the trace buffers to
@@ -111,22 +133,37 @@ void write_rec(unsigned int cpu, struct 
  */
 void get_tbufs(unsigned long *mfn, unsigned long *size)
 {
-    uint32_t size32;
+    int ret;
+    dom0_op_t op;                        /* dom0 op we'll build             */
     int xc_handle = xc_interface_open(); /* for accessing control interface */
-
-    if (xc_tbuf_get_size(xc_handle, &size32) != 0)
-        goto fail;
-    *size = size32;
-
-    if (xc_tbuf_get_mfn(xc_handle, mfn) != 0)
-        goto fail;
+    unsigned int tbsize;
+
+    enable_tracing_or_die(xc_handle);
+
+    if (xc_tbuf_get_size(xc_handle, &tbsize) != 0) {
+      perror("Failure to get tbuf info from Xen. Guess size is 0?");
+      exit(1);
+    }
+    else
+      printf("Current tbuf size: 0x%x\n", tbsize);
+    
+
+    op.cmd = DOM0_TBUFCONTROL;
+    op.interface_version = DOM0_INTERFACE_VERSION;
+    op.u.tbufcontrol.op  = DOM0_TBUF_GET_INFO;
+
+    ret = do_dom0_op(xc_handle, &op);
 
     xc_interface_close(xc_handle);
-    return;
-
-fail:
-    PERROR("Failure to get trace buffer pointer from Xen");
-    exit(EXIT_FAILURE);
+
+    if ( ret != 0 )
+    {
+        PERROR("Failure to get trace buffer pointer from Xen");
+        exit(EXIT_FAILURE);
+    }
+
+    *mfn  = op.u.tbufcontrol.buffer_mfn;
+    *size = op.u.tbufcontrol.size;
 }
 
 /**

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.