提交 08e20a63 编写于 作者: S Stefan Raspl 提交者: Paolo Bonzini

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: NStefan Raspl <raspl@linux.vnet.ibm.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 f3d11b0e
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册