aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenmon
diff options
context:
space:
mode:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2006-05-16 09:18:25 +0100
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2006-05-16 09:18:25 +0100
commitb152f0ed7a5b3294fc70a60ca56496737a7e903f (patch)
tree6a209bb15439626573c139278b6c70f3f3691415 /tools/xenmon
parent1c9887d59b3a49d3350ed1a72199b90a292284a8 (diff)
downloadxen-b152f0ed7a5b3294fc70a60ca56496737a7e903f.tar.gz
xen-b152f0ed7a5b3294fc70a60ca56496737a7e903f.tar.bz2
xen-b152f0ed7a5b3294fc70a60ca56496737a7e903f.zip
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@sun.com>
Diffstat (limited to 'tools/xenmon')
-rw-r--r--tools/xenmon/xenbaked.c87
1 files changed, 25 insertions, 62 deletions
diff --git a/tools/xenmon/xenbaked.c b/tools/xenmon/xenbaked.c
index 402089c1f7..15b59c0b9c 100644
--- a/tools/xenmon/xenbaked.c
+++ b/tools/xenmon/xenbaked.c
@@ -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);
+ if ( xc_handle < 0 )
+ {
+ exit(EXIT_FAILURE);
}
- 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);
+ 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);
+ perror("Couldn't enable trace buffers");
+ exit(1);
}
- *mfn = op.u.tbufcontrol.buffer_mfn;
- *size = op.u.tbufcontrol.size;
+ 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);
}
/**