Commit c012a0f2 authored by Stefan Raspl's avatar Stefan Raspl Committed by Radim Krčmář

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: default avatarStefan Raspl <raspl@linux.ibm.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
parent 404517e4
...@@ -1103,6 +1103,7 @@ class Tui(object): ...@@ -1103,6 +1103,7 @@ class Tui(object):
pid = self.stats.pid_filter pid = self.stats.pid_filter
self.screen.erase() self.screen.erase()
gname = self.get_gname_from_pid(pid) gname = self.get_gname_from_pid(pid)
self._gname = gname
if gname: if gname:
gname = ('({})'.format(gname[:MAX_GUEST_NAME_LEN] + '...' gname = ('({})'.format(gname[:MAX_GUEST_NAME_LEN] + '...'
if len(gname) > MAX_GUEST_NAME_LEN if len(gname) > MAX_GUEST_NAME_LEN
...@@ -1170,6 +1171,15 @@ class Tui(object): ...@@ -1170,6 +1171,15 @@ class Tui(object):
return sorted_items return sorted_items
if not self._is_running_guest(self.stats.pid_filter): if not self._is_running_guest(self.stats.pid_filter):
if self._gname:
try: # ...to identify the guest by name in case it's back
pids = self.get_pid_from_gname(self._gname)
if len(pids) == 1:
self._refresh_header(pids[0])
self._update_pid(pids[0])
return
except:
pass
self._display_guest_dead() self._display_guest_dead()
# leave final data on screen # leave final data on screen
return return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment