From: Masaki Kanno Subject: [PATCH] [RESEND] Fix xm commands so that the Traceback does not occur Date: Thu, 15 Jun 2006 19:41:39 +0900 Message-ID: References: <20060614143545.GC6955@leeni.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-TuqQQjH5UFSfEga26Tv8T" Return-path: In-Reply-To: <20060614143545.GC6955@leeni.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ewan Mellor Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --Boundary-TuqQQjH5UFSfEga26Tv8T Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Content-Description: Mail message body Hi, We reflected comment to our patch. Our patch has become very small. :-) Signed-off-by: Hiroyuki Yamamoto Signed-off-by: Masaki Kanno Best regards, Kan >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@lists.xensource.com >> 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 >> Signed-off-by: Masaki Kanno >> >> 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. --Boundary-TuqQQjH5UFSfEga26Tv8T Content-Type: application/octet-stream; name="xm.patch" Content-Disposition: attachment; filename="xm.patch" Content-Transfer-Encoding: base64 ZGlmZiAtciBhYTIyOTg3MzkxMTIgdG9vbHMvcHl0aG9uL3hlbi94bS9tYWluLnB5Ci0tLSBh L3Rvb2xzL3B5dGhvbi94ZW4veG0vbWFpbi5weQlGcmkgSnVuIDA5IDEwOjQwOjMxIDIwMDYg LTA2MDAKKysrIGIvdG9vbHMvcHl0aG9uL3hlbi94bS9tYWluLnB5CVRodSBKdW4gMTUgMTk6 MTU6MDIgMjAwNiArMDkwMApAQCAtMTE5Myw2ICsxMTkzLDkgQEAgZGVmIG1haW4oYXJndj1z eXMuYXJndik6CiAgICAgICAgICAgICBlbHNlOgogICAgICAgICAgICAgICAgIHByaW50ICA+ PnN5cy5zdGRlcnIsICJFcnJvcjogJXMiICUgZXguZmF1bHRTdHJpbmcKICAgICAgICAgICAg IHN5cy5leGl0KDEpCisgICAgICAgIGV4Y2VwdCAoVmFsdWVFcnJvciwgT3ZlcmZsb3dFcnJv cik6CisgICAgICAgICAgICBlcnIoIkludmFsaWQgYXJndW1lbnQuIikKKyAgICAgICAgICAg IHVzYWdlKGFyZ3ZbMV0pCiAgICAgICAgIGV4Y2VwdDoKICAgICAgICAgICAgIHByaW50ICJV bmV4cGVjdGVkIGVycm9yOiIsIHN5cy5leGNfaW5mbygpWzBdCiAgICAgICAgICAgICBwcmlu dAo= --Boundary-TuqQQjH5UFSfEga26Tv8T Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-TuqQQjH5UFSfEga26Tv8T--