From: Dan Smith Subject: Re: [PATCH] fix error handler index in xm Date: Wed, 24 Aug 2005 10:07:22 -0700 Message-ID: References: <3d8eece205082408487c9e6812@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Christian.Limpach@cl.cam.ac.uk Cc: "List: Xen Developers" List-Id: xen-devel@lists.xenproject.org --=-=-= CL> I've reverted this check-in because with the change applied, the CL> error messages are incorrect: Ok, so the problem is rooted in the way the args list is manipulated in the subcommand handlers. As it stands now (without the patch), some commands give a good error message, while others dump a stack trace if the domain doesn't exist: # xm destroy foo Error: Domain 'foo' not found when running 'xm destroy' # xm domid foo 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 671, in main handle_xend_error(argv[1], args[1], ex) IndexError: list index out of range This is because destroy adds "bogus" into the args list at index 0, but domid does not. I've attached a new patch that checks for this condition, and removes the "bogus" entry from the list if the subcommand added it. This makes the call to handle_xend_error() work in both situations: # xm destroy foo Error: Domain 'foo' not found when running 'xm destroy' # xm domid foo Error: Domain 'foo' not found when running 'xm domid' Is that an acceptable solution for now? Perhaps a cleanup of the inconsistent subcommand handler behavior is in order. I can do that when I start work on the remaining interface changes. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=xm_new.patch diff -r b74c15e4dd4f tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Wed Aug 24 16:15:42 2005 +++ b/tools/python/xen/xm/main.py Wed Aug 24 09:36:32 2005 @@ -665,8 +665,10 @@ err("Most commands need root access. Please try again as root") sys.exit(1) except XendError, ex: + if args[0] == "bogus": + args.remove("bogus") if len(args) > 0: - handle_xend_error(argv[1], args[1], ex) + handle_xend_error(argv[1], args[0], ex) else: print "Unexpected error:", sys.exc_info()[0] print --=-=-= -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com --=-=-= 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 --=-=-=--