From: Pritha Srivastava
Displaying 0 is misleading.
Signed-off-by: Pritha Srivastava
Signed-off-by: Ronan Abhamon
---
tools/xenstat/libxenstat/src/xenstat.c | 6 +
tools/xenstat/libxenstat/src/xenstat.h | 5 +
tools/xenstat/libxenstat/src/xenstat_linux.c | 47 +++---
tools/xenstat/libxenstat/src/xenstat_priv.h | 1 +
tools/xenstat/xentop/xentop.c| 161 ++-
5 files changed, 158 insertions(+), 62 deletions(-)
diff --git a/tools/xenstat/libxenstat/src/xenstat.c
b/tools/xenstat/libxenstat/src/xenstat.c
index fbe44f3c56..8b856b32a3 100644
--- a/tools/xenstat/libxenstat/src/xenstat.c
+++ b/tools/xenstat/libxenstat/src/xenstat.c
@@ -729,6 +729,12 @@ unsigned long long xenstat_vbd_wr_sects(xenstat_vbd * vbd)
return vbd->wr_sects;
}
+/* Returns error while getting stats (1 if error happened, 0 otherwise) */
+bool xenstat_vbd_error(xenstat_vbd * vbd)
+{
+ return vbd->error;
+}
+
/*
* Tmem functions
*/
diff --git a/tools/xenstat/libxenstat/src/xenstat.h
b/tools/xenstat/libxenstat/src/xenstat.h
index 47ec60e14d..9f5053dd92 100644
--- a/tools/xenstat/libxenstat/src/xenstat.h
+++ b/tools/xenstat/libxenstat/src/xenstat.h
@@ -20,6 +20,8 @@
#ifndef XENSTAT_H
#define XENSTAT_H
+#include
+
/* Opaque handles */
typedef struct xenstat_handle xenstat_handle;
typedef struct xenstat_domain xenstat_domain;
@@ -193,6 +195,9 @@ unsigned long long xenstat_vbd_wr_reqs(xenstat_vbd * vbd);
unsigned long long xenstat_vbd_rd_sects(xenstat_vbd * vbd);
unsigned long long xenstat_vbd_wr_sects(xenstat_vbd * vbd);
+/* Returns error while getting stats (1 if error happened, 0 otherwise) */
+bool xenstat_vbd_error(xenstat_vbd * vbd);
+
/*
* Tmem functions - extract tmem information
*/
diff --git a/tools/xenstat/libxenstat/src/xenstat_linux.c
b/tools/xenstat/libxenstat/src/xenstat_linux.c
index 7cdd3bf91f..9421ca43c8 100644
--- a/tools/xenstat/libxenstat/src/xenstat_linux.c
+++ b/tools/xenstat/libxenstat/src/xenstat_linux.c
@@ -436,13 +436,15 @@ int xenstat_collect_vbds(xenstat_node * node)
ret = sscanf(dp->d_name, "%3s-%u-%u", buf, , );
if (ret != 3)
continue;
+ if (!(strstr(buf, "vbd")) && !(strstr(buf, "tap")))
+ continue;
if (strcmp(buf,"vbd") == 0)
vbd.back_type = 1;
else if (strcmp(buf,"tap") == 0)
vbd.back_type = 2;
else
- continue;
+ vbd.back_type = 0;
domain = xenstat_node_domain(node, domid);
if (domain == NULL) {
@@ -453,36 +455,29 @@ int xenstat_collect_vbds(xenstat_node * node)
continue;
}
- if((read_attributes_vbd(dp->d_name, "statistics/oo_req", buf,
256)<=0)
- || ((ret = sscanf(buf, "%llu", _reqs)) != 1))
- {
- continue;
- }
-
- if((read_attributes_vbd(dp->d_name, "statistics/rd_req", buf,
256)<=0)
- || ((ret = sscanf(buf, "%llu", _reqs)) != 1))
+ if (vbd.back_type == 1 || vbd.back_type == 2)
{
- continue;
- }
- if((read_attributes_vbd(dp->d_name, "statistics/wr_req", buf,
256)<=0)
- || ((ret = sscanf(buf, "%llu", _reqs)) != 1))
- {
- continue;
- }
-
- if((read_attributes_vbd(dp->d_name, "statistics/rd_sect", buf,
256)<=0)
- || ((ret = sscanf(buf, "%llu", _sects)) != 1))
- {
- continue;
+ vbd.error = 0;
+
+ if ((read_attributes_vbd(dp->d_name,
"statistics/oo_req", buf, 256)<=0) ||
+ ((ret = sscanf(buf, "%llu", _reqs)) !=
1) ||
+ (read_attributes_vbd(dp->d_name,
"statistics/rd_req", buf, 256)<=0) ||
+ ((ret = sscanf(buf, "%llu", _reqs)) !=
1) ||
+ (read_attributes_vbd(dp->d_name,
"statistics/wr_req", buf, 256)<=0) ||
+ ((ret = sscanf(buf, "%llu", _reqs)) !=
1) ||
+ (read_attributes_vbd(dp->d_name,
"statistics/rd_sect", buf, 256)<=0) ||
+ ((ret = sscanf(buf, "%llu", _sects)) !=
1) ||
+ (read_attributes_vbd(dp->d_name,
"statistics/wr_sect", buf, 256)<=0) ||
+ ((ret = sscanf(buf, "%llu", _sects)) !=
1))
+ {
+ vbd.error = 1;
+ }
}
-
- if((read_attributes_vbd(dp->d_name, "statistics/wr_sect", buf,
256)<=0)
- || ((ret = sscanf(buf, "%llu", _sects)) != 1))
+