diff options
author | Stefan Raspl <stefan.raspl@de.ibm.com> | 2017-12-11 12:25:25 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2017-12-14 09:25:45 +0100 |
commit | 08e20a6300e106d5feb89c9e47ea479533fec46f (patch) | |
tree | 247c3ecb6bcb21386d5b682e020614dcd485ca07 /tools/kvm | |
parent | f3d11b0e8619bbb053d3e13f2271819fb01c1e2a (diff) | |
download | linux-riscv-08e20a6300e106d5feb89c9e47ea479533fec46f.tar.gz linux-riscv-08e20a6300e106d5feb89c9e47ea479533fec46f.tar.bz2 linux-riscv-08e20a6300e106d5feb89c9e47ea479533fec46f.zip |
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/kvm')
-rwxr-xr-x | tools/kvm/kvm_stat/kvm_stat | 7 |
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 |