From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>, kvm@vger.kernel.org
Subject: [PATCH 4/4] kvm_stat: add 'x' key for enabling/disabling "drilldown"
Date: Thu, 17 Feb 2011 14:42:50 +0200 [thread overview]
Message-ID: <1297946570-477-5-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1297946570-477-1-git-send-email-avi@redhat.com>
Pressing 'x' enables drilldown into kvm_exit reasons. Pressing it
again reverts to normal behaviour.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
kvm/kvm_stat | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/kvm/kvm_stat b/kvm/kvm_stat
index e3e9def..db2d135 100755
--- a/kvm/kvm_stat
+++ b/kvm/kvm_stat
@@ -311,20 +311,26 @@ class TracepointProvider(object):
class Stats:
def __init__(self, provider, fields = None):
+ self.provider = provider
+ self.fields_filter = fields
+ self._update()
+ def _update(self):
def wanted(key):
import re
- if not fields:
+ if not self.fields_filter:
return True
- return re.match(fields, key) != None
- self.provider = provider
+ return re.match(self.fields_filter, key) is not None
self.values = dict([(key, None)
for key in provider.fields()
if wanted(key)])
self.provider.select(self.values.keys())
+ def set_fields_filter(self, fields_filter):
+ self.fields_filter = fields_filter
+ self._update()
def get(self):
new = self.provider.read()
for key in self.provider.fields():
- oldval = self.values[key]
+ oldval = self.values.get(key, (0, 0))
newval = new[key]
newdelta = None
if oldval is not None:
@@ -346,6 +352,15 @@ number_width = 10
def tui(screen, stats):
curses.use_default_colors()
curses.noecho()
+ drilldown = False
+ fields_filter = stats.fields_filter
+ def update_drilldown():
+ if not fields_filter:
+ if drilldown:
+ stats.set_fields_filter(None)
+ else:
+ stats.set_fields_filter(r'^[^\(]*$')
+ update_drilldown()
def refresh(sleeptime):
screen.erase()
screen.addstr(0, 0, 'kvm statistics')
@@ -379,6 +394,9 @@ def tui(screen, stats):
sleeptime = 3
try:
c = screen.getkey()
+ if c == 'x':
+ drilldown = not drilldown
+ update_drilldown()
if c == 'q':
break
except KeyboardInterrupt:
--
1.7.1
prev parent reply other threads:[~2011-02-17 12:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-17 12:42 [PATCH 0/4] Enable drilldown for kvm_exit reasons Avi Kivity
2011-02-17 12:42 ` [PATCH 1/4] kvm_stat: move groups and events into well defined objects Avi Kivity
2011-02-17 12:42 ` [PATCH 2/4] kvm_stat: add wrappers for perf_event enable and disable ioctls Avi Kivity
2011-02-17 12:42 ` [PATCH 3/4] kvm_stat: allow enabling/disabling events dynamicalls Avi Kivity
2011-02-17 12:42 ` Avi Kivity [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1297946570-477-5-git-send-email-avi@redhat.com \
--to=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox