ia64/xen-unstable
changeset 17121:0d732e2455b3
xentrace: Disable tracing by default on exit
Includes an option to disable this behavior.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Includes an option to disable this behavior.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Tue Feb 26 14:39:11 2008 +0000 (2008-02-26) |
parents | 803c964e3ede |
children | 3278024fa4ea |
files | tools/xentrace/xentrace.c |
line diff
1.1 --- a/tools/xentrace/xentrace.c Tue Feb 26 14:38:57 2008 +0000 1.2 +++ b/tools/xentrace/xentrace.c Tue Feb 26 14:39:11 2008 +0000 1.3 @@ -55,7 +55,8 @@ typedef struct settings_st { 1.4 uint32_t cpu_mask; 1.5 unsigned long tbuf_size; 1.6 unsigned long disk_rsvd; 1.7 - uint8_t discard:1; 1.8 + uint8_t discard:1, 1.9 + disable_tracing:1; 1.10 } settings_t; 1.11 1.12 settings_t opts; 1.13 @@ -158,6 +159,28 @@ void write_buffer(unsigned int cpu, unsi 1.14 exit(EXIT_FAILURE); 1.15 } 1.16 1.17 +static void disable_tbufs(void) 1.18 +{ 1.19 + int xc_handle = xc_interface_open(); 1.20 + int ret; 1.21 + 1.22 + if ( xc_handle < 0 ) 1.23 + { 1.24 + perror("Couldn't open xc handle to disable tbufs."); 1.25 + goto out; 1.26 + } 1.27 + 1.28 + ret = xc_tbuf_disable(xc_handle); 1.29 + 1.30 + if ( ret != 0 ) 1.31 + { 1.32 + perror("Couldn't disable trace buffers"); 1.33 + } 1.34 + 1.35 +out: 1.36 + xc_interface_close(xc_handle); 1.37 +} 1.38 + 1.39 static void get_tbufs(unsigned long *mfn, unsigned long *size) 1.40 { 1.41 int ret; 1.42 @@ -465,6 +488,9 @@ int monitor_tbufs(int outfd) 1.43 wait_for_event_or_timeout(opts.poll_sleep); 1.44 } 1.45 1.46 + if(opts.disable_tracing) 1.47 + disable_tbufs(); 1.48 + 1.49 /* cleanup */ 1.50 free(meta); 1.51 free(data); 1.52 @@ -503,6 +529,11 @@ void usage(void) 1.53 " this argument will be ignored.\n" \ 1.54 " -D --discard-buffers Discard all records currently in the trace\n" \ 1.55 " buffers before beginning.\n" \ 1.56 +" -x --dont-disable-tracing\n" \ 1.57 +" By default, xentrace will disable tracing when\n" \ 1.58 +" it exits. Selecting this option will tell it to\n" \ 1.59 +" keep tracing on. Traces will be collected in\n" \ 1.60 +" Xen's trace buffers until they become full.\n" \ 1.61 " -?, --help Show this message\n" \ 1.62 " -V, --version Print program version\n" \ 1.63 "\n" \ 1.64 @@ -573,6 +604,7 @@ void parse_args(int argc, char **argv) 1.65 { "trace-buf-size", required_argument, 0, 'S' }, 1.66 { "reserve-disk-space", required_argument, 0, 'r' }, 1.67 { "discard-buffers", no_argument, 0, 'D' }, 1.68 + { "dont-disable-tracing", no_argument, 0, 'x' }, 1.69 { "help", no_argument, 0, '?' }, 1.70 { "version", no_argument, 0, 'V' }, 1.71 { 0, 0, 0, 0 } 1.72 @@ -612,6 +644,10 @@ void parse_args(int argc, char **argv) 1.73 opts.disk_rsvd = argtol(optarg, 0); 1.74 break; 1.75 1.76 + case 'x': /* Don't disable tracing */ 1.77 + opts.disable_tracing = 0; 1.78 + break; 1.79 + 1.80 default: 1.81 usage(); 1.82 } 1.83 @@ -640,6 +676,7 @@ int main(int argc, char **argv) 1.84 opts.evt_mask = 0; 1.85 opts.cpu_mask = 0; 1.86 opts.disk_rsvd = 0; 1.87 + opts.disable_tracing = 1; 1.88 1.89 parse_args(argc, argv); 1.90