Blame SOURCES/kvm-tools-kvm_stat-handle-SIGINT-in-log-and-batch-modes.patch

4a2fec
From dada85e20a716597bb06c8684eca7a17a2eb8c5e Mon Sep 17 00:00:00 2001
4a2fec
From: David Hildenbrand <david@redhat.com>
4a2fec
Date: Tue, 17 Oct 2017 19:15:29 +0200
4a2fec
Subject: [PATCH 24/69] tools/kvm_stat: handle SIGINT in log and batch modes
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-4-david@redhat.com>
4a2fec
Patchwork-id: 77318
4a2fec
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 03/39] tools/kvm_stat: handle SIGINT in log and batch modes
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 dadf1e7839243474b691ca4258bfd2a59e628a5e
4a2fec
4a2fec
commit dadf1e7839243474b691ca4258bfd2a59e628a5e
4a2fec
Author: Stefan Raspl <raspl@linux.vnet.ibm.com>
4a2fec
Date:   Fri Mar 10 13:40:02 2017 +0100
4a2fec
4a2fec
    tools/kvm_stat: handle SIGINT in log and batch modes
4a2fec
4a2fec
    SIGINT causes ugly unhandled exceptions in log and batch mode, which we
4a2fec
    prevent by catching the exceptions accordingly.
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 | 28 +++++++++++++++++-----------
4a2fec
 1 file changed, 17 insertions(+), 11 deletions(-)
4a2fec
4a2fec
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
4a2fec
index ef47ad7..14536c0 100755
4a2fec
--- a/scripts/kvm/kvm_stat
4a2fec
+++ b/scripts/kvm/kvm_stat
4a2fec
@@ -969,12 +969,15 @@ class Tui(object):
4a2fec
 
4a2fec
 def batch(stats):
4a2fec
     """Prints statistics in a key, value format."""
4a2fec
-    s = stats.get()
4a2fec
-    time.sleep(1)
4a2fec
-    s = stats.get()
4a2fec
-    for key in sorted(s.keys()):
4a2fec
-        values = s[key]
4a2fec
-        print '%-42s%10d%10d' % (key, values[0], values[1])
4a2fec
+    try:
4a2fec
+        s = stats.get()
4a2fec
+        time.sleep(1)
4a2fec
+        s = stats.get()
4a2fec
+        for key in sorted(s.keys()):
4a2fec
+            values = s[key]
4a2fec
+            print '%-42s%10d%10d' % (key, values[0], values[1])
4a2fec
+    except KeyboardInterrupt:
4a2fec
+        pass
4a2fec
 
4a2fec
 def log(stats):
4a2fec
     """Prints statistics as reiterating key block, multiple value blocks."""
4a2fec
@@ -991,11 +994,14 @@ def log(stats):
4a2fec
     line = 0
4a2fec
     banner_repeat = 20
4a2fec
     while True:
4a2fec
-        time.sleep(1)
4a2fec
-        if line % banner_repeat == 0:
4a2fec
-            banner()
4a2fec
-        statline()
4a2fec
-        line += 1
4a2fec
+        try:
4a2fec
+            time.sleep(1)
4a2fec
+            if line % banner_repeat == 0:
4a2fec
+                banner()
4a2fec
+            statline()
4a2fec
+            line += 1
4a2fec
+        except KeyboardInterrupt:
4a2fec
+            break
4a2fec
 
4a2fec
 def get_options():
4a2fec
     """Returns processed program arguments."""
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec