diff options
author | Stefan Raspl <stefan.raspl@de.ibm.com> | 2017-12-11 06:25:26 -0500 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2017-12-14 03:25:46 -0500 |
commit | 822cfe3e4813c8f52199362b0e689fba9459ddc9 (patch) | |
tree | df755bd5baf19f41c256a6ffb817c8531fbef559 | |
parent | 08e20a6300e106d5feb89c9e47ea479533fec46f (diff) |
tools/kvm_stat: suppress usage information on command line errors
Errors while parsing the '-g' command line argument result in display of
usage information prior to the error message. This is a bit confusing,
as the command line is syntactically correct.
To reproduce, run 'kvm_stat -g' and specify a non-existing or inactive
guest.
Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rwxr-xr-x | tools/kvm/kvm_stat/kvm_stat | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat index 29c56f3a05dc..bf65531570f5 100755 --- a/tools/kvm/kvm_stat/kvm_stat +++ b/tools/kvm/kvm_stat/kvm_stat | |||
@@ -1453,16 +1453,13 @@ Press any other key to refresh statistics immediately. | |||
1453 | try: | 1453 | try: |
1454 | pids = Tui.get_pid_from_gname(val) | 1454 | pids = Tui.get_pid_from_gname(val) |
1455 | except: | 1455 | except: |
1456 | raise optparse.OptionValueError('Error while searching for guest ' | 1456 | sys.exit('Error while searching for guest "{}". Use "-p" to ' |
1457 | '"{}", use "-p" to specify a pid ' | 1457 | 'specify a pid instead?'.format(val)) |
1458 | 'instead'.format(val)) | ||
1459 | if len(pids) == 0: | 1458 | if len(pids) == 0: |
1460 | raise optparse.OptionValueError('No guest by the name "{}" ' | 1459 | sys.exit('Error: No guest by the name "{}" found'.format(val)) |
1461 | 'found'.format(val)) | ||
1462 | if len(pids) > 1: | 1460 | if len(pids) > 1: |
1463 | raise optparse.OptionValueError('Multiple processes found (pids: ' | 1461 | sys.exit('Error: Multiple processes found (pids: {}). Use "-p" ' |
1464 | '{}) - use "-p" to specify a pid ' | 1462 | 'to specify the desired pid'.format(" ".join(pids))) |
1465 | 'instead'.format(" ".join(pids))) | ||
1466 | parser.values.pid = pids[0] | 1463 | parser.values.pid = pids[0] |
1467 | 1464 | ||
1468 | optparser = optparse.OptionParser(description=description_text, | 1465 | optparser = optparse.OptionParser(description=description_text, |