summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStefan Raspl <stefan.raspl@de.ibm.com>2017-12-11 14:25:25 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2017-12-14 11:25:45 +0300
commit08e20a6300e106d5feb89c9e47ea479533fec46f (patch)
tree247c3ecb6bcb21386d5b682e020614dcd485ca07 /tools
parentf3d11b0e8619bbb053d3e13f2271819fb01c1e2a (diff)
downloadlinux-08e20a6300e106d5feb89c9e47ea479533fec46f.tar.xz
tools/kvm_stat: handle invalid regular expressions
Passing an invalid regular expression on the command line results in a traceback. Note that interactive specification of invalid regular expressions is not affected To reproduce, run "kvm_stat -f '*'". Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/kvm/kvm_stat/kvm_stat7
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index 90f0445d7808..29c56f3a05dc 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -1521,6 +1521,13 @@ Press any other key to refresh statistics immediately.
callback=cb_guest_to_pid,
)
(options, _) = optparser.parse_args(sys.argv)
+ try:
+ # verify that we were passed a valid regex up front
+ re.compile(options.fields)
+ except re.error:
+ sys.exit('Error: "' + options.fields + '" is not a valid regular '
+ 'expression')
+
return options