Blame SOURCES/kvm-tools-kvm_stat-add-interactive-command-c.patch

4a2fec
From 38362f9d75028cdcd58b6facb605f71f2a22a9be Mon Sep 17 00:00:00 2001
4a2fec
From: David Hildenbrand <david@redhat.com>
4a2fec
Date: Tue, 17 Oct 2017 19:15:41 +0200
4a2fec
Subject: [PATCH 36/69] tools/kvm_stat: add interactive command 'c'
4a2fec
MIME-Version: 1.0
4a2fec
Content-Type: text/plain; charset=UTF-8
4a2fec
Content-Transfer-Encoding: 8bit
4a2fec
4a2fec
RH-Author: David Hildenbrand <david@redhat.com>
4a2fec
Message-id: <20171017191605.2378-16-david@redhat.com>
4a2fec
Patchwork-id: 77325
4a2fec
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 15/39] tools/kvm_stat: add interactive command 'c'
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 4443084fa0cf85f91d357c8917b90504b784d925
4a2fec
4a2fec
Convertion of documentation (for man page generation) to texi.
4a2fec
4a2fec
commit 4443084fa0cf85f91d357c8917b90504b784d925
4a2fec
Author: Stefan Raspl <raspl@linux.vnet.ibm.com>
4a2fec
Date:   Fri Mar 10 13:40:14 2017 +0100
4a2fec
4a2fec
    tools/kvm_stat: add interactive command 'c'
4a2fec
4a2fec
    Provide a real simple way to erase any active filter.
4a2fec
4a2fec
    Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
4a2fec
    Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
4a2fec
    Signed-off-by: Radim Krčmář <rkrcmar@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
 scripts/kvm/kvm_stat.texi |  3 +++
4a2fec
 2 files changed, 15 insertions(+), 4 deletions(-)
4a2fec
4a2fec
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
4a2fec
index f263312..676a92a 100755
4a2fec
--- a/scripts/kvm/kvm_stat
4a2fec
+++ b/scripts/kvm/kvm_stat
4a2fec
@@ -861,6 +861,7 @@ DELAY_INITIAL = 0.25
4a2fec
 DELAY_REGULAR = 3.0
4a2fec
 MAX_GUEST_NAME_LEN = 48
4a2fec
 MAX_REGEX_LEN = 44
4a2fec
+DEFAULT_REGEX = r'^[^\(]*$'
4a2fec
 
4a2fec
 
4a2fec
 class Tui(object):
4a2fec
@@ -907,9 +908,9 @@ class Tui(object):
4a2fec
     def update_drilldown(self):
4a2fec
         """Sets or removes a filter that only allows fields without braces."""
4a2fec
         if not self.stats.fields_filter:
4a2fec
-            self.stats.fields_filter = r'^[^\(]*$'
4a2fec
+            self.stats.fields_filter = DEFAULT_REGEX
4a2fec
 
4a2fec
-        elif self.stats.fields_filter == r'^[^\(]*$':
4a2fec
+        elif self.stats.fields_filter == DEFAULT_REGEX:
4a2fec
             self.stats.fields_filter = None
4a2fec
 
4a2fec
     def update_pid(self, pid):
4a2fec
@@ -931,7 +932,8 @@ class Tui(object):
4a2fec
                                .format(pid, gname), curses.A_BOLD)
4a2fec
         else:
4a2fec
             self.screen.addstr(0, 0, 'kvm statistics - summary', curses.A_BOLD)
4a2fec
-        if self.stats.fields_filter and self.stats.fields_filter != '^[^\(]*$':
4a2fec
+        if self.stats.fields_filter and self.stats.fields_filter \
4a2fec
+           != DEFAULT_REGEX:
4a2fec
             regex = self.stats.fields_filter
4a2fec
             if len(regex) > MAX_REGEX_LEN:
4a2fec
                 regex = regex[:MAX_REGEX_LEN] + '...'
4a2fec
@@ -991,7 +993,7 @@ class Tui(object):
4a2fec
             regex = self.screen.getstr()
4a2fec
             curses.noecho()
4a2fec
             if len(regex) == 0:
4a2fec
-                self.stats.fields_filter = r'^[^\(]*$'
4a2fec
+                self.stats.fields_filter = DEFAULT_REGEX
4a2fec
                 self.refresh_header()
4a2fec
                 return
4a2fec
             try:
4a2fec
@@ -1101,6 +1103,11 @@ class Tui(object):
4a2fec
                     sleeptime = DELAY_INITIAL
4a2fec
                 if char == 'q':
4a2fec
                     break
4a2fec
+                if char == 'c':
4a2fec
+                    self.stats.fields_filter = DEFAULT_REGEX
4a2fec
+                    self.refresh_header(0)
4a2fec
+                    self.update_pid(0)
4a2fec
+                    sleeptime = DELAY_INITIAL
4a2fec
                 if char == 'f':
4a2fec
                     self.show_filter_selection()
4a2fec
                     sleeptime = DELAY_INITIAL
4a2fec
@@ -1177,6 +1184,7 @@ Requirements:
4a2fec
   the large number of files that are possibly opened.
4a2fec
 
4a2fec
 Interactive Commands:
4a2fec
+   c     clear filter
4a2fec
    f     filter by regular expression
4a2fec
    g     filter by guest name
4a2fec
    p     filter by PID
4a2fec
diff --git a/scripts/kvm/kvm_stat.texi b/scripts/kvm/kvm_stat.texi
4a2fec
index a8c1071..203d61d 100644
4a2fec
--- a/scripts/kvm/kvm_stat.texi
4a2fec
+++ b/scripts/kvm/kvm_stat.texi
4a2fec
@@ -24,6 +24,9 @@ Use batch and logging modes for scripting purposes.
4a2fec
 While running in regular (interactive) mode, use any of the following keys:
4a2fec
 
4a2fec
 @table @key
4a2fec
+@item c
4a2fec
+@kindex c
4a2fec
+clear filter
4a2fec
 @item f
4a2fec
 @kindex f
4a2fec
 filter by regular expression
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec