diff options
author | Janosch Frank <frankja@linux.vnet.ibm.com> | 2016-01-11 16:18:02 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-01-26 15:58:13 +0100 |
commit | 126b33e6191cd21ba7e05673eb1428b73bf2d34e (patch) | |
tree | d03b881037973183652c4612bfbc4ad48d3c3822 | |
parent | 1cd55f9dc7debdad0d54f4fad8617527433b4c4b (diff) |
scripts/kvm/kvm_stat: Fixup filtering
When filtering, the group leader event should not be disabled, as all
other events under it will also be disabled. Also we should make sure
that values from disabled fields will not be displayed.
This also filters the fields from the log and batch output for better
readability.
Also the drilldown update now directly checks for the stats' field
filter and (un)sets drilldown accordingly.
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-33-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rwxr-xr-x | scripts/kvm/kvm_stat | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat index 2a1842e33e..eb97a650f0 100755 --- a/scripts/kvm/kvm_stat +++ b/scripts/kvm/kvm_stat @@ -467,6 +467,9 @@ class TracepointProvider(object): trace_filter=tracefilter)) self.group_leaders.append(group) + def available_fields(self): + return self.get_available_fields() + @property def fields(self): return self._fields @@ -475,23 +478,30 @@ class TracepointProvider(object): def fields(self, fields): self._fields = fields for group in self.group_leaders: - for event in group.events: + for index, event in enumerate(group.events): if event.name in fields: event.reset() event.enable() else: - event.disable() + # Do not disable the group leader. + # It would disable all of its events. + if index != 0: + event.disable() def read(self): ret = defaultdict(int) for group in self.group_leaders: for name, val in group.read().iteritems(): - ret[name] += val + if name in self._fields: + ret[name] += val return ret class DebugfsProvider(object): def __init__(self): - self._fields = walkdir(PATH_DEBUGFS_KVM)[2] + self._fields = self.get_available_fields() + + def get_available_fields(self): + return walkdir(PATH_DEBUGFS_KVM)[2] @property def fields(self): @@ -523,7 +533,8 @@ class Stats(object): # also clear the cache of old values. self.values = {} for provider in self.providers: - provider_fields = [key for key in provider.fields if wanted(key)] + provider_fields = [key for key in provider.get_available_fields() + if wanted(key)] provider.fields = provider_fields @property @@ -555,7 +566,6 @@ class Tui(object): self.stats = stats self.screen = None self.drilldown = False - self.fields_filter = self.stats.fields_filter self.update_drilldown() def __enter__(self): @@ -586,11 +596,11 @@ class Tui(object): curses.endwin() def update_drilldown(self): - if not self.fields_filter: - if self.drilldown: - self.stats.fields_filter = None - else: - self.stats.fields_filter = r'^[^\(]*$' + if not self.stats.fields_filter: + self.stats.fields_filter = r'^[^\(]*$' + + elif self.stats.fields_filter == r'^[^\(]*$': + self.stats.fields_filter = None def refresh(self, sleeptime): self.screen.erase() |