Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0152c20f authored by Stefan Raspl's avatar Stefan Raspl Committed by Paolo Bonzini
Browse files

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: default avatarStefan Raspl <raspl@linux.vnet.ibm.com>
Reviewed-by: default avatarMarc Hartmayer <mhartmay@linux.vnet.ibm.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
parent be03ea3b
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -976,6 +976,7 @@ class Tui(object):
        Asks for a pid until a valid pid or 0 has been entered.
        Asks for a pid until a valid pid or 0 has been entered.


        """
        """
        msg = ''
        while True:
        while True:
            self.screen.erase()
            self.screen.erase()
            self.screen.addstr(0, 0,
            self.screen.addstr(0, 0,
@@ -984,6 +985,7 @@ class Tui(object):
            self.screen.addstr(1, 0,
            self.screen.addstr(1, 0,
                               'This might limit the shown data to the trace '
                               'This might limit the shown data to the trace '
                               'statistics.')
                               'statistics.')
            self.screen.addstr(5, 0, msg)


            curses.echo()
            curses.echo()
            self.screen.addstr(3, 0, "Pid [0 or pid]: ")
            self.screen.addstr(3, 0, "Pid [0 or pid]: ")
@@ -995,6 +997,7 @@ class Tui(object):
                    pid = int(pid)
                    pid = int(pid)
                    if pid != 0 and not os.path.isdir(os.path.join('/proc/',
                    if pid != 0 and not os.path.isdir(os.path.join('/proc/',
                                                                   str(pid))):
                                                                   str(pid))):
                        msg = '"' + str(pid) + '": Not a running process'
                        continue
                        continue
                else:
                else:
                    pid = 0
                    pid = 0
@@ -1003,6 +1006,7 @@ class Tui(object):
                break
                break


            except ValueError:
            except ValueError:
                msg = '"' + str(pid) + '": Not a valid pid'
                continue
                continue


    def show_stats(self):
    def show_stats(self):