From: Ewan Mellor Subject: Re: xenstore watch for domU shutdown Date: Wed, 10 Jan 2007 11:26:54 +0000 Message-ID: <20070110112654.GA8858@leeni.uk.xensource.com> References: <94158.18113.qm@web53108.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <94158.18113.qm@web53108.mail.yahoo.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: David Richardson Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On Tue, Jan 09, 2007 at 06:41:52PM -0800, David Richardson wrote: > Hey everyone, > > I'm trying to write a simple python program in dom0 that registers a watch > on the xenstore to determine when a domU has shutdown. Is there a > particular token I should use? Looking through the tools/python/xen/*.py > code, I've come across the 'control/shutdown' token... seems promising? control/shutdown is an instruction from the tools to the domU that it should shut down. What it doesn't tell you is when a domain has gone away, because if it shuts down of its own accord or crashes, of course there won't be anything here. The store will fire @releaseDomain whenever a domain goes away -- you then need to read from Xen to find out if its the one that you're interested in. Read through XendDomainInfo.refreshShutdown; the watch itself is registered in XendDomain. If you're using Xend it's a little bit complicated, because Xend is going to clean up the domain under your feet, reboot it, and so on, so if you're using Xend, the easiest way would be either to modify Xend, and add a hook for what you want, or to watch @releaseDomain, read from Xen to see what has shut down, and if Xend has already cleaned up after the domain then read xend/last_shutdown_reason to find out what happened. (last_shutdown_reason appeared in very recent xen-unstable.) Ewan.