diff tools/python/xen/xm/ @ 11572:ad22c711ccb7

[XM] Error handling cleanup

Introducing an OptionError exception to be used by all xm subcommands
to signal an error in the arguments. "xm" will catch these and output
the appropriate error and usage message.

Detailed Changes:
* Cleaned up imports and moved warning filter outside of
import block.
* Converted usage parameters and description to a python
dict rather than strings to enable better usage help
* Removed unused list_label domain command.
* Added cmdHelp() prints out usage message for any command
* Added shortHelp() prints out the default help message when
xm is invoked with no arguments.
* Added longHelp() prints out long help message when invoked
with xm --help or xm help.
* Added extra optional paramter to getDomains() so we can
tell Xend not to poll devices. This will speed up xm list.
(PENDING changes to Xend itself.)
* Changed all references where 'dom' actually means 'domid'
to use the correct name.
* Changed 'xm list' header format to use printf formatting style.
* Renamed xm_subcommand to xm_importcommand so it is more
clear what it is doing (all xm commands are subcommands!)
* Moved cpu_make_map() inside xm_vcpu_pin as an anonymous func.
* Use OptionError whenever an invalid option is detected in xm.
* Added proper catch and error printing for XendError and
OptionErrors in main().
* Replaced usage() with help() that is called from
* Replaced usage() invokation with raising OptionError
* Added very simple wrap() function that behaves differently
to textwrap.wrap()
* Added OptionError()
* Replaced the string representation of Opt, Opts to output
a nicely formatted usage message.
* Changed class Opts itself will throw approriate OptionErrors.
* Changed set_bool to recognise 'y' and 'n' as valid input
* Some whitespace and column width cleanup.
* throws OptionError if encounters option error.
* Replace usage() message with the string representation of
* Replace usage message with throwing OptionErrors

Signed-off-by: Alastair Tse <>
date Fri Sep 22 11:37:31 2006 +0100 (2006-09-22)
parents 713328270fb3
line diff
     1.1 --- a/tools/python/xen/xm/	Fri Sep 22 11:33:03 2006 +0100
     1.2 +++ b/tools/python/xen/xm/	Fri Sep 22 11:37:31 2006 +0100
     1.3 @@ -18,9 +18,7 @@
     1.5  XENCONSOLE = "xenconsole"
     1.7 -
     1.8  import xen.util.auxbin
    1.10 -
    1.11  def execConsole(domid):
    1.12      xen.util.auxbin.execute(XENCONSOLE, [str(domid)])