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] An Introduction to the Xen-API Work

To: Jim Fehlig <jfehlig@xxxxxxxxxx>
Subject: Re: [Xen-devel] An Introduction to the Xen-API Work
From: Stefan Berger <stefanb@xxxxxxxxxx>
Date: Wed, 8 Nov 2006 14:15:35 -0500
Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Ewan Mellor <ewan@xxxxxxxxxxxxx>
Delivery-date: Wed, 08 Nov 2006 11:15:52 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <45521520.40307@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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx

Jim Fehlig <jfehlig@xxxxxxxxxx> wrote on 11/08/2006 12:34:24 PM:

> Stefan Berger wrote:
> >
> > This here solves the problem.
> >
> > diff -r 2408c042a276 tools/python/xen/xend/XendDomain.py
> > --- a/tools/python/xen/xend/XendDomain.py                 Wed Nov  8
> > 11:13:50 2006
> > +++ b/tools/python/xen/xend/XendDomain.py                 Wed Nov  8
> > 09:58:35 2006
> > @@ -472,7 +472,7 @@
> >         self.domains_lock.acquire()
> >         try:
> >             # lookup by name
> > -            match = [dom for dom in self.domains.values() \
> > +            match = [dom for dom in self.managed_domains.values() \
> >                      if dom.getName() == domid]
> >             if match:
> >                 return match[0]
> >
> >  Stefan
>
> Ah, this is essentially the xend patch I was referring to in
> http://lists.xensource.com/archives/html/xen-devel/2006-11/msg00361.html.  
> In domain_lookup_nr, it appears only 'non-inactive' domains are in the
> domains dictionary, so this routine would not find the inactive domain
> that I was attempting to destroy.  I took a slightly different approach
> (patch attached), but given my knowledge of the code was not sure of any
> potential side affects.  Also I wasn't sure why we are building a list
> only to return the first item.  Why not return the item when found?  I
> realize that names are not unique but the current code doesn't handle
> duplicates anyway.
>
> Ewan, can you comment on either of these patches?  This routine needs to
> accommodate inactive domains as well.


Just another comment: For me it solves the problem of restricting domain creation to only allow one domain with a certain name *and* being able to destroy the domain afterwards...

  Stefan

>
> Regards,
> Jim
>
> diff -r 8eb8c0085604 tools/python/xen/xend/XendDomain.py
> --- a/tools/python/xen/xend/XendDomain.py   Mon Nov 06 16:36:51 2006 +0000
> +++ b/tools/python/xen/xend/XendDomain.py   Wed Nov 08 10:32:26 2006 -0700
> @@ -472,10 +472,9 @@ class XendDomain:
>          self.domains_lock.acquire()
>          try:
>              # lookup by name
> -            match = [dom for dom in self.domains.values() \
> -                     if dom.getName() == domid]
> -            if match:
> -                return match[0]
> +            for dom in self.domains.values() + self.managed_domains.values():
> +                if dom.getName() == domid:
> +                    return dom
>  
>              # lookup by id
>              try:
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel