public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] tools/kvm_stat: fix typo and add '-f help' field
@ 2017-07-25 11:05 Lin Ma
  2017-07-25 11:05 ` [PATCH 1/2] tools/kvm_stat: use variables instead of hard paths in help output Lin Ma
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lin Ma @ 2017-07-25 11:05 UTC (permalink / raw)
  To: kvm; +Cc: pbonzini

* use variables instead of hard paths in help output
* add '-f help' to get the available event list

Lin Ma (2):
  tools/kvm_stat: use variables instead of hard paths in help output
  tools/kvm_stat: add '-f help' to get the available event list

 tools/kvm/kvm_stat/kvm_stat | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

-- 
2.9.2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] tools/kvm_stat: use variables instead of hard paths in help output
  2017-07-25 11:05 [PATCH 0/2] tools/kvm_stat: fix typo and add '-f help' field Lin Ma
@ 2017-07-25 11:05 ` Lin Ma
  2017-07-25 11:05 ` [PATCH 2/2] tools/kvm_stat: add '-f help' to get the available event list Lin Ma
  2017-07-25 13:33 ` [PATCH 0/2] tools/kvm_stat: fix typo and add '-f help' field Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Lin Ma @ 2017-07-25 11:05 UTC (permalink / raw)
  To: kvm; +Cc: pbonzini

Using variables instead of hard paths makes the requirements information
more accurate.

Signed-off-by: Lin Ma <lma@suse.com>
---
 tools/kvm/kvm_stat/kvm_stat | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index dd8f00cf..5704044 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -1413,8 +1413,8 @@ performance.
 
 Requirements:
 - Access to:
-    /sys/kernel/debug/kvm
-    /sys/kernel/debug/trace/events/*
+    %s
+    %s/events/*
     /proc/pid/task
 - /proc/sys/kernel/perf_event_paranoid < 1 if user has no
   CAP_SYS_ADMIN and perf events are used.
@@ -1434,7 +1434,7 @@ Interactive Commands:
    s     set update interval
    x     toggle reporting of stats for individual child trace events
 Press any other key to refresh statistics immediately.
-"""
+""" % (PATH_DEBUGFS_KVM, PATH_DEBUGFS_TRACING)
 
     class PlainHelpFormatter(optparse.IndentedHelpFormatter):
         def format_description(self, description):
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] tools/kvm_stat: add '-f help' to get the available event list
  2017-07-25 11:05 [PATCH 0/2] tools/kvm_stat: fix typo and add '-f help' field Lin Ma
  2017-07-25 11:05 ` [PATCH 1/2] tools/kvm_stat: use variables instead of hard paths in help output Lin Ma
@ 2017-07-25 11:05 ` Lin Ma
  2017-07-25 13:33 ` [PATCH 0/2] tools/kvm_stat: fix typo and add '-f help' field Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Lin Ma @ 2017-07-25 11:05 UTC (permalink / raw)
  To: kvm; +Cc: pbonzini

Signed-off-by: Lin Ma <lma@suse.com>
---
 tools/kvm/kvm_stat/kvm_stat | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index 5704044..32283d8 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -474,7 +474,7 @@ class Provider(object):
     @staticmethod
     def is_field_wanted(fields_filter, field):
         """Indicate whether field is valid according to fields_filter."""
-        if not fields_filter:
+        if not fields_filter or fields_filter == "help":
             return True
         return re.match(fields_filter, field) is not None
 
@@ -1496,7 +1496,8 @@ Press any other key to refresh statistics immediately.
                          action='store',
                          default=DEFAULT_REGEX,
                          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',
                          action='store',
@@ -1559,6 +1560,17 @@ def main():
 
     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:
         log(stats)
     elif not options.once:
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] tools/kvm_stat: fix typo and add '-f help' field
  2017-07-25 11:05 [PATCH 0/2] tools/kvm_stat: fix typo and add '-f help' field Lin Ma
  2017-07-25 11:05 ` [PATCH 1/2] tools/kvm_stat: use variables instead of hard paths in help output Lin Ma
  2017-07-25 11:05 ` [PATCH 2/2] tools/kvm_stat: add '-f help' to get the available event list Lin Ma
@ 2017-07-25 13:33 ` Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2017-07-25 13:33 UTC (permalink / raw)
  To: Lin Ma, kvm

On 25/07/2017 13:05, Lin Ma wrote:
> * use variables instead of hard paths in help output
> * add '-f help' to get the available event list
> 
> Lin Ma (2):
>   tools/kvm_stat: use variables instead of hard paths in help output
>   tools/kvm_stat: add '-f help' to get the available event list
> 
>  tools/kvm/kvm_stat/kvm_stat | 22 +++++++++++++++++-----
>  1 file changed, 17 insertions(+), 5 deletions(-)
> 

Applied, thanks.

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-07-25 13:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-25 11:05 [PATCH 0/2] tools/kvm_stat: fix typo and add '-f help' field Lin Ma
2017-07-25 11:05 ` [PATCH 1/2] tools/kvm_stat: use variables instead of hard paths in help output Lin Ma
2017-07-25 11:05 ` [PATCH 2/2] tools/kvm_stat: add '-f help' to get the available event list Lin Ma
2017-07-25 13:33 ` [PATCH 0/2] tools/kvm_stat: fix typo and add '-f help' field Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox