summaryrefslogtreecommitdiffstats
path: root/tools/kvm
diff options
context:
space:
mode:
authorStefan Raspl <stefan.raspl@de.ibm.com>2018-08-24 08:03:56 -0400
committerRadim Krčmář <rkrcmar@redhat.com>2018-08-30 11:15:12 -0400
commit617c66b9f236d20f11cecbb3f45e6d5675b2fae1 (patch)
treeb3d987012daec6cea5ed93421d7ba5d5cde641e3 /tools/kvm
parent58f33cfe73076b6497bada4f7b5bda961ed68083 (diff)
tools/kvm_stat: fix handling of invalid paths in debugfs provider
When filtering by guest, kvm_stat displays garbage when the guest is destroyed - see sample output below. We add code to remove the invalid paths from the providers, so at least no more garbage is displayed. Here's a sample output to illustrate: kvm statistics - pid 13986 (foo) Event Total %Total CurAvg/s diagnose_258 -2 0.0 0 deliver_program_interruption -3 0.0 0 diagnose_308 -4 0.0 0 halt_poll_invalid -91 0.0 -6 deliver_service_signal -244 0.0 -16 halt_successful_poll -250 0.1 -17 exit_pei -285 0.1 -19 exit_external_request -312 0.1 -21 diagnose_9c -328 0.1 -22 userspace_handled -713 0.1 -47 halt_attempted_poll -939 0.2 -62 deliver_emergency_signal -3126 0.6 -208 halt_wakeup -7199 1.5 -481 exit_wait_state -7379 1.5 -493 diagnose_500 -56499 11.5 -3757 exit_null -85491 17.4 -5685 diagnose_44 -133300 27.1 -8874 exit_instruction -195898 39.8 -13037 Total -492063 Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Diffstat (limited to 'tools/kvm')
-rwxr-xr-xtools/kvm/kvm_stat/kvm_stat8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index e10b90a8917a..b9e8d0def1ab 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -766,6 +766,13 @@ class DebugfsProvider(Provider):
766 self.do_read = True 766 self.do_read = True
767 self.reset() 767 self.reset()
768 768
769 def _verify_paths(self):
770 """Remove invalid paths"""
771 for path in self.paths:
772 if not os.path.exists(os.path.join(PATH_DEBUGFS_KVM, path)):
773 self.paths.remove(path)
774 continue
775
769 def read(self, reset=0, by_guest=0): 776 def read(self, reset=0, by_guest=0):
770 """Returns a dict with format:'file name / field -> current value'. 777 """Returns a dict with format:'file name / field -> current value'.
771 778
@@ -780,6 +787,7 @@ class DebugfsProvider(Provider):
780 # If no debugfs filtering support is available, then don't read. 787 # If no debugfs filtering support is available, then don't read.
781 if not self.do_read: 788 if not self.do_read:
782 return results 789 return results
790 self._verify_paths()
783 791
784 paths = self.paths 792 paths = self.paths
785 if self._pid == 0: 793 if self._pid == 0: