Blob Blame History Raw
From 05cc1c1aab959dde7801cabe184c5f4b287835b6 Mon Sep 17 00:00:00 2001
From: David Hildenbrand <david@redhat.com>
Date: Tue, 17 Oct 2017 19:15:37 +0200
Subject: [PATCH 32/69] tools/kvm_stat: print error messages on faulty pid
 filter input
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

RH-Author: David Hildenbrand <david@redhat.com>
Message-id: <20171017191605.2378-12-david@redhat.com>
Patchwork-id: 77321
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 11/39] tools/kvm_stat: print error messages on faulty pid filter input
Bugzilla: 1497137
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Thomas Huth <thuth@redhat.com>

Upstream-status: linux.git 0152c20f0400498774ae56067f8076cef312abc7

commit 0152c20f0400498774ae56067f8076cef312abc7
Author: Stefan Raspl <raspl@linux.vnet.ibm.com>
Date:   Fri Mar 10 13:40:10 2017 +0100

    tools/kvm_stat: print error messages on faulty pid filter input

    Print helpful messages in case users enter invalid input or invalid pids in
    the interactive pid filter dialogue.

    Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
    Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
    Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>

Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 scripts/kvm/kvm_stat | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
index 9e9eb98..ced0cb9 100755
--- a/scripts/kvm/kvm_stat
+++ b/scripts/kvm/kvm_stat
@@ -976,6 +976,7 @@ class Tui(object):
         Asks for a pid until a valid pid or 0 has been entered.
 
         """
+        msg = ''
         while True:
             self.screen.erase()
             self.screen.addstr(0, 0,
@@ -984,6 +985,7 @@ class Tui(object):
             self.screen.addstr(1, 0,
                                'This might limit the shown data to the trace '
                                'statistics.')
+            self.screen.addstr(5, 0, msg)
 
             curses.echo()
             self.screen.addstr(3, 0, "Pid [0 or pid]: ")
@@ -995,6 +997,7 @@ class Tui(object):
                     pid = int(pid)
                     if pid != 0 and not os.path.isdir(os.path.join('/proc/',
                                                                    str(pid))):
+                        msg = '"' + str(pid) + '": Not a running process'
                         continue
                 else:
                     pid = 0
@@ -1003,6 +1006,7 @@ class Tui(object):
                 break
 
             except ValueError:
+                msg = '"' + str(pid) + '": Not a valid pid'
                 continue
 
     def show_stats(self):
-- 
1.8.3.1