From: Brendan Cully Subject: [RFC] always call external device migration hook during save? Date: Wed, 13 Dec 2006 10:50:09 -0800 Message-ID: <20061213185009.GA8890@ventoux.cs.ubc.ca> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="YZ5djTAD1cGYuMQK" Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Xen Developers List-Id: xen-devel@lists.xenproject.org --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Here's a patch/RFC to always call an external device migration script if one has been declared in xend-config. That is, for all devices and all save modes. I want this because I'd like to create LVM snapshots on xm save. Does this seem like a good way to do that? --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="external-migration-hook.diff" # HG changeset patch # User Brendan Cully # Date 1166035431 28800 # Node ID 706116f403ae69eac179fe0a40a0e94d0cf2ee1e # Parent 02a0d2ca3fe60c98030c5b61f183c10dc8feed36 Activate a declared external device migration script for all devices and all save modes. Signed-off-by: Brendan Cully diff -r 02a0d2ca3fe6 -r 706116f403ae tools/python/xen/xend/server/DevController.py --- a/tools/python/xen/xend/server/DevController.py Tue Dec 12 19:27:56 2006 -0800 +++ b/tools/python/xen/xend/server/DevController.py Wed Dec 13 10:43:51 2006 -0800 @@ -19,12 +19,14 @@ from threading import Event from threading import Event import types -from xen.xend import sxp +from xen.xend import sxp, XendRoot from xen.xend.XendError import VmError from xen.xend.XendLogging import log from xen.xend.xenstore.xstransact import xstransact, complete from xen.xend.xenstore.xswatch import xswatch + +import os DEVICE_CREATE_TIMEOUT = 100 HOTPLUG_STATUS_NODE = "hotplug-status" @@ -47,6 +49,8 @@ xenbusState = { 'Closing' : 5, 'Closed' : 6, } + +xroot = XendRoot.instance() xenbusState.update(dict(zip(xenbusState.values(), xenbusState.keys()))) @@ -313,6 +317,16 @@ class DevController: Make sure that the migration has finished and only then return from the call. """ + tool = xroot.get_external_migration_tool() + if tool: + log.info("Calling external migration tool for step %d" % step) + fd = os.popen("%s -type %s -step %d -host %s -domname %s" % + (tool, self.deviceClass, step, dst, domName)) + for line in fd: + log.info(line.rstrip()) + rc = fd.close() + if rc: + raise VmError('Migration tool returned %d' % (rc >> 8)) return 0 @@ -320,6 +334,16 @@ class DevController: """ Recover from device migration. The given step was the last one that was successfully executed. """ + tool = xroot.get_external_migration_tool() + if tool: + log.info("Calling external migration tool") + fd = os.popen("%s -type %s -step %d -host %s -domname %s -recover" % + (tool, self.deviceClass, step, dst, domName)) + for line in fd: + log.info(line.rstrip()) + rc = fd.close() + if rc: + raise VmError('Migration tool returned %d' % (rc >> 8)) return 0 --YZ5djTAD1cGYuMQK 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 --YZ5djTAD1cGYuMQK--