# HG changeset patch # User Satoshi UCHIDA # Node ID 763f043712421a8848a1a1d1013c0e67a28f8932 # Parent e9f165338a9325b03c56d4d278de42598bd335e6 [XENTOP]Add VBD information. display VBD information at xentop. By put 'b' key, display each VBD information in detail. Signed-off-by: Satoshi UCHIDA diff -r 43dda746e4ca -r d295ab4b8be8 tools/xenstat/xentop/xentop.c --- a/tools/xenstat/xentop/xentop.c Wed Jun 28 22:34:37 2006 +0900 +++ b/tools/xenstat/xentop/xentop.c Wed Jun 28 22:36:41 2006 +0900 @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -65,6 +66,7 @@ static int compare(unsigned long long, u static int compare(unsigned long long, unsigned long long); static int compare_domains(xenstat_domain **, xenstat_domain **); static unsigned long long tot_net_bytes( xenstat_domain *, int); +static unsigned long long tot_vbd_reqs( xenstat_domain *, int); /* Field functions */ static int compare_state(xenstat_domain *domain1, xenstat_domain *domain2); @@ -91,6 +93,15 @@ static void print_ssid(xenstat_domain *d static void print_ssid(xenstat_domain *domain); static int compare_name(xenstat_domain *domain1, xenstat_domain *domain2); static void print_name(xenstat_domain *domain); +static int compare_vbds(xenstat_domain *domain1, xenstat_domain *domain2); +static void print_vbds(xenstat_domain *domain); +static int compare_vbd_oo(xenstat_domain *domain1, xenstat_domain *domain2); +static void print_vbd_oo(xenstat_domain *domain); +static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain *domain2); +static void print_vbd_rd(xenstat_domain *domain); +static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain *domain2); +static void print_vbd_wr(xenstat_domain *domain); + /* Section printing functions */ static void do_summary(void); @@ -99,6 +110,7 @@ static void do_domain(xenstat_domain *); static void do_domain(xenstat_domain *); static void do_vcpu(xenstat_domain *); static void do_network(xenstat_domain *); +static void do_vbd(xenstat_domain *); static void top(void); /* Field types */ @@ -116,6 +128,10 @@ typedef enum field_id { FIELD_NETS, FIELD_NET_TX, FIELD_NET_RX, + FIELD_VBDS, + FIELD_VBD_OO, + FIELD_VBD_RD, + FIELD_VBD_WR, FIELD_SSID } field_id; @@ -140,7 +156,11 @@ field fields[] = { { FIELD_NETS, "NETS", 4, compare_nets, print_nets }, { FIELD_NET_TX, "NETTX(k)", 8, compare_net_tx, print_net_tx }, { FIELD_NET_RX, "NETRX(k)", 8, compare_net_rx, print_net_rx }, - { FIELD_SSID, "SSID", 4, compare_ssid, print_ssid } + { FIELD_NET_RX, "VBDS", 8, compare_vbds, print_vbds }, + { FIELD_NET_RX, "VBD_OO", 8, compare_vbd_oo, print_vbd_oo }, + { FIELD_NET_RX, "VBD_RD", 8, compare_vbd_rd, print_vbd_rd }, + { FIELD_NET_RX, "VBD_WR", 8, compare_vbd_wr, print_vbd_wr }, + { FIELD_SSID, "SSID", 4, compare_ssid, print_ssid } }; const unsigned int NUM_FIELDS = sizeof(fields)/sizeof(field); @@ -155,6 +175,7 @@ unsigned int delay = 3; unsigned int delay = 3; int show_vcpus = 0; int show_networks = 0; +int show_vbds = 0; int repeat_header = 0; #define PROMPT_VAL_LEN 80 char *prompt = NULL; @@ -177,6 +198,7 @@ static void usage(const char *program) "-V, --version output version information and exit\n" "-d, --delay=SECONDS seconds between updates (default 3)\n" "-n, --networks output vif network data\n" + "-b, --vbds output vbd block device data\n" "-r, --repeat-header repeat table header before each domain\n" "-v, --vcpus output vcpu data\n" "\n" XENTOP_BUGSTO, @@ -278,6 +300,9 @@ static int handle_key(int ch) switch(ch) { case 'n': case 'N': show_networks ^= 1; + break; + case 'b': case 'B': + show_vbds ^= 1; break; case 'r': case 'R': repeat_header ^= 1; @@ -574,6 +599,96 @@ static unsigned long long tot_net_bytes( return total; } +/* Compares number of virtual block devices of two domains, + returning -1,0,1 for * <,=,> */ +static int compare_vbds(xenstat_domain *domain1, xenstat_domain *domain2) +{ + return -compare(xenstat_domain_num_vbds(domain1), + xenstat_domain_num_vbds(domain2)); +} + +/* Prints number of virtual block devices statistic */ +static void print_vbds(xenstat_domain *domain) +{ + print("%4u", xenstat_domain_num_vbds(domain)); +} + +/* Compares number of total VBD OO requests of two domains, + returning -1,0,1 * for <,=,> */ +static int compare_vbd_oo(xenstat_domain *domain1, xenstat_domain *domain2) +{ + return -compare(tot_vbd_reqs(domain1, FIELD_VBD_OO), + tot_vbd_reqs(domain2, FIELD_VBD_OO)); +} + +/* Prints number of total VBD OO requests statistic */ +static void print_vbd_oo(xenstat_domain *domain) +{ + print("%8llu", tot_vbd_reqs(domain, FIELD_VBD_OO)); +} + +/* Compares number of total VBD READ requests of two domains, + returning -1,0,1 * for <,=,> */ +static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain *domain2) +{ + return -compare(tot_vbd_reqs(domain1, FIELD_VBD_RD), + tot_vbd_reqs(domain2, FIELD_VBD_RD)); +} + +/* Prints number of total VBD READ requests statistic */ +static void print_vbd_rd(xenstat_domain *domain) +{ + print("%8llu", tot_vbd_reqs(domain, FIELD_VBD_RD)); +} + +/* Compares number of total VBD WRITE requests of two domains, + returning -1,0,1 * for <,=,> */ +static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain *domain2) +{ + return -compare(tot_vbd_reqs(domain1,FIELD_VBD_WR), + tot_vbd_reqs(domain2,FIELD_VBD_WR)); +} + +/* Prints number of total VBD WRITE requests statistic */ +static void print_vbd_wr(xenstat_domain *domain) +{ + print("%8llu", tot_vbd_reqs(domain,FIELD_VBD_WR)); +} + +/* Gets number of total VBD requests statistic, + * if flag is FIELD_VBD_OO, then OO requests, + * if flag is FIELD_VBD_RD, then READ requests and + * if flag is FIELD_VBD_WR, then WRITE requests. + */ +static unsigned long long tot_vbd_reqs(xenstat_domain *domain, int flag) +{ + int i = 0; + xenstat_vbd *vbd; + unsigned num_vbds = 0; + unsigned long long total = 0; + + num_vbds = xenstat_domain_num_vbds(domain); + + for ( i=0 ; i < num_vbds ; i++) { + vbd = xenstat_domain_vbd(domain,i); + switch(flag) { + case FIELD_VBD_OO: + total += xenstat_vbd_oo_reqs(vbd); + break; + case FIELD_VBD_RD: + total += xenstat_vbd_rd_reqs(vbd); + break; + case FIELD_VBD_WR: + total += xenstat_vbd_wr_reqs(vbd); + break; + default: + break; + } + } + + return total; +} + /* Compares security id (ssid) of two domains, returning -1,0,1 for <,=,> */ static int compare_ssid(xenstat_domain *domain1, xenstat_domain *domain2) { @@ -669,6 +784,13 @@ void do_bottom_line(void) addch(A_REVERSE | 'N'); attr_addstr(show_networks ? COLOR_PAIR(1) : 0, "etworks"); addstr(" "); + + /* VBDs */ + attr_addstr(show_vbds ? COLOR_PAIR(1) : 0, "v"); + addch(A_REVERSE | 'B'); + attr_addstr(show_vbds ? COLOR_PAIR(1) : 0, "ds"); + addstr(" "); + /* vcpus */ addch(A_REVERSE | 'V'); @@ -758,6 +880,28 @@ void do_network(xenstat_domain *domain) } } + +/* Output all VBD information */ +void do_vbd(xenstat_domain *domain) +{ + int i = 0; + xenstat_vbd *vbd; + unsigned num_vbds = 0; + + num_vbds = xenstat_domain_num_vbds(domain); + + for (i=0 ; i< num_vbds; i++) { + vbd = xenstat_domain_vbd(domain,i); + + print("VBD %4u [%2x:%2x] OO: %8llu RD: %8llu WR: %8llu\n", + xenstat_vbd_dev(vbd), + MAJOR(xenstat_vbd_dev(vbd)), MINOR(xenstat_vbd_dev(vbd)), + xenstat_vbd_oo_reqs(vbd), + xenstat_vbd_rd_reqs(vbd), + xenstat_vbd_wr_reqs(vbd)); + } +} + static void top(void) { xenstat_domain **domains; @@ -801,6 +945,8 @@ static void top(void) do_vcpu(domains[i]); if (show_networks) do_network(domains[i]); + if (show_vbds) + do_vbd(domains[i]); } do_bottom_line(); @@ -815,12 +961,13 @@ int main(int argc, char **argv) { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { "networks", no_argument, NULL, 'n' }, + { "vbds", no_argument, NULL, 'b' }, { "repeat-header", no_argument, NULL, 'r' }, { "vcpus", no_argument, NULL, 'v' }, { "delay", required_argument, NULL, 'd' }, { 0, 0, 0, 0 }, }; - const char *sopts = "hVbnvd:"; + const char *sopts = "hVbnrvd:"; if (atexit(cleanup) != 0) fail("Failed to install cleanup handler.\n"); @@ -838,6 +985,9 @@ int main(int argc, char **argv) case 'n': show_networks = 1; break; + case 'b': + show_vbds = 1; + break; case 'r': repeat_header = 1; break;