Skip to content

Commit 404517e

Browse files
Stefan-Rasplrkrcmar
authored andcommitted
tools/kvm_stat: indicate dead guests as such
For destroyed guests, kvm_stat essentially freezes with the last data displayed. This is acceptable for users, in case they want to inspect the final data. But it looks a bit irritating. Therefore, detect this situation and display a respective indicator in the header. Signed-off-by: Stefan Raspl <raspl@linux.ibm.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
1 parent 29c39f3 commit 404517e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tools/kvm/kvm_stat/kvm_stat

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,10 +1108,10 @@ class Tui(object):
11081108
if len(gname) > MAX_GUEST_NAME_LEN
11091109
else gname))
11101110
if pid > 0:
1111-
self.screen.addstr(0, 0, 'kvm statistics - pid {0} {1}'
1112-
.format(pid, gname), curses.A_BOLD)
1111+
self._headline = 'kvm statistics - pid {0} {1}'.format(pid, gname)
11131112
else:
1114-
self.screen.addstr(0, 0, 'kvm statistics - summary', curses.A_BOLD)
1113+
self._headline = 'kvm statistics - summary'
1114+
self.screen.addstr(0, 0, self._headline, curses.A_BOLD)
11151115
if self.stats.fields_filter:
11161116
regex = self.stats.fields_filter
11171117
if len(regex) > MAX_REGEX_LEN:
@@ -1170,6 +1170,7 @@ class Tui(object):
11701170
return sorted_items
11711171

11721172
if not self._is_running_guest(self.stats.pid_filter):
1173+
self._display_guest_dead()
11731174
# leave final data on screen
11741175
return
11751176
row = 3
@@ -1228,6 +1229,11 @@ class Tui(object):
12281229
('Total', total, tavg), curses.A_BOLD)
12291230
self.screen.refresh()
12301231

1232+
def _display_guest_dead(self):
1233+
marker = ' Guest is DEAD '
1234+
y = min(len(self._headline), 80 - len(marker))
1235+
self.screen.addstr(0, y, marker, curses.A_BLINK | curses.A_STANDOUT)
1236+
12311237
def _show_msg(self, text):
12321238
"""Display message centered text and exit on key press"""
12331239
hint = 'Press any key to continue'

0 commit comments

Comments
 (0)