ia64/xen-unstable
changeset 17122:3278024fa4ea
xentrace: Add a time parameter
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Tue Feb 26 14:39:26 2008 +0000 (2008-02-26) |
parents | 0d732e2455b3 |
children | 4f8c3a61511c |
files | tools/xentrace/xentrace.c |
line diff
1.1 --- a/tools/xentrace/xentrace.c Tue Feb 26 14:39:11 2008 +0000 1.2 +++ b/tools/xentrace/xentrace.c Tue Feb 26 14:39:26 2008 +0000 1.3 @@ -55,6 +55,7 @@ typedef struct settings_st { 1.4 uint32_t cpu_mask; 1.5 unsigned long tbuf_size; 1.6 unsigned long disk_rsvd; 1.7 + unsigned long timeout; 1.8 uint8_t discard:1, 1.9 disable_tracing:1; 1.10 } settings_t; 1.11 @@ -534,6 +535,7 @@ void usage(void) 1.12 " it exits. Selecting this option will tell it to\n" \ 1.13 " keep tracing on. Traces will be collected in\n" \ 1.14 " Xen's trace buffers until they become full.\n" \ 1.15 +" -T --time-interval=s Run xentrace for s seconds and quit.\n" \ 1.16 " -?, --help Show this message\n" \ 1.17 " -V, --version Print program version\n" \ 1.18 "\n" \ 1.19 @@ -603,6 +605,7 @@ void parse_args(int argc, char **argv) 1.20 { "evt-mask", required_argument, 0, 'e' }, 1.21 { "trace-buf-size", required_argument, 0, 'S' }, 1.22 { "reserve-disk-space", required_argument, 0, 'r' }, 1.23 + { "time-interval", required_argument, 0, 'T' }, 1.24 { "discard-buffers", no_argument, 0, 'D' }, 1.25 { "dont-disable-tracing", no_argument, 0, 'x' }, 1.26 { "help", no_argument, 0, '?' }, 1.27 @@ -648,6 +651,10 @@ void parse_args(int argc, char **argv) 1.28 opts.disable_tracing = 0; 1.29 break; 1.30 1.31 + case 'T': 1.32 + opts.timeout = argtol(optarg, 0); 1.33 + break; 1.34 + 1.35 default: 1.36 usage(); 1.37 } 1.38 @@ -660,7 +667,6 @@ void parse_args(int argc, char **argv) 1.39 opts.outfile = argv[optind]; 1.40 } 1.41 1.42 - 1.43 /* *BSD has no O_LARGEFILE */ 1.44 #ifndef O_LARGEFILE 1.45 #define O_LARGEFILE 0 1.46 @@ -677,6 +683,7 @@ int main(int argc, char **argv) 1.47 opts.cpu_mask = 0; 1.48 opts.disk_rsvd = 0; 1.49 opts.disable_tracing = 1; 1.50 + opts.timeout = 0; 1.51 1.52 parse_args(argc, argv); 1.53 1.54 @@ -693,6 +700,9 @@ int main(int argc, char **argv) 1.55 if ( opts.cpu_mask != 0 ) 1.56 set_mask(opts.cpu_mask, 1); 1.57 1.58 + if ( opts.timeout != 0 ) 1.59 + alarm(opts.timeout); 1.60 + 1.61 if ( opts.outfile ) 1.62 outfd = open(opts.outfile, 1.63 O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE, 1.64 @@ -717,6 +727,7 @@ int main(int argc, char **argv) 1.65 sigaction(SIGHUP, &act, NULL); 1.66 sigaction(SIGTERM, &act, NULL); 1.67 sigaction(SIGINT, &act, NULL); 1.68 + sigaction(SIGALRM, &act, NULL); 1.69 1.70 ret = monitor_tbufs(outfd); 1.71