summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorStefan Raspl <stefan.raspl@de.ibm.com>2017-12-21 13:03:27 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2017-12-21 13:03:32 +0100
commitaa12f594f97efe50223611dbd13ecca4e8dafee6 (patch)
tree0b74c359f9a4d34c4dfae50073a7a2517f5e8997 /tools
parentfae1a3e775cca8c3a9e0eb34443b310871a15a92 (diff)
downloadlinux-aa12f594f97efe50223611dbd13ecca4e8dafee6.tar.gz
linux-aa12f594f97efe50223611dbd13ecca4e8dafee6.tar.bz2
linux-aa12f594f97efe50223611dbd13ecca4e8dafee6.zip
tools/kvm_stat: sort '-f help' output
Sort the fields returned by specifying '-f help' on the command line. While at it, simplify the code a bit, indent the output and eliminate an extra blank line at the beginning. Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/kvm/kvm_stat/kvm_stat16
1 files changed, 6 insertions, 10 deletions
diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index 566a70ddd005..a5684d0968b4 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -1579,17 +1579,13 @@ def main():
stats = Stats(options)
- if options.fields == "help":
+ if options.fields == 'help':
stats.fields_filter = None
- event_list = "\n"
- s = stats.get()
- for key in s.keys():
- if key.find('(') != -1:
- key = key[0:key.find('(')]
- if event_list.find('\n' + key + '\n') == -1:
- event_list += key + '\n'
- sys.stdout.write(event_list)
- return ""
+ event_list = []
+ for key in stats.get().keys():
+ event_list.append(key.split('(', 1)[0])
+ sys.stdout.write(' ' + '\n '.join(sorted(set(event_list))) + '\n')
+ sys.exit(0)
if options.log:
log(stats)