ia64/xen-unstable

changeset 10608:85b092b4567d

[XENTOP]Add VBD information.

Display VBD information at xentop.
By put 'x' key, display each VBD information in detail.

Signed-off-by: Satoshi UCHIDA <s-uchida@ap.jp.nec.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Jun 30 09:25:42 2006 +0100 (2006-06-30)
parents 3edac4400459
children 5fc6d83f43f7
files tools/xenstat/xentop/xentop.c
line diff
     1.1 --- a/tools/xenstat/xentop/xentop.c	Fri Jun 30 09:20:22 2006 +0100
     1.2 +++ b/tools/xenstat/xentop/xentop.c	Fri Jun 30 09:25:42 2006 +0100
     1.3 @@ -27,6 +27,7 @@
     1.4  #include <sys/time.h>
     1.5  #include <time.h>
     1.6  #include <unistd.h>
     1.7 +#include <linux/kdev_t.h>
     1.8  
     1.9  #include <xenstat.h>
    1.10  
    1.11 @@ -65,6 +66,7 @@ static int handle_key(int);
    1.12  static int compare(unsigned long long, unsigned long long);
    1.13  static int compare_domains(xenstat_domain **, xenstat_domain **);
    1.14  static unsigned long long tot_net_bytes( xenstat_domain *, int);
    1.15 +static unsigned long long tot_vbd_reqs( xenstat_domain *, int);
    1.16  
    1.17  /* Field functions */
    1.18  static int compare_state(xenstat_domain *domain1, xenstat_domain *domain2);
    1.19 @@ -91,6 +93,15 @@ static int compare_ssid(xenstat_domain *
    1.20  static void print_ssid(xenstat_domain *domain);
    1.21  static int compare_name(xenstat_domain *domain1, xenstat_domain *domain2);
    1.22  static void print_name(xenstat_domain *domain);
    1.23 +static int compare_vbds(xenstat_domain *domain1, xenstat_domain *domain2);
    1.24 +static void print_vbds(xenstat_domain *domain);
    1.25 +static int compare_vbd_oo(xenstat_domain *domain1, xenstat_domain *domain2);
    1.26 +static void print_vbd_oo(xenstat_domain *domain);
    1.27 +static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain *domain2);
    1.28 +static void print_vbd_rd(xenstat_domain *domain);
    1.29 +static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain *domain2);
    1.30 +static void print_vbd_wr(xenstat_domain *domain);
    1.31 +
    1.32  
    1.33  /* Section printing functions */
    1.34  static void do_summary(void);
    1.35 @@ -99,6 +110,7 @@ static void do_bottom_line(void);
    1.36  static void do_domain(xenstat_domain *);
    1.37  static void do_vcpu(xenstat_domain *);
    1.38  static void do_network(xenstat_domain *);
    1.39 +static void do_vbd(xenstat_domain *);
    1.40  static void top(void);
    1.41  
    1.42  /* Field types */
    1.43 @@ -116,6 +128,10 @@ typedef enum field_id {
    1.44  	FIELD_NETS,
    1.45  	FIELD_NET_TX,
    1.46  	FIELD_NET_RX,
    1.47 +	FIELD_VBDS,
    1.48 +	FIELD_VBD_OO,
    1.49 +	FIELD_VBD_RD,
    1.50 +	FIELD_VBD_WR,
    1.51  	FIELD_SSID
    1.52  } field_id;
    1.53  
    1.54 @@ -140,7 +156,11 @@ field fields[] = {
    1.55  	{ FIELD_NETS,    "NETS",       4, compare_nets,    print_nets    },
    1.56  	{ FIELD_NET_TX,  "NETTX(k)",   8, compare_net_tx,  print_net_tx  },
    1.57  	{ FIELD_NET_RX,  "NETRX(k)",   8, compare_net_rx,  print_net_rx  },
    1.58 -	{ FIELD_SSID,    "SSID",       4, compare_ssid,    print_ssid    }
    1.59 +	{ FIELD_NET_RX,  "VBDS",       8, compare_vbds,    print_vbds    },
    1.60 +	{ FIELD_NET_RX,  "VBD_OO",     8, compare_vbd_oo,  print_vbd_oo  },
    1.61 +	{ FIELD_NET_RX,  "VBD_RD",     8, compare_vbd_rd,  print_vbd_rd  },
    1.62 +	{ FIELD_NET_RX,  "VBD_WR",     8, compare_vbd_wr,  print_vbd_wr  },
    1.63 +       	{ FIELD_SSID,    "SSID",       4, compare_ssid,    print_ssid    }
    1.64  };
    1.65  
    1.66  const unsigned int NUM_FIELDS = sizeof(fields)/sizeof(field);
    1.67 @@ -158,6 +178,7 @@ unsigned int loop = 1;
    1.68  unsigned int iterations = 0;
    1.69  int show_vcpus = 0;
    1.70  int show_networks = 0;
    1.71 +int show_vbds = 0;
    1.72  int repeat_header = 0;
    1.73  #define PROMPT_VAL_LEN 80
    1.74  char *prompt = NULL;
    1.75 @@ -180,6 +201,7 @@ static void usage(const char *program)
    1.76  	       "-V, --version        output version information and exit\n"
    1.77  	       "-d, --delay=SECONDS  seconds between updates (default 3)\n"
    1.78  	       "-n, --networks       output vif network data\n"
    1.79 +	       "-b, --vbds           output vbd block device data\n"
    1.80  	       "-r, --repeat-header  repeat table header before each domain\n"
    1.81  	       "-v, --vcpus          output vcpu data\n"
    1.82  	       "-b, --batch	     output in batch mode, no user input accepted\n"
    1.83 @@ -290,6 +312,9 @@ static int handle_key(int ch)
    1.84  		case 'n': case 'N':
    1.85  			show_networks ^= 1;
    1.86  			break;
    1.87 +		case 'b': case 'B':
    1.88 +			show_vbds ^= 1;
    1.89 +			break;
    1.90  		case 'r': case 'R':
    1.91  			repeat_header ^= 1;
    1.92  			break;
    1.93 @@ -585,6 +610,96 @@ static unsigned long long tot_net_bytes(
    1.94  	return total;
    1.95  }
    1.96  
    1.97 +/* Compares number of virtual block devices of two domains,
    1.98 +   returning -1,0,1 for * <,=,> */
    1.99 +static int compare_vbds(xenstat_domain *domain1, xenstat_domain *domain2)
   1.100 +{
   1.101 +	return -compare(xenstat_domain_num_vbds(domain1),
   1.102 +	                xenstat_domain_num_vbds(domain2));
   1.103 +}
   1.104 +
   1.105 +/* Prints number of virtual block devices statistic */
   1.106 +static void print_vbds(xenstat_domain *domain)
   1.107 +{
   1.108 +	print("%4u", xenstat_domain_num_vbds(domain));
   1.109 +}
   1.110 +
   1.111 +/* Compares number of total VBD OO requests of two domains,
   1.112 +   returning -1,0,1 * for <,=,> */
   1.113 +static int compare_vbd_oo(xenstat_domain *domain1, xenstat_domain *domain2)
   1.114 +{
   1.115 +  return -compare(tot_vbd_reqs(domain1, FIELD_VBD_OO),
   1.116 +		  tot_vbd_reqs(domain2, FIELD_VBD_OO));
   1.117 +}
   1.118 +
   1.119 +/* Prints number of total VBD OO requests statistic */
   1.120 +static void print_vbd_oo(xenstat_domain *domain)
   1.121 +{
   1.122 +	print("%8llu", tot_vbd_reqs(domain, FIELD_VBD_OO));
   1.123 +}
   1.124 +
   1.125 +/* Compares number of total VBD READ requests of two domains,
   1.126 +   returning -1,0,1 * for <,=,> */
   1.127 +static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain *domain2)
   1.128 +{
   1.129 +	return -compare(tot_vbd_reqs(domain1, FIELD_VBD_RD),
   1.130 +			tot_vbd_reqs(domain2, FIELD_VBD_RD));
   1.131 +}
   1.132 +
   1.133 +/* Prints number of total VBD READ requests statistic */
   1.134 +static void print_vbd_rd(xenstat_domain *domain)
   1.135 +{
   1.136 +	print("%8llu", tot_vbd_reqs(domain, FIELD_VBD_RD));
   1.137 +}
   1.138 +
   1.139 +/* Compares number of total VBD WRITE requests of two domains,
   1.140 +   returning -1,0,1 * for <,=,> */
   1.141 +static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain *domain2)
   1.142 +{
   1.143 +	return -compare(tot_vbd_reqs(domain1,FIELD_VBD_WR),
   1.144 +			tot_vbd_reqs(domain2,FIELD_VBD_WR));
   1.145 +}
   1.146 +
   1.147 +/* Prints number of total VBD WRITE requests statistic */
   1.148 +static void print_vbd_wr(xenstat_domain *domain)
   1.149 +{
   1.150 +	print("%8llu", tot_vbd_reqs(domain,FIELD_VBD_WR));
   1.151 +}
   1.152 +
   1.153 +/* Gets number of total VBD requests statistic, 
   1.154 + *   if flag is FIELD_VBD_OO, then OO requests,
   1.155 + *   if flag is FIELD_VBD_RD, then READ requests and
   1.156 + *   if flag is FIELD_VBD_WR, then WRITE requests.
   1.157 + */
   1.158 +static unsigned long long tot_vbd_reqs(xenstat_domain *domain, int flag)
   1.159 +{
   1.160 +	int i = 0;
   1.161 +	xenstat_vbd *vbd;
   1.162 +	unsigned num_vbds = 0;
   1.163 +	unsigned long long total = 0;
   1.164 +	
   1.165 +	num_vbds = xenstat_domain_num_vbds(domain);
   1.166 +	
   1.167 +	for ( i=0 ; i < num_vbds ; i++) {
   1.168 +		vbd = xenstat_domain_vbd(domain,i);
   1.169 +		switch(flag) {
   1.170 +		case FIELD_VBD_OO:
   1.171 +			total += xenstat_vbd_oo_reqs(vbd);
   1.172 +			break;
   1.173 +		case FIELD_VBD_RD:
   1.174 +			total += xenstat_vbd_rd_reqs(vbd);
   1.175 +			break;
   1.176 +		case FIELD_VBD_WR:
   1.177 +			total += xenstat_vbd_wr_reqs(vbd);
   1.178 +			break;
   1.179 +		default:
   1.180 +			break;
   1.181 +		}
   1.182 +	}
   1.183 +	
   1.184 +	return total;
   1.185 +}
   1.186 +
   1.187  /* Compares security id (ssid) of two domains, returning -1,0,1 for <,=,> */
   1.188  static int compare_ssid(xenstat_domain *domain1, xenstat_domain *domain2)
   1.189  {
   1.190 @@ -680,6 +795,13 @@ void do_bottom_line(void)
   1.191  		addch(A_REVERSE | 'N');
   1.192  		attr_addstr(show_networks ? COLOR_PAIR(1) : 0, "etworks");
   1.193  		addstr("  ");
   1.194 +		
   1.195 +		/* VBDs */
   1.196 +		attr_addstr(show_vbds ? COLOR_PAIR(1) : 0, "v");
   1.197 +		addch(A_REVERSE | 'B');
   1.198 +		attr_addstr(show_vbds ? COLOR_PAIR(1) : 0, "ds");
   1.199 +		addstr("  ");
   1.200 +
   1.201  
   1.202  		/* vcpus */
   1.203  		addch(A_REVERSE | 'V');
   1.204 @@ -769,6 +891,28 @@ void do_network(xenstat_domain *domain)
   1.205  	}
   1.206  }
   1.207  
   1.208 +
   1.209 +/* Output all VBD information */
   1.210 +void do_vbd(xenstat_domain *domain)
   1.211 +{
   1.212 +	int i = 0;
   1.213 +	xenstat_vbd *vbd;
   1.214 +	unsigned num_vbds = 0;
   1.215 +
   1.216 +	num_vbds = xenstat_domain_num_vbds(domain);
   1.217 +
   1.218 +	for (i=0 ; i< num_vbds; i++) {
   1.219 +		vbd = xenstat_domain_vbd(domain,i);
   1.220 +				
   1.221 +		print("VBD %4u [%2x:%2x]  OO: %8llu   RD: %8llu   WR: %8llu\n",
   1.222 +		      xenstat_vbd_dev(vbd),
   1.223 +		      MAJOR(xenstat_vbd_dev(vbd)), MINOR(xenstat_vbd_dev(vbd)),
   1.224 +		      xenstat_vbd_oo_reqs(vbd),
   1.225 +		      xenstat_vbd_rd_reqs(vbd),
   1.226 +		      xenstat_vbd_wr_reqs(vbd));
   1.227 +	}
   1.228 +}
   1.229 +
   1.230  static void top(void)
   1.231  {
   1.232  	xenstat_domain **domains;
   1.233 @@ -812,6 +956,8 @@ static void top(void)
   1.234  			do_vcpu(domains[i]);
   1.235  		if (show_networks)
   1.236  			do_network(domains[i]);
   1.237 +		if (show_vbds)
   1.238 +			do_vbd(domains[i]);
   1.239  	}
   1.240  
   1.241  	if(!batch)
   1.242 @@ -827,6 +973,7 @@ int main(int argc, char **argv)
   1.243  		{ "help",          no_argument,       NULL, 'h' },
   1.244  		{ "version",       no_argument,       NULL, 'V' },
   1.245  		{ "networks",      no_argument,       NULL, 'n' },
   1.246 + 		{ "vbds",          no_argument,       NULL, 'x' },
   1.247  		{ "repeat-header", no_argument,       NULL, 'r' },
   1.248  		{ "vcpus",         no_argument,       NULL, 'v' },
   1.249  		{ "delay",         required_argument, NULL, 'd' },
   1.250 @@ -834,7 +981,7 @@ int main(int argc, char **argv)
   1.251  		{ "iterations",	   required_argument, NULL, 'i' },
   1.252  		{ 0, 0, 0, 0 },
   1.253  	};
   1.254 -	const char *sopts = "hVbnvd:bi:";
   1.255 +	const char *sopts = "hVnxrvd:bi:";
   1.256  
   1.257  	if (atexit(cleanup) != 0)
   1.258  		fail("Failed to install cleanup handler.\n");
   1.259 @@ -852,6 +999,9 @@ int main(int argc, char **argv)
   1.260  		case 'n':
   1.261  			show_networks = 1;
   1.262  			break;
   1.263 +		case 'x':
   1.264 +			show_vbds = 1;
   1.265 +			break;
   1.266  		case 'r':
   1.267  			repeat_header = 1;
   1.268  			break;