ia64/xen-unstable

changeset 2134:9c32df6c75a7

bitkeeper revision 1.1159.6.3 (41176e6a6b2iBgpt5G6vdnKJ6_grmw)

Fix error when save terminates.
author mjw@wray-m-3.hpl.hp.com
date Mon Aug 09 12:30:34 2004 +0000 (2004-08-09)
parents 0219fa720732
children 05bd2a6ec4b2
files tools/python/xen/xend/XendMigrate.py
line diff
     1.1 --- a/tools/python/xen/xend/XendMigrate.py	Mon Aug 09 12:25:34 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendMigrate.py	Mon Aug 09 12:30:34 2004 +0000
     1.3 @@ -41,9 +41,11 @@ class Xfrd(Protocol):
     1.4          sxp.show(req, out=self.transport)
     1.5  
     1.6      def loseConnection(self):
     1.7 +        print 'Xfrd>loseConnection>'
     1.8          self.transport.loseConnection()
     1.9  
    1.10      def connectionLost(self, reason):
    1.11 +        print 'Xfrd>connectionLost>', reason
    1.12          self.xinfo.connectionLost(reason)
    1.13  
    1.14      def dataReceived(self, data):
    1.15 @@ -85,6 +87,8 @@ class XfrdInfo:
    1.16          from xen.xend import XendDomain
    1.17          self.xd = XendDomain.instance()
    1.18          self.deferred = defer.Deferred()
    1.19 +        self.suspended = {}
    1.20 +        self.paused = {}
    1.21          
    1.22      def vmconfig(self):
    1.23          print 'vmconfig>'
    1.24 @@ -143,6 +147,7 @@ class XfrdInfo:
    1.25          try:
    1.26              vmid = sxp.child0(val)
    1.27              val = self.xd.domain_pause(vmid)
    1.28 +            self.paused[vmid] = 1
    1.29          except:
    1.30              val = errno.EINVAL
    1.31          return ['xfr.err', val]
    1.32 @@ -152,6 +157,8 @@ class XfrdInfo:
    1.33          try:
    1.34              vmid = sxp.child0(val)
    1.35              val = self.xd.domain_unpause(vmid)
    1.36 +            if vmid in self.paused:
    1.37 +                del self.paused[vmid]
    1.38          except:
    1.39              val = errno.EINVAL
    1.40          return ['xfr.err', val]
    1.41 @@ -161,10 +168,24 @@ class XfrdInfo:
    1.42          try:
    1.43              vmid = sxp.child0(val)
    1.44              val = self.xd.domain_shutdown(vmid, reason='suspend')
    1.45 +            self.suspended[vmid] = 1
    1.46          except:
    1.47              val = errno.EINVAL
    1.48          return ['xfr.err', val]
    1.49  
    1.50 +    def connectionLost(self, reason=None):
    1.51 +        print 'XfrdInfo>connectionLost>', reason
    1.52 +        for vmid in self.suspended:
    1.53 +            try:
    1.54 +                self.xd.domain_destroy(vmid)
    1.55 +            except:
    1.56 +                pass
    1.57 +        for vmid in self.paused:
    1.58 +            try:
    1.59 +                self.xd.domain_unpause(vmid)
    1.60 +            except:
    1.61 +                pass
    1.62 +
    1.63  class XendMigrateInfo(XfrdInfo):
    1.64      """Representation of a migrate in-progress and its interaction with xfrd.
    1.65      """
    1.66 @@ -195,21 +216,25 @@ class XendMigrateInfo(XfrdInfo):
    1.67          if not vmconfig:
    1.68              xfrd.loseConnection()
    1.69              return
    1.70 +        self.xd.domain_pause(self.src_dom)
    1.71 +        self.paused[self.src_dom] = 1
    1.72          xfrd.request(['xfr.migrate',
    1.73                        self.src_dom,
    1.74                        vmconfig,
    1.75                        self.dst_host,
    1.76                        self.dst_port])
    1.77          
    1.78 -    def xfr_migrate_ok(self, val):
    1.79 +    def xfr_migrate_ok(self, xfrd, val):
    1.80          dom = int(sxp.child0(val))
    1.81          self.state = 'ok'
    1.82          self.dst_dom = dom
    1.83 -        self.xd_domain_destroy(self.src_dom)
    1.84 +        self.xd.domain_destroy(self.src_dom)
    1.85          if not self.deferred.called:
    1.86              self.deferred.callback(self)
    1.87  
    1.88      def connectionLost(self, reason=None):
    1.89 +        print 'XfrdMigrateInfo>connectionLost>', reason
    1.90 +        XfrdInfo.connectionLost(self, reason)
    1.91          if self.state =='ok':
    1.92              eserver.inject('xend.migrate.ok', self.sxpr())
    1.93          else:
    1.94 @@ -241,9 +266,11 @@ class XendSaveInfo(XfrdInfo):
    1.95          if not vmconfig:
    1.96              xfrd.loseConnection()
    1.97              return
    1.98 +        self.xd.domain_pause(self.src_dom)
    1.99 +        self.paused[self.src_dom] = 1
   1.100          xfrd.request(['xfr.save', self.src_dom, vmconfig, self.file ])
   1.101          
   1.102 -    def xfr_save_ok(self, val):
   1.103 +    def xfr_save_ok(self, xfrd, val):
   1.104          dom = int(sxp.child0(val))
   1.105          self.state = 'ok'
   1.106          self.xd_domain_destroy(self.src_dom)
   1.107 @@ -251,6 +278,8 @@ class XendSaveInfo(XfrdInfo):
   1.108              self.deferred.callback(self)
   1.109  
   1.110      def connectionLost(self, reason=None):
   1.111 +        print 'XfrdSaveInfo>connectionLost>', reason
   1.112 +        XfrdInfo.connectionLost(self, reason)
   1.113          if self.state =='ok':
   1.114              eserver.inject('xend.save.ok', self.sxpr())
   1.115          else: