Commit 67fbcd62 authored by Lin Ma's avatar Lin Ma Committed by Paolo Bonzini

tools/kvm_stat: add '-f help' to get the available event list

Signed-off-by: default avatarLin Ma <lma@suse.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent efcb5219
...@@ -474,7 +474,7 @@ class Provider(object): ...@@ -474,7 +474,7 @@ class Provider(object):
@staticmethod @staticmethod
def is_field_wanted(fields_filter, field): def is_field_wanted(fields_filter, field):
"""Indicate whether field is valid according to fields_filter.""" """Indicate whether field is valid according to fields_filter."""
if not fields_filter: if not fields_filter or fields_filter == "help":
return True return True
return re.match(fields_filter, field) is not None return re.match(fields_filter, field) is not None
...@@ -1496,7 +1496,8 @@ Press any other key to refresh statistics immediately. ...@@ -1496,7 +1496,8 @@ Press any other key to refresh statistics immediately.
action='store', action='store',
default=DEFAULT_REGEX, default=DEFAULT_REGEX,
dest='fields', dest='fields',
help='fields to display (regex)', help='''fields to display (regex)
"-f help" for a list of available events''',
) )
optparser.add_option('-p', '--pid', optparser.add_option('-p', '--pid',
action='store', action='store',
...@@ -1559,6 +1560,17 @@ def main(): ...@@ -1559,6 +1560,17 @@ def main():
stats = Stats(options) stats = Stats(options)
if options.fields == "help":
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 ""
if options.log: if options.log:
log(stats) log(stats)
elif not options.once: elif not options.once:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment