ia64/xen-unstable

changeset 17135:368d3774a4b5

Fix libxenstat on Solaris

Recent Solaris enhancements have changed the way virtual NIC
statistics are collected - fix libxenstat up for this.

Signed-off-by: John Levon <john.levon@sun.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Feb 27 13:10:42 2008 +0000 (2008-02-27)
parents 2a8eaba24bf0
children 6951fb517f5b
files tools/xenstat/libxenstat/src/xenstat_solaris.c
line diff
     1.1 --- a/tools/xenstat/libxenstat/src/xenstat_solaris.c	Tue Feb 26 15:11:51 2008 +0000
     1.2 +++ b/tools/xenstat/libxenstat/src/xenstat_solaris.c	Wed Feb 27 13:10:42 2008 +0000
     1.3 @@ -113,49 +113,23 @@ static void xenstat_uninit_devs(xenstat_
     1.4  	priv->kc = NULL;
     1.5  }
     1.6  
     1.7 -static int parse_nic(const char *nic, char *module, int *instance)
     1.8 -{
     1.9 -	const char *c;
    1.10 -
    1.11 -	for (c = &nic[strlen(nic) - 1]; c != nic && isdigit(*c); c--)
    1.12 -		;
    1.13 -
    1.14 -	if (c == nic)
    1.15 -		return 0;
    1.16 -
    1.17 -	c++;
    1.18 -
    1.19 -	if (sscanf(c, "%d", instance) != 1)
    1.20 -		return 0;
    1.21 -
    1.22 -	strncpy(module, nic, c - nic);
    1.23 -	module[c - nic] = '\0';
    1.24 -	return 1;
    1.25 -}
    1.26 -
    1.27  static int update_dev_stats(priv_data_t *priv, stdevice_t *dev)
    1.28  {
    1.29 -	char mod[256];
    1.30 -	const char *name;
    1.31 -	int inst;
    1.32  	kstat_t *ksp;
    1.33  
    1.34 -	if (dev->type == DEVICE_NIC) {
    1.35 -		if (!parse_nic(dev->name, mod, &inst))
    1.36 -			return 0;
    1.37 -		name = "mac";
    1.38 -	} else {
    1.39 -		strcpy(mod, "xdb");
    1.40 -		inst = dev->instance;
    1.41 -		name = "req_statistics";
    1.42 -	}
    1.43 -
    1.44  	if (kstat_chain_update(priv->kc) == -1)
    1.45  		return 0;
    1.46  
    1.47 -	ksp = kstat_lookup(priv->kc, mod, inst, (char *)name);
    1.48 +	if (dev->type == DEVICE_NIC) {
    1.49 +		ksp = kstat_lookup(priv->kc, "link", 0, (char *)dev->name);
    1.50 +	} else {
    1.51 +		ksp = kstat_lookup(priv->kc, "xdb", dev->instance,
    1.52 +		    (char *)"req_statistics");
    1.53 +	}
    1.54 +
    1.55  	if (ksp == NULL)
    1.56  		return 0;
    1.57 +
    1.58  	if (kstat_read(priv->kc, ksp, NULL) == -1)
    1.59  		return 0;
    1.60