|
|
4a2fec |
From 592b801e5cc13422eedf2bc81bb27c12e2da3d9e Mon Sep 17 00:00:00 2001
|
|
|
4a2fec |
From: David Hildenbrand <david@redhat.com>
|
|
|
4a2fec |
Date: Tue, 17 Oct 2017 19:16:05 +0200
|
|
|
4a2fec |
Subject: [PATCH 60/69] tools/kvm_stat: add '-f help' to get the available
|
|
|
4a2fec |
event list
|
|
|
4a2fec |
|
|
|
4a2fec |
RH-Author: David Hildenbrand <david@redhat.com>
|
|
|
4a2fec |
Message-id: <20171017191605.2378-40-david@redhat.com>
|
|
|
4a2fec |
Patchwork-id: 77345
|
|
|
4a2fec |
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 39/39] tools/kvm_stat: add '-f help' to get the available event list
|
|
|
4a2fec |
Bugzilla: 1497137
|
|
|
4a2fec |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4a2fec |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
4a2fec |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
4a2fec |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
4a2fec |
|
|
|
4a2fec |
Upstream-status: linux.git 67fbcd62f54d4503e3dc63b68af1c6757b74e050
|
|
|
4a2fec |
|
|
|
4a2fec |
commit 67fbcd62f54d4503e3dc63b68af1c6757b74e050
|
|
|
4a2fec |
Author: Lin Ma <lma@suse.com>
|
|
|
4a2fec |
Date: Tue Jul 25 19:05:54 2017 +0800
|
|
|
4a2fec |
|
|
|
4a2fec |
tools/kvm_stat: add '-f help' to get the available event list
|
|
|
4a2fec |
|
|
|
4a2fec |
Signed-off-by: Lin Ma <lma@suse.com>
|
|
|
4a2fec |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
4a2fec |
|
|
|
4a2fec |
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
|
4a2fec |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
4a2fec |
---
|
|
|
4a2fec |
scripts/kvm/kvm_stat | 16 ++++++++++++++--
|
|
|
4a2fec |
1 file changed, 14 insertions(+), 2 deletions(-)
|
|
|
4a2fec |
|
|
|
4a2fec |
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
|
|
|
4a2fec |
index 5704044..32283d8 100755
|
|
|
4a2fec |
--- a/scripts/kvm/kvm_stat
|
|
|
4a2fec |
+++ b/scripts/kvm/kvm_stat
|
|
|
4a2fec |
@@ -474,7 +474,7 @@ class Provider(object):
|
|
|
4a2fec |
@staticmethod
|
|
|
4a2fec |
def is_field_wanted(fields_filter, field):
|
|
|
4a2fec |
"""Indicate whether field is valid according to fields_filter."""
|
|
|
4a2fec |
- if not fields_filter:
|
|
|
4a2fec |
+ if not fields_filter or fields_filter == "help":
|
|
|
4a2fec |
return True
|
|
|
4a2fec |
return re.match(fields_filter, field) is not None
|
|
|
4a2fec |
|
|
|
4a2fec |
@@ -1496,7 +1496,8 @@ Press any other key to refresh statistics immediately.
|
|
|
4a2fec |
action='store',
|
|
|
4a2fec |
default=DEFAULT_REGEX,
|
|
|
4a2fec |
dest='fields',
|
|
|
4a2fec |
- help='fields to display (regex)',
|
|
|
4a2fec |
+ help='''fields to display (regex)
|
|
|
4a2fec |
+ "-f help" for a list of available events''',
|
|
|
4a2fec |
)
|
|
|
4a2fec |
optparser.add_option('-p', '--pid',
|
|
|
4a2fec |
action='store',
|
|
|
4a2fec |
@@ -1559,6 +1560,17 @@ def main():
|
|
|
4a2fec |
|
|
|
4a2fec |
stats = Stats(options)
|
|
|
4a2fec |
|
|
|
4a2fec |
+ if options.fields == "help":
|
|
|
4a2fec |
+ event_list = "\n"
|
|
|
4a2fec |
+ s = stats.get()
|
|
|
4a2fec |
+ for key in s.keys():
|
|
|
4a2fec |
+ if key.find('(') != -1:
|
|
|
4a2fec |
+ key = key[0:key.find('(')]
|
|
|
4a2fec |
+ if event_list.find('\n' + key + '\n') == -1:
|
|
|
4a2fec |
+ event_list += key + '\n'
|
|
|
4a2fec |
+ sys.stdout.write(event_list)
|
|
|
4a2fec |
+ return ""
|
|
|
4a2fec |
+
|
|
|
4a2fec |
if options.log:
|
|
|
4a2fec |
log(stats)
|
|
|
4a2fec |
elif not options.once:
|
|
|
4a2fec |
--
|
|
|
4a2fec |
1.8.3.1
|
|
|
4a2fec |
|