[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] Fix xm commands so that the Traceback does not occur



On Wed, Jun 14, 2006 at 11:42:49AM +0900, Masaki Kanno wrote:

Content-Description: Mail message body
> Hi,
> 
> When we tested xm commands, the xm commands occurred the Traceback.
> The following are the examples.
> 
> # xm sched-sedf domUtemp -s xx
> Unexpected error: exceptions.ValueError
> 
> Please report to xen-devel@xxxxxxxxxxxxxxxxxxx
> Traceback (most recent call last):
>   File "/usr/sbin/xm", line 10, in ?
>     main.main(sys.argv)
>   File "//usr/lib/python/xen/xm/main.py", line 1169, in main
>     rc = cmd(args)
>   File "//usr/lib/python/xen/xm/main.py", line 701, in xm_sched_sedf
>     opts['slice'] = ms_to_ns(v)
>   File "//usr/lib/python/xen/xm/main.py", line 665, in ms_to_ns
>     return (float(val) / 0.000001)
> ValueError: invalid literal for float(): xx

> [Snip]

> The cause of the Traceback are entering wrong xm commands.
> We suggest this patch so that the Traceback does not occur.
> 
> Signed-off-by: Hiroyuki Yamamoto <yamamoto.hiroyu@xxxxxxxxxxxxxx>
> Signed-off-by: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
> 
> Best regards,
>  Kan
> 

> diff -r aa2298739112 tools/python/xen/xm/main.py
> --- a/tools/python/xen/xm/main.py     Fri Jun 09 10:40:31 2006 -0600
> +++ b/tools/python/xen/xm/main.py     Mon Jun 12 20:40:13 2006 +0900
> @@ -597,8 +597,16 @@ def xm_vcpu_pin(args):
>      arg_check(args, "vcpu-pin", 3)
>  
>      dom  = args[0]
> -    vcpu = int(args[1])
> -    cpumap = cpu_make_map(args[2])
> +    try:
> +        vcpu = int(args[1])
> +    except (ValueError, OverflowError):
> +        err('Invalid argument: %s' % args[1])
> +        sys.exit(1)
> +    try:
> +        cpumap = cpu_make_map(args[2])
> +    except (ValueError, OverflowError):
> +        err('Invalid argument: %s' % args[2])
> +        sys.exit(1)
>      
>      server.xend.domain.pincpu(dom, vcpu, cpumap)
>  
> [Snip]

It would be a lot nicer if you let the exceptions propagate, and then caught
them in the main exception handler at the bottom of main.py.  It would also be
better if you printed out the usage of the command to tell the user what error
they made.

Thanks,

Ewan.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.