ia64/xen-unstable

changeset 13012:903f80054bca

[XEND] Activate a declared external device migration script for all devices and all save modes.
Signed-off-by: Brendan Cully <brendan@cs.ubc.ca>
author kfraser@localhost.localdomain
date Thu Dec 14 10:00:56 2006 +0000 (2006-12-14)
parents 360eb996fa38
children 997f2bbb5cbc
files tools/python/xen/xend/server/DevController.py
line diff
     1.1 --- a/tools/python/xen/xend/server/DevController.py	Wed Dec 13 16:13:26 2006 +0000
     1.2 +++ b/tools/python/xen/xend/server/DevController.py	Thu Dec 14 10:00:56 2006 +0000
     1.3 @@ -19,13 +19,15 @@
     1.4  from threading import Event
     1.5  import types
     1.6  
     1.7 -from xen.xend import sxp
     1.8 +from xen.xend import sxp, XendRoot
     1.9  from xen.xend.XendError import VmError
    1.10  from xen.xend.XendLogging import log
    1.11  
    1.12  from xen.xend.xenstore.xstransact import xstransact, complete
    1.13  from xen.xend.xenstore.xswatch import xswatch
    1.14  
    1.15 +import os
    1.16 +
    1.17  DEVICE_CREATE_TIMEOUT = 100
    1.18  HOTPLUG_STATUS_NODE = "hotplug-status"
    1.19  HOTPLUG_ERROR_NODE  = "hotplug-error"
    1.20 @@ -48,6 +50,8 @@ xenbusState = {
    1.21      'Closed'       : 6,
    1.22      }
    1.23  
    1.24 +xroot = XendRoot.instance()
    1.25 +
    1.26  xenbusState.update(dict(zip(xenbusState.values(), xenbusState.keys())))
    1.27  
    1.28  
    1.29 @@ -313,6 +317,16 @@ class DevController:
    1.30                        Make sure that the migration has finished and only
    1.31                        then return from the call.
    1.32          """
    1.33 +        tool = xroot.get_external_migration_tool()
    1.34 +        if tool:
    1.35 +            log.info("Calling external migration tool for step %d" % step)
    1.36 +            fd = os.popen("%s -type %s -step %d -host %s -domname %s" %
    1.37 +                          (tool, self.deviceClass, step, dst, domName))
    1.38 +            for line in fd:
    1.39 +                log.info(line.rstrip())
    1.40 +            rc = fd.close()
    1.41 +            if rc:
    1.42 +                raise VmError('Migration tool returned %d' % (rc >> 8))
    1.43          return 0
    1.44  
    1.45  
    1.46 @@ -320,6 +334,16 @@ class DevController:
    1.47          """ Recover from device migration. The given step was the
    1.48              last one that was successfully executed.
    1.49          """
    1.50 +        tool = xroot.get_external_migration_tool()
    1.51 +        if tool:
    1.52 +            log.info("Calling external migration tool")
    1.53 +            fd = os.popen("%s -type %s -step %d -host %s -domname %s -recover" %
    1.54 +                          (tool, self.deviceClass, step, dst, domName))
    1.55 +            for line in fd:
    1.56 +                log.info(line.rstrip())
    1.57 +            rc = fd.close()
    1.58 +            if rc:
    1.59 +                raise VmError('Migration tool returned %d' % (rc >> 8))
    1.60          return 0
    1.61  
    1.62