direct-io.hg

changeset 15272:30449e0e0a64

xentop: Fix -b option (batch mode).

Some curses libraries don't work with xentop in batch mode, avoid
those calls. Avoid the over-verbose summary lines when batch mode is
requested.

Signed-off-by: Gary Pennington <gary.pennington@sun.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Jun 13 11:13:11 2007 +0100 (2007-06-13)
parents c484106e44bd
children 7f9362a8ae3d
files tools/xenstat/xentop/xentop.c
line diff
     1.1 --- a/tools/xenstat/xentop/xentop.c	Wed Jun 13 11:05:47 2007 +0100
     1.2 +++ b/tools/xenstat/xentop/xentop.c	Wed Jun 13 11:13:11 2007 +0100
     1.3 @@ -290,12 +290,24 @@ static void print(const char *fmt, ...)
     1.4  	}
     1.5  }
     1.6  
     1.7 +static void xentop_attron(int attr)
     1.8 +{
     1.9 +	if (!batch)
    1.10 +		attron(attr);
    1.11 +}
    1.12 +
    1.13 +static void xentop_attroff(int attr)
    1.14 +{
    1.15 +	if (!batch)
    1.16 +		attroff(attr);
    1.17 +}
    1.18 +
    1.19  /* Print a string with the given attributes set. */
    1.20  static void attr_addstr(int attr, const char *str)
    1.21  {
    1.22 -	attron(attr);
    1.23 +	xentop_attron(attr);
    1.24  	addstr((curses_str_t)str);
    1.25 -	attroff(attr);
    1.26 +	xentop_attroff(attr);
    1.27  }
    1.28  
    1.29  /* Handle setting the delay from the user-supplied value in prompt_val */
    1.30 @@ -780,18 +792,18 @@ void do_header(void)
    1.31  	field_id i;
    1.32  
    1.33  	/* Turn on REVERSE highlight attribute for headings */
    1.34 -	attron(A_REVERSE);
    1.35 +	xentop_attron(A_REVERSE);
    1.36  	for(i = 0; i < NUM_FIELDS; i++) {
    1.37 -		if(i != 0)
    1.38 +		if (i != 0)
    1.39  			print(" ");
    1.40  		/* The BOLD attribute is turned on for the sort column */
    1.41 -		if(i == sort_field)
    1.42 -			attron(A_BOLD);
    1.43 +		if (i == sort_field)
    1.44 +			xentop_attron(A_BOLD);
    1.45  		print("%*s", fields[i].default_width, fields[i].header);
    1.46 -		if(i == sort_field)
    1.47 -			attroff(A_BOLD);
    1.48 +		if (i == sort_field)
    1.49 +			xentop_attroff(A_BOLD);
    1.50  	}
    1.51 -	attroff(A_REVERSE);
    1.52 +	xentop_attroff(A_REVERSE);
    1.53  	print("\n");
    1.54  }
    1.55  
    1.56 @@ -838,14 +850,14 @@ void do_bottom_line(void)
    1.57  void do_domain(xenstat_domain *domain)
    1.58  {
    1.59  	unsigned int i;
    1.60 -	for(i = 0; i < NUM_FIELDS; i++) {
    1.61 -		if(i != 0)
    1.62 +	for (i = 0; i < NUM_FIELDS; i++) {
    1.63 +		if (i != 0)
    1.64  			print(" ");
    1.65 -		if(i == sort_field)
    1.66 -			attron(A_BOLD);
    1.67 +		if (i == sort_field)
    1.68 +			xentop_attron(A_BOLD);
    1.69  		fields[i].print(domain);
    1.70 -		if(i == sort_field)
    1.71 -			attroff(A_BOLD);
    1.72 +		if (i == sort_field)
    1.73 +			xentop_attroff(A_BOLD);
    1.74  	}
    1.75  	print("\n");
    1.76  }
    1.77 @@ -956,7 +968,8 @@ static void top(void)
    1.78  		fail("Failed to retrieve statistics from libxenstat\n");
    1.79  
    1.80  	/* dump summary top information */
    1.81 -	do_summary();
    1.82 +	if (!batch)
    1.83 +		do_summary();
    1.84  
    1.85  	/* Count the number of domains for which to report data */
    1.86  	num_domains = xenstat_node_num_domains(cur_node);
    1.87 @@ -976,7 +989,7 @@ static void top(void)
    1.88  		first_domain_index = num_domains-1;
    1.89  
    1.90  	for (i = first_domain_index; i < num_domains; i++) {
    1.91 -		if(current_row() == lines()-1)
    1.92 +		if(!batch && current_row() == lines()-1)
    1.93  			break;
    1.94  		if (i == first_domain_index || repeat_header)
    1.95  			do_header();
    1.96 @@ -989,8 +1002,8 @@ static void top(void)
    1.97  			do_vbd(domains[i]);
    1.98  	}
    1.99  
   1.100 -	if(!batch)
   1.101 -	do_bottom_line();
   1.102 +	if (!batch)
   1.103 +		do_bottom_line();
   1.104  
   1.105  	free(domains);
   1.106  }