All of lore.kernel.org
 help / color / mirror / Atom feed
* xenstore watch for domU shutdown
@ 2007-01-10  2:41 David Richardson
  2007-01-10 11:26 ` Ewan Mellor
  0 siblings, 1 reply; 2+ messages in thread
From: David Richardson @ 2007-01-10  2:41 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 1015 bytes --]

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? 
 
 My code is attached below.  As is, if fails to call the registered watch function on a domain shutdown.  Any help or suggestions would be greatly appreciated.  Thanks!
 
 ~Dave
 
 #####################BEGIN CODE##############################
 
 from xen.xend.xenstore.xsutil import *
 from xen.xend.xenstore.xswatch import *
 from sys import argv
 from xen.xend.xenstore.xstransact import xstransact
 
 #domid of the domU guest
 domid = int(argv[1])
 
 xs = xshandle()
 path = xs.get_domain_path(domid)
 
 def myHandleShutdownWatch(_):
     f = open("/scratch/TEST", "w")
     f.write("Shutdown called")
     f.close()
     return True
 
 mywatch = xswatch(path+"/control/shutdown",myHandleShutdownWatch)
 

[-- Attachment #1.2: Type: text/html, Size: 1187 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: xenstore watch for domU shutdown
  2007-01-10  2:41 xenstore watch for domU shutdown David Richardson
@ 2007-01-10 11:26 ` Ewan Mellor
  0 siblings, 0 replies; 2+ messages in thread
From: Ewan Mellor @ 2007-01-10 11:26 UTC (permalink / raw)
  To: David Richardson; +Cc: xen-devel

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-01-10 11:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-10  2:41 xenstore watch for domU shutdown David Richardson
2007-01-10 11:26 ` Ewan Mellor

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.