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] Re: [Xen-changelog] The dom destroy path is doing a dom_

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-devel] Re: [Xen-changelog] The dom destroy path is doing a dom_get on a non-existent domain to
From: Mark Williamson <mark.williamson@xxxxxxxxxxxx>
Date: Thu, 15 Sep 2005 18:28:58 +0100
Cc: Dan Smith <danms@xxxxxxxxxx>, Robert Read <robert@xxxxxxxxxxxxx>
Delivery-date: Thu, 15 Sep 2005 17:25:29 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <54A27885-1ACD-45DB-BE00-886677039950@xxxxxxxxxxxxx>
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: <E1EFftK-00037x-UP@xxxxxxxxxxxxxxxxxxxxx> <87wtlji1ea.fsf@xxxxxxxxxx> <54A27885-1ACD-45DB-BE00-886677039950@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: KMail/1.8
> > This is not actually true, right?  There are several places in the
> > code that blindly use the return value of dom_get(), assuming that it
> > is actually anything but None.  The closest example is in the update()
> > function, several lines down:
> >
> >   self.info = info or dom_get(self.domid)
>
> Ah, my bad. I misinterpreted this as a boolean expression at first
> glance.  Note, dom_get was already returning None when the domain
> wasn't found, but another exception was preventing it from getting
> that far. We're just moving the exceptions around, now.

Well really it is a boolean expression but it follows the Perl/Python 
convention of using short-circuit evaluation of booleans for things like 
control flow.  It's fine once you've run into it.  My favourite is the Python 
idiom for the ternary conditional:

a = (b and c) or d)

Which actually means (assuming c isn't false, or equivalent):

a = b ? c : d;

:-D

Cheers,
Mark

> >   self.memory = self.info['mem_kb'] / 1024
> >
> > Clearly, we need to decide what behavior dom_get() is expected to
> > have.  Do we expect it to return None if the domid is not found, or do
> > we expect the domain we're asking about to always be present
> > (i.e. throw an exception if not)?
> >
> > If nobody has strong feelings either way, I'll work up a patch to fix
> > it.
>
> My original fix was to allow dom_get to raise the exception, and I
> just ignored it in delete(), since we are not expecting to find the
> domain in the first place there.  On second thought, this was
> probably a better approach, since the other uses of dom_get would be
> better off if they got exceptions instead of None.
>
> robert
>
> > --
> > Dan Smith
> > IBM Linux Technology Center
> > Open Hypervisor Team
> > email: danms@xxxxxxxxxx
> >
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@xxxxxxxxxxxxxxxxxxx
> > http://lists.xensource.com/xen-devel
>
> --
> Robert Read
> robert@xxxxxxxxxxxxx
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel

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

<Prev in Thread] Current Thread [Next in Thread>