From: Ewan Mellor Subject: Re: [PATCH] xm,xend: flesh out xm sched-sedf Date: Fri, 10 Mar 2006 00:39:37 +0000 Message-ID: <20060310003937.GE16724@leeni.uk.xensource.com> References: <20060307234243.GH15536@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20060307234243.GH15536@us.ibm.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: Ryan Harper Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On Tue, Mar 07, 2006 at 05:42:43PM -0600, Ryan Harper wrote: > This patch > > -Displays[1] current parameters for running domains ala xm list > -Allow users to set[2] one or more parameters[3] without having to > provide values for parameters they do not wish to change > -Adds additional testing of sched-sedf via new xm-test testcases. > > With this patch applied, test 02_sedf_period_lower_neg.py exposes a > bug[4]. I'll follow up this email with a patch for the bug. Applied, complete with FIXME. > FIXME: this can probably go away if someone points me to the proper way. > + def domid_match(domid, info): > + d = "" > + f = "" > + try: > + d = int(domid) > + f = 'dom' > + except: > + d = domid > + f = 'name' > + > + return (d == info[f]) You can probably just go with def domid_match(domid, info): return domid == info['name'] || domid == str(info['dom']) and then, because I prefer to use None when I really mean 'value unspecified', and because I'd want to roll the test for 'unspecified' into domid_match, I'd do def domid_match(domid, info): return domid is None || domid == info['name'] || domid == str(info['dom']) and change the domid = -1 to domid = None, which then means that > + if domid == '-1' or domid_match(domid, d): loses the first test. Neater, IMHO, mainly because now we've got the one test, we can use filter and get rid of the for loop and the if statement altogether: doms = filter(lambda x : domid_match(domid, x), [parse_doms_info(dom) for dom in getDomains("")]) (It's a real shame that Guido's eschewed a decent partial-application syntax, because Python's list comprehensions are really nice, but some extra syntax for partial applications would make this example much nicer.) I'll let you try this; if you like it, send a patch back. Cheers, Ewan.