ia64/xen-unstable

changeset 2158:c7f623950d2d

bitkeeper revision 1.1159.14.1 (4118b580s6wv9f_TYlNpiSrvoYj-qQ)

Merge http://xen.bkbits.net:8080/xeno-unstable.bk
into gandalf.hpl.hp.com:/var/bk/xeno-unstable.bk
author xenbk@gandalf.hpl.hp.com
date Tue Aug 10 11:46:08 2004 +0000 (2004-08-10)
parents d000e4ddb729 9fe59cdcbfdd
children fcc4a1183476 ba6f62459745
files tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/XendMigrate.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Tue Aug 10 07:39:01 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Tue Aug 10 11:46:08 2004 +0000
     1.3 @@ -199,7 +199,7 @@ class XendDomain:
     1.4          self.domain_db[info.id] = info.sxpr()
     1.5          self.domain_by_name[info.name] = info
     1.6          self.sync_domain(info.id)
     1.7 -        if notify: eserver.inject('xend.domain.created', info.name)
     1.8 +        if notify: eserver.inject('xend.domain.created', [info.name, info.id])
     1.9  
    1.10      def _delete_domain(self, id, notify=1):
    1.11          """Remove a domain from the tables.
    1.12 @@ -209,7 +209,7 @@ class XendDomain:
    1.13          """
    1.14          if id in self.domain_by_id:
    1.15              info = self.domain_by_id[id]
    1.16 -            if notify: eserver.inject('xend.domain.died', info.name)
    1.17 +            if notify: eserver.inject('xend.domain.died', [info.name, info.id])
    1.18              if info.name in self.domain_by_name:
    1.19                  del self.domain_by_name[info.name]
    1.20              del self.domain_by_id[id]
    1.21 @@ -239,6 +239,9 @@ class XendDomain:
    1.22                  reason = XendDomainInfo.shutdown_reason(d['shutdown_reason'])
    1.23                  log.debug('XendDomain>reap> shutdown id=%s reason=%s', id, reason)
    1.24                  if reason in ['suspend']:
    1.25 +                    dominfo = self.domain_by_id.get(id)
    1.26 +                    name = (dominfo and dominfo.name) or '??'
    1.27 +                    eserver.inject('xend.domain.suspended', [name, id])
    1.28                      continue
    1.29                  if reason in ['poweroff', 'reboot']:
    1.30                      self.domain_restart_schedule(id, reason)
    1.31 @@ -421,7 +424,7 @@ class XendDomain:
    1.32          @param id: domain id
    1.33          """
    1.34          dominfo = self.domain_lookup(id)
    1.35 -        eserver.inject('xend.domain.unpause', dominfo.name)
    1.36 +        eserver.inject('xend.domain.unpause', [dominfo.name, dominfo.id])
    1.37          try:
    1.38              return xc.domain_unpause(dom=dominfo.dom)
    1.39          except Exception, ex:
    1.40 @@ -433,7 +436,7 @@ class XendDomain:
    1.41          @param id: domain id
    1.42          """
    1.43          dominfo = self.domain_lookup(id)
    1.44 -        eserver.inject('xend.domain.pause', dominfo.name)
    1.45 +        eserver.inject('xend.domain.pause', [dominfo.name, dominfo.id])
    1.46          try:
    1.47              return xc.domain_pause(dom=dominfo.dom)
    1.48          except Exception, ex:
    1.49 @@ -455,7 +458,7 @@ class XendDomain:
    1.50              self.domain_restart_cancel(dominfo.id)
    1.51          else:
    1.52              self.domain_restart_schedule(dominfo.id, reason, force=1)
    1.53 -        eserver.inject('xend.domain.shutdown', [dominfo.name, reason])
    1.54 +        eserver.inject('xend.domain.shutdown', [dominfo.name, dominfo.id, reason])
    1.55          if reason == 'halt':
    1.56              reason = 'poweroff'
    1.57          val = xend.domain_shutdown(dominfo.id, reason)
    1.58 @@ -535,7 +538,7 @@ class XendDomain:
    1.59          """
    1.60          dominfo = self.domain_lookup(id)
    1.61          log.info('Destroying domain: name=%s', dominfo.name)
    1.62 -        eserver.inject('xend.domain.destroy', dominfo.name)
    1.63 +        eserver.inject('xend.domain.destroy', [dominfo.name, dominfo.id])
    1.64          if dominfo:
    1.65              val = dominfo.destroy()
    1.66          else:
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Aug 10 07:39:01 2004 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Aug 10 11:46:08 2004 +0000
     2.3 @@ -643,7 +643,11 @@ class XendDomainInfo:
     2.4          """
     2.5          self.release_vifs()
     2.6          self.release_vbds()
     2.7 +        
     2.8          self.devices = {}
     2.9 +        self.device_index = {}
    2.10 +        self.configs = []
    2.11 +        self.ipaddrs = []
    2.12  
    2.13      def release_vifs(self):
    2.14          """Release vm virtual network devices (vifs).
    2.15 @@ -851,7 +855,7 @@ class XendDomainInfo:
    2.16  
    2.17      def restart_check(self):
    2.18          """Check if domain restart is OK.
    2.19 -        To prevent restart loops, raise an error it is
    2.20 +        To prevent restart loops, raise an error if it is
    2.21          less than MINIMUM_RESTART_TIME seconds since the last restart.
    2.22          """
    2.23          tnow = time.time()
     3.1 --- a/tools/python/xen/xend/XendMigrate.py	Tue Aug 10 07:39:01 2004 +0000
     3.2 +++ b/tools/python/xen/xend/XendMigrate.py	Tue Aug 10 11:46:08 2004 +0000
     3.3 @@ -107,6 +107,15 @@ class XfrdInfo:
     3.4              self.deferred.errback(err)
     3.5  
     3.6      def dispatch(self, xfrd, val):
     3.7 +        
     3.8 +        def cbok(v):
     3.9 +            if v is None: return
    3.10 +            sxp.show(v, out=xfrd.transport)
    3.11 +
    3.12 +        def cberr(err):
    3.13 +            v = ['xfr.err', errno.EINVAL]
    3.14 +            sxp.show(v, out=xfrd.transport)
    3.15 +
    3.16          op = sxp.name(val)
    3.17          op = op.replace('.', '_')
    3.18          if op.startswith('xfr_'):
    3.19 @@ -114,8 +123,11 @@ class XfrdInfo:
    3.20          else:
    3.21              fn = self.unknown
    3.22          val = fn(xfrd, val)
    3.23 -        if val is not None:
    3.24 -            sxp.show(val, out=xfrd.transport)
    3.25 +        if isinstance(val, defer.Deferred):
    3.26 +            val.addCallback(cbok)
    3.27 +            val.addErrback(cberr)
    3.28 +        else:
    3.29 +            cbok(val)
    3.30  
    3.31      def unknown(self, xfrd, val):
    3.32          print 'unknown>', val
    3.33 @@ -164,11 +176,40 @@ class XfrdInfo:
    3.34          return ['xfr.err', val]
    3.35  
    3.36      def xfr_vm_suspend(self, xfrd, val):
    3.37 +        """Suspend a domain. Suspending takes time, so we return
    3.38 +        a Deferred that is called when the suspend completes.
    3.39 +        """
    3.40          print 'xfr_vm_suspend>', val
    3.41          try:
    3.42              vmid = sxp.child0(val)
    3.43 +            d = defer.Deferred()
    3.44 +            # Subscribe to 'suspended' events so we can tell when the
    3.45 +            # suspend completes. Subscribe to 'died' events so we can tell if
    3.46 +            # the domain died.
    3.47 +            def onSuspended(e, v):
    3.48 +                print 'onSuspended>', e, v
    3.49 +                if v[1] != vmid: return
    3.50 +                subscribe(on=0)
    3.51 +                d.callback(v)
    3.52 +                
    3.53 +            def onDied(e, v):
    3.54 +                print 'onDied>', e, v
    3.55 +                if v[1] != vmid: return
    3.56 +                subscribe(on=0)
    3.57 +                d.errback(XendError('Domain died'))
    3.58 +                
    3.59 +            def subscribe(on=1):
    3.60 +                if on:
    3.61 +                    action = eserver.subscribe
    3.62 +                else:
    3.63 +                    action = eserver.unsubscribe
    3.64 +                action('xend.domain.suspended', onSuspended)
    3.65 +                action('xend.domain.died', onDied)
    3.66 +
    3.67 +            subscribe()
    3.68              val = self.xd.domain_shutdown(vmid, reason='suspend')
    3.69              self.suspended[vmid] = 1
    3.70 +            return d
    3.71          except:
    3.72              val = errno.EINVAL
    3.73          return ['xfr.err', val]
    3.74 @@ -216,8 +257,6 @@ class XendMigrateInfo(XfrdInfo):
    3.75          if not vmconfig:
    3.76              xfrd.loseConnection()
    3.77              return
    3.78 -        self.xd.domain_pause(self.src_dom)
    3.79 -        self.paused[self.src_dom] = 1
    3.80          xfrd.request(['xfr.migrate',
    3.81                        self.src_dom,
    3.82                        vmconfig,
    3.83 @@ -266,14 +305,11 @@ class XendSaveInfo(XfrdInfo):
    3.84          if not vmconfig:
    3.85              xfrd.loseConnection()
    3.86              return
    3.87 -        self.xd.domain_pause(self.src_dom)
    3.88 -        self.paused[self.src_dom] = 1
    3.89          xfrd.request(['xfr.save', self.src_dom, vmconfig, self.file ])
    3.90          
    3.91      def xfr_save_ok(self, xfrd, val):
    3.92 -        dom = int(sxp.child0(val))
    3.93          self.state = 'ok'
    3.94 -        self.xd_domain_destroy(self.src_dom)
    3.95 +        self.xd.domain_destroy(self.src_dom)
    3.96          if not self.deferred.called:
    3.97              self.deferred.callback(self)
    3.98