From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Richardson Subject: xenstore watch for domU shutdown Date: Tue, 9 Jan 2007 18:41:52 -0800 (PST) Message-ID: <94158.18113.qm@web53108.mail.yahoo.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0718325692==" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --===============0718325692== Content-Type: multipart/alternative; boundary="0-1182401766-1168396912=:18113" Content-Transfer-Encoding: 8bit --0-1182401766-1168396912=:18113 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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) --0-1182401766-1168396912=:18113 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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)
--0-1182401766-1168396912=:18113-- --===============0718325692== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============0718325692==--