WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] xm,xend: flesh out xm sched-sedf

To: Ryan Harper <ryanh@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] xm,xend: flesh out xm sched-sedf
From: Ewan Mellor <ewan@xxxxxxxxxxxxx>
Date: Fri, 10 Mar 2006 00:39:37 +0000
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Fri, 10 Mar 2006 00:40:25 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20060307234243.GH15536@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20060307234243.GH15536@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.9i
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.

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