diff options
author | Stefan Raspl <stefan.raspl@de.ibm.com> | 2017-12-11 06:25:25 -0500 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2017-12-14 03:25:45 -0500 |
commit | 08e20a6300e106d5feb89c9e47ea479533fec46f (patch) | |
tree | 247c3ecb6bcb21386d5b682e020614dcd485ca07 /tools | |
parent | f3d11b0e8619bbb053d3e13f2271819fb01c1e2a (diff) |
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-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. | |||
1521 | callback=cb_guest_to_pid, | 1521 | callback=cb_guest_to_pid, |
1522 | ) | 1522 | ) |
1523 | (options, _) = optparser.parse_args(sys.argv) | 1523 | (options, _) = optparser.parse_args(sys.argv) |
1524 | try: | ||
1525 | # verify that we were passed a valid regex up front | ||
1526 | re.compile(options.fields) | ||
1527 | except re.error: | ||
1528 | sys.exit('Error: "' + options.fields + '" is not a valid regular ' | ||
1529 | 'expression') | ||
1530 | |||
1524 | return options | 1531 | return options |
1525 | 1532 | ||
1526 | 1533 | ||