Skip to content

Commit

Permalink
tools/kvm_stat: sort '-f help' output
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
Stefan-Raspl authored and bonzini committed Dec 21, 2017
1 parent fae1a3e commit aa12f59
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions tools/kvm/kvm_stat/kvm_stat
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit aa12f59

Please sign in to comment.