Skip to content

Commit

Permalink
tools/kvm_stat: print error on invalid regex
Browse files Browse the repository at this point in the history
Entering an invalid regular expression did not produce any indication of an
error so far.
To reproduce, press 'f' and enter 'foo(' (with an unescaped bracket).

Signed-off-by: Stefan Raspl <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
Stefan-Raspl authored and bonzini committed Feb 24, 2018
1 parent 3df33a0 commit 1cd8bfb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/kvm/kvm_stat/kvm_stat
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,7 @@ class Tui(object):
Asks for a valid regex and sets the fields filter accordingly.
"""
msg = ''
while True:
self.screen.erase()
self.screen.addstr(0, 0,
Expand All @@ -1184,6 +1185,7 @@ class Tui(object):
self.screen.addstr(2, 0,
"Current regex: {0}"
.format(self.stats.fields_filter))
self.screen.addstr(5, 0, msg)
self.screen.addstr(3, 0, "New regex: ")
curses.echo()
regex = self.screen.getstr().decode(ENCODING)
Expand All @@ -1198,6 +1200,7 @@ class Tui(object):
self.refresh_header()
return
except re.error:
msg = '"' + regex + '": Not a valid regular expression'
continue

def show_vm_selection_by_pid(self):
Expand Down

0 comments on commit 1cd8bfb

Please sign in to comment.