ia64/xen-unstable

changeset 17819:7a0f1bf86516

libxenstat: Fix statistics for blktap disks on linux

Overview: update xenstat vbd statistics parsing from
/sys/devices/xen-backend to process blktap disks

Reason:
-blktap devices (now referenced as tap rather than vbd in
/sys) have statistics counters
(e.g., rd_req, wr_req, oo_req) prepended by tap_
-xenstat behavior did not previously account for this
behavior, which resulted in 0 disks
visible and similarly impacted disk statistics

To reproduce these conditions, make a domain with tap:aio backed disks
on 3.2.x, run xentop, and press B to view VBD stats (nothing will
appear for the domain using tap:aio)

Signed-off-by: steve.maresca@gmail.com
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jun 10 09:27:01 2008 +0100 (2008-06-10)
parents 58e07771d455
children 9af7a535225f
files tools/xenstat/libxenstat/src/xenstat_linux.c
line diff
     1.1 --- a/tools/xenstat/libxenstat/src/xenstat_linux.c	Tue Jun 10 09:25:47 2008 +0100
     1.2 +++ b/tools/xenstat/libxenstat/src/xenstat_linux.c	Tue Jun 10 09:27:01 2008 +0100
     1.3 @@ -181,6 +181,12 @@ int xenstat_collect_vbds(xenstat_node * 
     1.4  	struct dirent *dp;
     1.5  	struct priv_data *priv = get_priv_data(node->handle);
     1.6  
     1.7 +	char *sys_prefix = "statistics/";
     1.8 +
     1.9 +	/* 23 = "statistics/" + "xxxx_xx_req" */
    1.10 +	char ooreq[23], rdreq[23], wrreq[23]; 
    1.11 +	char *stat_prefix = NULL;
    1.12 +
    1.13  	if (priv == NULL) {
    1.14  		perror("Allocation error");
    1.15  		return 0;
    1.16 @@ -208,12 +214,16 @@ int xenstat_collect_vbds(xenstat_node * 
    1.17  		if (ret != 3)
    1.18  			continue;
    1.19  
    1.20 -		if (strcmp(buf,"vbd") == 0)
    1.21 +
    1.22 +		if (strcmp(buf,"vbd") == 0){
    1.23 +			stat_prefix = "";
    1.24  			vbd.back_type = 1;
    1.25 -		else if (strcmp(buf,"tap") == 0)
    1.26 +		} else if (strcmp(buf,"tap") == 0){
    1.27 +			stat_prefix = "tap_";
    1.28  			vbd.back_type = 2;
    1.29 -		else
    1.30 +		} else {
    1.31  			continue;
    1.32 +		}
    1.33  
    1.34  		domain = xenstat_node_domain(node, domid);
    1.35  		if (domain == NULL) {
    1.36 @@ -224,25 +234,27 @@ int xenstat_collect_vbds(xenstat_node * 
    1.37  			continue;
    1.38  		}
    1.39  
    1.40 -		if((read_attributes_vbd(dp->d_name, "statistics/oo_req", buf, 256)<=0)
    1.41 +		snprintf(ooreq, sizeof(ooreq), "%s%soo_req", sys_prefix, stat_prefix);
    1.42 +		if((read_attributes_vbd(dp->d_name, ooreq, buf, 256)<=0)
    1.43  		   || ((ret = sscanf(buf, "%llu", &vbd.oo_reqs)) != 1))
    1.44  		{
    1.45  			continue;
    1.46  		}
    1.47  
    1.48 -		if((read_attributes_vbd(dp->d_name, "statistics/rd_req", buf, 256)<=0)
    1.49 +		snprintf(rdreq,  sizeof(rdreq),"%s%srd_req", sys_prefix, stat_prefix);
    1.50 +		if((read_attributes_vbd(dp->d_name, rdreq, buf, 256)<=0)
    1.51  		   || ((ret = sscanf(buf, "%llu", &vbd.rd_reqs)) != 1))
    1.52  		{
    1.53  			continue;
    1.54  		}
    1.55  
    1.56 -		if((read_attributes_vbd(dp->d_name, "statistics/wr_req", buf, 256)<=0)
    1.57 +		snprintf(wrreq,  sizeof(wrreq),"%s%swr_req", sys_prefix, stat_prefix);
    1.58 +		if((read_attributes_vbd(dp->d_name, wrreq, buf, 256)<=0)
    1.59  		   || ((ret = sscanf(buf, "%llu", &vbd.wr_reqs)) != 1))
    1.60  		{
    1.61  			continue;
    1.62  		}
    1.63  
    1.64 -
    1.65  		if (domain->vbds == NULL) {
    1.66  			domain->num_vbds = 1;
    1.67  			domain->vbds = malloc(sizeof(xenstat_vbd));