aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Raspl <stefan.raspl@de.ibm.com>2018-08-24 08:03:57 -0400
committerRadim Krčmář <rkrcmar@redhat.com>2018-08-30 11:15:12 -0400
commit710ab11ad9329d2d4b044405e328c994b19a2aa9 (patch)
tree654adc6f7cef41e5c4083b248043ee842b360701
parent617c66b9f236d20f11cecbb3f45e6d5675b2fae1 (diff)
tools/kvm_stat: fix updates for dead guests
With pid filtering active, when a guest is removed e.g. via virsh shutdown, successive updates produce garbage. Therefore, we add code to detect this case and prevent further body updates. Note that when displaying the help dialog via 'h' in this case, once we exit we're stuck with the 'Collecting data...' message till we remove the filter. Signed-off-by: Stefan Raspl <raspl@linux.ibm.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
-rwxr-xr-xtools/kvm/kvm_stat/kvm_stat11
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index b9e8d0def1ab..7c92545931e3 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -1170,6 +1170,9 @@ class Tui(object):
1170 1170
1171 return sorted_items 1171 return sorted_items
1172 1172
1173 if not self._is_running_guest(self.stats.pid_filter):
1174 # leave final data on screen
1175 return
1173 row = 3 1176 row = 3
1174 self.screen.move(row, 0) 1177 self.screen.move(row, 0)
1175 self.screen.clrtobot() 1178 self.screen.clrtobot()
@@ -1327,6 +1330,12 @@ class Tui(object):
1327 msg = '"' + str(val) + '": Invalid value' 1330 msg = '"' + str(val) + '": Invalid value'
1328 self._refresh_header() 1331 self._refresh_header()
1329 1332
1333 def _is_running_guest(self, pid):
1334 """Check if pid is still a running process."""
1335 if not pid:
1336 return True
1337 return os.path.isdir(os.path.join('/proc/', str(pid)))
1338
1330 def _show_vm_selection_by_guest(self): 1339 def _show_vm_selection_by_guest(self):
1331 """Draws guest selection mask. 1340 """Draws guest selection mask.
1332 1341
@@ -1354,7 +1363,7 @@ class Tui(object):
1354 if not guest or guest == '0': 1363 if not guest or guest == '0':
1355 break 1364 break
1356 if guest.isdigit(): 1365 if guest.isdigit():
1357 if not os.path.isdir(os.path.join('/proc/', guest)): 1366 if not self._is_running_guest(guest):
1358 msg = '"' + guest + '": Not a running process' 1367 msg = '"' + guest + '": Not a running process'
1359 continue 1368 continue
1360 pid = int(guest) 1369 pid = int(guest)