Skip to content

Commit c012a0f

Browse files
Stefan-Rasplrkrcmar
authored andcommitted
tools/kvm_stat: re-animate display of dead guests
When filtering by guest (interactive commands 'p'/'g'), and the respective guest was destroyed, detect when the guest is up again through the guest name if possible. I.e. when displaying events for a specific guest, it is not necessary anymore to restart kvm_stat in case the guest is restarted. Signed-off-by: Stefan Raspl <raspl@linux.ibm.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
1 parent 404517e commit c012a0f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tools/kvm/kvm_stat/kvm_stat

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,7 @@ class Tui(object):
11031103
pid = self.stats.pid_filter
11041104
self.screen.erase()
11051105
gname = self.get_gname_from_pid(pid)
1106+
self._gname = gname
11061107
if gname:
11071108
gname = ('({})'.format(gname[:MAX_GUEST_NAME_LEN] + '...'
11081109
if len(gname) > MAX_GUEST_NAME_LEN
@@ -1170,6 +1171,15 @@ class Tui(object):
11701171
return sorted_items
11711172

11721173
if not self._is_running_guest(self.stats.pid_filter):
1174+
if self._gname:
1175+
try: # ...to identify the guest by name in case it's back
1176+
pids = self.get_pid_from_gname(self._gname)
1177+
if len(pids) == 1:
1178+
self._refresh_header(pids[0])
1179+
self._update_pid(pids[0])
1180+
return
1181+
except:
1182+
pass
11731183
self._display_guest_dead()
11741184
# leave final data on screen
11751185
return

0 commit comments

Comments
 (0)