WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Use common code for enabling tracing via xenmon and xent

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Use common code for enabling tracing via xenmon and xentrace, also fixing
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 16 May 2006 17:04:12 +0000
Delivery-date: Tue, 16 May 2006 10:05:38 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 18fceb2f6b2d691b1860b6105b6994ff016d55d9
# Parent  6a285d7d7b390d2610be640a5f3fbd38385856d7
Use common code for enabling tracing via xenmon and xentrace, also fixing
the last two remaining xc_private.h users outside of libxc.

Signed-off-by: John Levon <john.levon@xxxxxxx>
---
 tools/libxc/xc_tbuf.c     |   31 +++++++++++---
 tools/libxc/xenctrl.h     |   39 ++++++++----------
 tools/xenmon/xenbaked.c   |   99 ++++++++++++++--------------------------------
 tools/xentrace/xentrace.c |   76 +++++++----------------------------
 4 files changed, 90 insertions(+), 155 deletions(-)

diff -r 6a285d7d7b39 -r 18fceb2f6b2d tools/libxc/xc_tbuf.c
--- a/tools/libxc/xc_tbuf.c     Tue May 16 09:15:19 2006 +0100
+++ b/tools/libxc/xc_tbuf.c     Tue May 16 09:18:25 2006 +0100
@@ -16,7 +16,7 @@
 
 #include "xc_private.h"
 
-int xc_tbuf_enable(int xc_handle, int enable)
+static int tbuf_enable(int xc_handle, int enable)
 {
   DECLARE_DOM0_OP;
 
@@ -30,7 +30,7 @@ int xc_tbuf_enable(int xc_handle, int en
   return xc_dom0_op(xc_handle, &op);
 }
 
-int xc_tbuf_set_size(int xc_handle, uint32_t size)
+int xc_tbuf_set_size(int xc_handle, unsigned long size)
 {
   DECLARE_DOM0_OP;
 
@@ -42,7 +42,7 @@ int xc_tbuf_set_size(int xc_handle, uint
   return xc_dom0_op(xc_handle, &op);
 }
 
-int xc_tbuf_get_size(int xc_handle, uint32_t *size)
+int xc_tbuf_get_size(int xc_handle, unsigned long *size)
 {
   int rc;
   DECLARE_DOM0_OP;
@@ -57,10 +57,17 @@ int xc_tbuf_get_size(int xc_handle, uint
   return rc;
 }
 
-int xc_tbuf_get_mfn(int xc_handle, unsigned long *mfn)
+int xc_tbuf_enable(int xc_handle, size_t cnt, unsigned long *mfn,
+    unsigned long *size)
 {
+    DECLARE_DOM0_OP;
     int rc;
-    DECLARE_DOM0_OP;
+
+    if ( xc_tbuf_set_size(xc_handle, cnt) != 0 )
+        return -1;
+
+    if ( tbuf_enable(xc_handle, 1) != 0 )
+        return -1;
 
     op.cmd = DOM0_TBUFCONTROL;
     op.interface_version = DOM0_INTERFACE_VERSION;
@@ -68,8 +75,17 @@ int xc_tbuf_get_mfn(int xc_handle, unsig
 
     rc = xc_dom0_op(xc_handle, &op);
     if ( rc == 0 )
-      *mfn = op.u.tbufcontrol.buffer_mfn;
-    return rc;
+    {
+        *size = op.u.tbufcontrol.size;
+        *mfn = op.u.tbufcontrol.buffer_mfn;
+    }
+
+    return 0;
+}
+
+int xc_tbuf_disable(int xc_handle)
+{
+    return tbuf_enable(xc_handle, 0);
 }
 
 int xc_tbuf_set_cpu_mask(int xc_handle, uint32_t mask)
@@ -95,3 +111,4 @@ int xc_tbuf_set_evt_mask(int xc_handle, 
 
     return do_dom0_op(xc_handle, &op);
 }
+
diff -r 6a285d7d7b39 -r 18fceb2f6b2d tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Tue May 16 09:15:19 2006 +0100
+++ b/tools/libxc/xenctrl.h     Tue May 16 09:18:25 2006 +0100
@@ -529,15 +529,23 @@ long xc_get_tot_pages(int xc_handle, uin
  */
 
 /**
- * This function enables or disables tracing. Trace buffer memory must
- * be already allocated by setting the size to a non-zero value, otherwise
- * tracing cannot be enabled.
- *
- * @parm xc_handle a handle to an open hypervisor interface
- * @parm enable the desired action, 1 for enable, 0 for disable
- * @return 0 on success, -1 on failure.
- */
-int xc_tbuf_enable(int xc_handle, int enable);
+ * xc_tbuf_enable - enable tracing buffers
+ *
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm cnt size of tracing buffers to create (in pages)
+ * @parm mfn location to store mfn of the trace buffers to
+ * @parm size location to store the size (in bytes) of a trace buffer to
+ *
+ * Gets the machine address of the trace pointer area and the size of the
+ * per CPU buffers.
+ */
+int xc_tbuf_enable(int xc_handle, size_t cnt, unsigned long *mfn,
+    unsigned long *size);
+
+/*
+ * Disable tracing buffers.
+ */
+int xc_tbuf_disable(int xc_handle);
 
 /**
  * This function sets the size of the trace buffers. Setting the size
@@ -549,7 +557,7 @@ int xc_tbuf_enable(int xc_handle, int en
  * @parm size the size in pages per cpu for the trace buffers
  * @return 0 on success, -1 on failure.
  */
-int xc_tbuf_set_size(int xc_handle, uint32_t size);
+int xc_tbuf_set_size(int xc_handle, unsigned long size);
 
 /**
  * This function retrieves the current size of the trace buffers.
@@ -559,16 +567,7 @@ int xc_tbuf_set_size(int xc_handle, uint
  * @parm size will contain the size in bytes for the trace buffers
  * @return 0 on success, -1 on failure.
  */
-int xc_tbuf_get_size(int xc_handle, uint32_t *size);
-
-/**
- * This function retrieves the machine frame of the trace buffer.
-
- * @parm xc_handle a handle to an open hypervisor interface
- * @parm mfn will contain the machine frame of the buffer.
- * @return 0 on success, -1 on failure.
- */
-int xc_tbuf_get_mfn(int xc_handle, unsigned long *mfn);
+int xc_tbuf_get_size(int xc_handle, unsigned long *size);
 
 int xc_tbuf_set_cpu_mask(int xc_handle, uint32_t mask);
 
diff -r 6a285d7d7b39 -r 18fceb2f6b2d tools/xenmon/xenbaked.c
--- a/tools/xenmon/xenbaked.c   Tue May 16 09:15:19 2006 +0100
+++ b/tools/xenmon/xenbaked.c   Tue May 16 09:18:25 2006 +0100
@@ -35,6 +35,7 @@
 #include <sys/mman.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/ioctl.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
@@ -46,7 +47,14 @@
 #include <sys/select.h>
 #include <xen/linux/evtchn.h>
 
-#include "xc_private.h"
+#define PERROR(_m, _a...)                                       \
+do {                                                            \
+    int __saved_errno = errno;                                  \
+    fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a ,       \
+            __saved_errno, strerror(__saved_errno));            \
+    errno = __saved_errno;                                      \
+} while (0)
+
 typedef struct { int counter; } atomic_t;
 #define _atomic_read(v)                ((v).counter)
 
@@ -326,77 +334,32 @@ void wait_for_event(void)
   }
 }
 
-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");
-}
-
-void disable_tracing(void)
-{
-  int enable = 0;
-  int xc_handle = xc_interface_open();
-    
-  xc_tbuf_enable(xc_handle, enable);
-  xc_interface_close(xc_handle);
-}
-
-
-/**
- * get_tbufs - get pointer to and size of the trace buffers
- * @mfn:  location to store mfn of the trace buffers to
- * @size: location to store the size of a trace buffer to
- *
- * Gets the machine address of the trace pointer area and the size of the
- * per CPU buffers.
- */
-void get_tbufs(unsigned long *mfn, unsigned long *size)
-{
+static void get_tbufs(unsigned long *mfn, unsigned long *size)
+{
+    int xc_handle = xc_interface_open();
     int ret;
-    dom0_op_t op;                        /* dom0 op we'll build             */
-    int xc_handle = xc_interface_open(); /* for accessing control interface */
-    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);
+
+    if ( xc_handle < 0 ) 
+    {
+        exit(EXIT_FAILURE);
+    }
+
+    ret = xc_tbuf_enable(xc_handle, DEFAULT_TBUF_SIZE, mfn, size);
 
     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;
+        perror("Couldn't enable trace buffers");
+        exit(1);
+    }
+
+    xc_interface_close(xc_handle);
+}
+
+void disable_tracing(void)
+{
+  int xc_handle = xc_interface_open();
+  xc_tbuf_disable(xc_handle);  
+  xc_interface_close(xc_handle);
 }
 
 /**
diff -r 6a285d7d7b39 -r 18fceb2f6b2d tools/xentrace/xentrace.c
--- a/tools/xentrace/xentrace.c Tue May 16 09:15:19 2006 +0100
+++ b/tools/xentrace/xentrace.c Tue May 16 09:18:25 2006 +0100
@@ -28,8 +28,6 @@
 
 #include <xenctrl.h>
 
-#include "xc_private.h"
-
 #define PERROR(_m, _a...)                                       \
 do {                                                            \
     int __saved_errno = errno;                                  \
@@ -103,67 +101,25 @@ 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
- * @size: location to store the size of a trace buffer to
- *
- * Gets the machine address of the trace pointer area and the size of the
- * per CPU buffers.
- */
-void get_tbufs(unsigned long *mfn, unsigned long *size)
-{
+static void get_tbufs(unsigned long *mfn, unsigned long *size)
+{
+    int xc_handle = xc_interface_open();
     int ret;
-    dom0_op_t op;                        /* dom0 op we'll build             */
-    int xc_handle = xc_interface_open(); /* for accessing control interface */
-    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);
+
+    if ( xc_handle < 0 ) 
+    {
+        exit(EXIT_FAILURE);
+    }
+
+    ret = xc_tbuf_enable(xc_handle, DEFAULT_TBUF_SIZE, mfn, size);
+
+    if ( ret != 0 )
+    {
+        perror("Couldn't enable trace buffers");
+        exit(1);
+    }
 
     xc_interface_close(xc_handle);
-
-    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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Use common code for enabling tracing via xenmon and xentrace, also fixing, Xen patchbot-unstable <=