Skip to content

Commit 29c39f3

Browse files
Stefan-Rasplrkrcmar
authored andcommitted
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>
1 parent 0db8b31 commit 29c39f3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tools/kvm/kvm_stat/kvm_stat

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,14 +1194,18 @@ class Tui(object):
11941194
# print events
11951195
tavg = 0
11961196
tcur = 0
1197+
guest_removed = False
11971198
for key, values in get_sorted_events(self, stats):
11981199
if row >= self.screen.getmaxyx()[0] - 1 or values == (0, 0):
11991200
break
12001201
if self._display_guests:
12011202
key = self.get_gname_from_pid(key)
12021203
if not key:
12031204
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
12051209
if key[0] != ' ':
12061210
if values.delta:
12071211
tcur += values.delta
@@ -1214,7 +1218,10 @@ class Tui(object):
12141218
values.value * 100 / float(ltotal), cur))
12151219
row += 1
12161220
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')
12181225
if row > 4:
12191226
tavg = int(round(tcur / sleeptime)) if tcur > 0 else ''
12201227
self.screen.addstr(row, 1, '%-40s %10d %8s' %

0 commit comments

Comments
 (0)