diff options
author | Stefan Raspl <stefan.raspl@de.ibm.com> | 2018-08-24 08:03:59 -0400 |
---|---|---|
committer | Radim Krčmář <rkrcmar@redhat.com> | 2018-08-30 11:15:12 -0400 |
commit | 29c39f38e4e8dbf0497e81db6c985ee59259f002 (patch) | |
tree | 9699cab1e002fa6b34ac5f942dcdf8fc1e130d79 | |
parent | 0db8b3102368755242b44f2b30f93302c70e8e82 (diff) |
tools/kvm_stat: handle guest removals more gracefully
When running with the DebugFS provider, removal of a guest can result in a
negative CurAvg/s, which looks rather confusing.
If so, suppress the body refresh and print a message instead.
To reproduce, have at least one guest A completely booted. Then start
another guest B (which generates a huge amount of events), then destroy B.
On the next refresh, kvm_stat should display a whole lot of negative values
in the CurAvg/s column.
Signed-off-by: Stefan Raspl <raspl@linux.ibm.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
-rwxr-xr-x | tools/kvm/kvm_stat/kvm_stat | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat index 62fbb8802f60..bd620579eb6f 100755 --- a/tools/kvm/kvm_stat/kvm_stat +++ b/tools/kvm/kvm_stat/kvm_stat | |||
@@ -1194,6 +1194,7 @@ class Tui(object): | |||
1194 | # print events | 1194 | # print events |
1195 | tavg = 0 | 1195 | tavg = 0 |
1196 | tcur = 0 | 1196 | tcur = 0 |
1197 | guest_removed = False | ||
1197 | for key, values in get_sorted_events(self, stats): | 1198 | for key, values in get_sorted_events(self, stats): |
1198 | if row >= self.screen.getmaxyx()[0] - 1 or values == (0, 0): | 1199 | if row >= self.screen.getmaxyx()[0] - 1 or values == (0, 0): |
1199 | break | 1200 | break |
@@ -1201,7 +1202,10 @@ class Tui(object): | |||
1201 | key = self.get_gname_from_pid(key) | 1202 | key = self.get_gname_from_pid(key) |
1202 | if not key: | 1203 | if not key: |
1203 | continue | 1204 | continue |
1204 | cur = int(round(values.delta / sleeptime)) if values.delta else '' | 1205 | cur = int(round(values.delta / sleeptime)) if values.delta else 0 |
1206 | if cur < 0: | ||
1207 | guest_removed = True | ||
1208 | continue | ||
1205 | if key[0] != ' ': | 1209 | if key[0] != ' ': |
1206 | if values.delta: | 1210 | if values.delta: |
1207 | tcur += values.delta | 1211 | tcur += values.delta |
@@ -1214,7 +1218,10 @@ class Tui(object): | |||
1214 | values.value * 100 / float(ltotal), cur)) | 1218 | values.value * 100 / float(ltotal), cur)) |
1215 | row += 1 | 1219 | row += 1 |
1216 | if row == 3: | 1220 | if row == 3: |
1217 | self.screen.addstr(4, 1, 'No matching events reported yet') | 1221 | if guest_removed: |
1222 | self.screen.addstr(4, 1, 'Guest removed, updating...') | ||
1223 | else: | ||
1224 | self.screen.addstr(4, 1, 'No matching events reported yet') | ||
1218 | if row > 4: | 1225 | if row > 4: |
1219 | tavg = int(round(tcur / sleeptime)) if tcur > 0 else '' | 1226 | tavg = int(round(tcur / sleeptime)) if tcur > 0 else '' |
1220 | self.screen.addstr(row, 1, '%-40s %10d %8s' % | 1227 | self.screen.addstr(row, 1, '%-40s %10d %8s' % |