direct-io.hg

changeset 2511:f7b2e90dac20

bitkeeper revision 1.1159.1.166 (41515bbcO3i2KEUTPMBadmjOSG5Sfw)

Add some restart events and make migrate/save events consistent
with other domain events.
author mjw@wray-m-3.hpl.hp.com
date Wed Sep 22 11:02:20 2004 +0000 (2004-09-22)
parents fbfc2497d55e
children ab0042a6d724 1c1f4aac700c
files tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendMigrate.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Wed Sep 22 10:51:56 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Wed Sep 22 11:02:20 2004 +0000
     1.3 @@ -203,7 +203,7 @@ class XendDomain:
     1.4          if info.name:
     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, info.id])
     1.8 +        if notify: eserver.inject('xend.domain.create', [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 @@ -374,6 +374,8 @@ class XendDomain:
    1.13              self._add_domain(dominfo)
    1.14              return dominfo
    1.15          log.info("Restarting domain: id=%s name=%s", dominfo.id, dominfo.name)
    1.16 +        eserver.inject("xend.domain.restart",
    1.17 +                       [dominfo.name, dominfo.id, "begin"])
    1.18          deferred = dominfo.restart()
    1.19          deferred.addCallback(cbok)
    1.20          return deferred        
    1.21 @@ -502,6 +504,8 @@ class XendDomain:
    1.22          self.restarts_by_name[dominfo.name] = dominfo
    1.23          self.restarts_by_id[dominfo.id] = dominfo
    1.24          log.info('Scheduling restart for domain: name=%s id=%s', dominfo.name, dominfo.id)
    1.25 +        eserver.inject("xend.domain.restart",
    1.26 +                       [dominfo.name, dominfo.id, "schedule"])
    1.27          self.domain_restarts_schedule()
    1.28              
    1.29      def domain_restart_cancel(self, id):
    1.30 @@ -512,6 +516,8 @@ class XendDomain:
    1.31          dominfo = self.restarts_by_id.get(id) or self.restarts_by_name.get(id)
    1.32          if dominfo:
    1.33              log.info('Cancelling restart for domain: name=%s id=%s', dominfo.name, dominfo.id)
    1.34 +            eserver.inject("xend.domain.restart",
    1.35 +                           [dominfo.name, dominfo.id, "cancel"])
    1.36              dominfo.restart_cancel()
    1.37              del self.restarts_by_id[dominfo.id]
    1.38              del self.restarts_by_name[dominfo.name]
    1.39 @@ -530,16 +536,23 @@ class XendDomain:
    1.40              try:
    1.41                  def cbok(dominfo):
    1.42                      log.info('Restarted domain name=%s id=%s', dominfo.name, dominfo.id)
    1.43 +                    eserver.inject("xend.domain.restart",
    1.44 +                                   [dominfo.name, dominfo.id, "success"])
    1.45                      self.domain_unpause(dominfo.id)
    1.46                  def cberr(err):
    1.47                      log.exception("Delayed exception restarting domain: name=%s id=%s",
    1.48                                    dominfo.name, dominfo.id)
    1.49 +                    eserver.inject("xend.domain.restart",
    1.50 +                                   [dominfo.name, dominfo.id, "fail"])
    1.51 +                    
    1.52                  deferred = self.domain_restart(dominfo)
    1.53                  deferred.addCallback(cbok)
    1.54                  deferred.addErrback(cberr)
    1.55              except:
    1.56                  log.exception("Exception restarting domain: name=%s id=%s",
    1.57                                dominfo.name, dominfo.id)
    1.58 +                eserver.inject("xend.domain.restart",
    1.59 +                               [dominfo.name, dominfo.id, "fail"])
    1.60          if self.domain_restarts_exist():
    1.61              # Run again later if any restarts remain.
    1.62              self.refresh_schedule(delay=5)
    1.63 @@ -587,7 +600,7 @@ class XendDomain:
    1.64          # Don't forget to cancel restart for it.
    1.65          dominfo = self.domain_lookup(id)
    1.66          xmigrate = XendMigrate.instance()
    1.67 -        val = xmigrate.migrate_begin(dominfo.id, dst, live=live)
    1.68 +        val = xmigrate.migrate_begin(dominfo, dst, live=live)
    1.69          return val
    1.70  
    1.71      def domain_save(self, id, dst, progress=0):
    1.72 @@ -600,7 +613,7 @@ class XendDomain:
    1.73          """
    1.74          dominfo = self.domain_lookup(id)
    1.75          xmigrate = XendMigrate.instance()
    1.76 -        return xmigrate.save_begin(dominfo.id, dst)
    1.77 +        return xmigrate.save_begin(dominfo, dst)
    1.78      
    1.79      def domain_pincpu(self, id, cpu):
    1.80          """Pin a domain to a cpu.
     2.1 --- a/tools/python/xen/xend/XendMigrate.py	Wed Sep 22 10:51:56 2004 +0000
     2.2 +++ b/tools/python/xen/xend/XendMigrate.py	Wed Sep 22 11:02:20 2004 +0000
     2.3 @@ -260,12 +260,13 @@ class XendMigrateInfo(XfrdInfo):
     2.4      """Representation of a migrate in-progress and its interaction with xfrd.
     2.5      """
     2.6  
     2.7 -    def __init__(self, xid, dom, host, port, live):
     2.8 +    def __init__(self, xid, dominfo, host, port, live):
     2.9          XfrdInfo.__init__(self)
    2.10          self.xid = xid
    2.11 +        self.dominfo = dominfo
    2.12          self.state = 'begin'
    2.13          self.src_host = socket.gethostname()
    2.14 -        self.src_dom = dom
    2.15 +        self.src_dom = dominfo.id
    2.16          self.dst_host = host
    2.17          self.dst_port = port
    2.18          self.dst_dom = None
    2.19 @@ -291,7 +292,9 @@ class XendMigrateInfo(XfrdInfo):
    2.20              xfrd.loseConnection()
    2.21              return
    2.22          log.info('Migrate BEGIN: ' + str(self.sxpr()))
    2.23 -        eserver.inject('xend.migrate.begin', self.sxpr())
    2.24 +        eserver.inject('xend.domain.migrate',
    2.25 +                       [ self.dominfo.name, self.dominfo.id,
    2.26 +                         "begin", self.sxpr() ])
    2.27          xfrd.request(['xfr.migrate',
    2.28                        self.src_dom,
    2.29                        vmconfig,
    2.30 @@ -312,22 +315,24 @@ class XendMigrateInfo(XfrdInfo):
    2.31          XfrdInfo.connectionLost(self, reason)
    2.32          if self.state =='ok':
    2.33              log.info('Migrate OK: ' + str(self.sxpr()))
    2.34 -            eserver.inject('xend.migrate.ok', self.sxpr())
    2.35          else:
    2.36              self.state = 'error'
    2.37              self.error(XendError("migrate failed"))
    2.38              log.info('Migrate ERROR: ' + str(self.sxpr()))
    2.39 -            eserver.inject('xend.migrate.error', self.sxpr())
    2.40 +        eserver.inject('xend.domain.migrate',
    2.41 +                       [ self.dominfo.name, self.dominfo.id,
    2.42 +                         self.state, self.sxpr() ])
    2.43  
    2.44  class XendSaveInfo(XfrdInfo):
    2.45      """Representation of a save in-progress and its interaction with xfrd.
    2.46      """
    2.47      
    2.48 -    def __init__(self, xid, dom, file):
    2.49 +    def __init__(self, xid, dominfo, file):
    2.50          XfrdInfo.__init__(self)
    2.51          self.xid = xid
    2.52 +        self.dominfo = dominfo
    2.53          self.state = 'begin'
    2.54 -        self.src_dom = dom
    2.55 +        self.src_dom = dominfo.id
    2.56          self.file = file
    2.57          self.start = 0
    2.58          
    2.59 @@ -347,7 +352,9 @@ class XendSaveInfo(XfrdInfo):
    2.60              return
    2.61          print '***request> begin'
    2.62          log.info('Save BEGIN: ' + str(self.sxpr()))
    2.63 -        eserver.inject('xend.save.begin', self.sxpr())
    2.64 +        eserver.inject('xend.domain.save',
    2.65 +                       [self.dominfo.name, self.dominfo.id,
    2.66 +                        "begin", self.sxpr()])
    2.67          xfrd.request(['xfr.save', self.src_dom, vmconfig, self.file ])
    2.68          
    2.69      def xfr_save_ok(self, xfrd, val):
    2.70 @@ -361,12 +368,13 @@ class XendSaveInfo(XfrdInfo):
    2.71          XfrdInfo.connectionLost(self, reason)
    2.72          if self.state =='ok':
    2.73              log.info('Save OK: ' + str(self.sxpr()))
    2.74 -            eserver.inject('xend.save.ok', self.sxpr())
    2.75          else:
    2.76              self.state = 'error'
    2.77              self.error(XendError("save failed"))
    2.78              log.info('Save ERROR: ' + str(self.sxpr()))
    2.79 -            eserver.inject('xend.save.error', self.sxpr())
    2.80 +        eserver.inject('xend.domain.save',
    2.81 +                       [ self.dominfo.name, self.dominfo.id,
    2.82 +                         self.state, self.sxpr() ])
    2.83      
    2.84  
    2.85  class XendMigrate:
    2.86 @@ -441,27 +449,27 @@ class XendMigrate:
    2.87          reactor.connectTCP('localhost', XFRD_PORT, xcf)
    2.88          return info.deferred
    2.89      
    2.90 -    def migrate_begin(self, dom, host, port=XFRD_PORT, live=0):
    2.91 +    def migrate_begin(self, dominfo, host, port=XFRD_PORT, live=0):
    2.92          """Begin to migrate a domain to another host.
    2.93  
    2.94 -        @param dom:  domain
    2.95 +        @param dominfo:  domain info
    2.96          @param host: destination host
    2.97          @param port: destination port
    2.98          @return: deferred
    2.99          """
   2.100          xid = self.nextid()
   2.101 -        info = XendMigrateInfo(xid, dom, host, port, live)
   2.102 +        info = XendMigrateInfo(xid, dominfo, host, port, live)
   2.103          return self.session_begin(info)
   2.104  
   2.105 -    def save_begin(self, dom, file):
   2.106 +    def save_begin(self, dominfo, file):
   2.107          """Begin saving a domain to file.
   2.108  
   2.109 -        @param dom:  domain
   2.110 +        @param dominfo:  domain info
   2.111          @param file: destination file
   2.112          @return: deferred
   2.113          """
   2.114          xid = self.nextid()
   2.115 -        info = XendSaveInfo(xid, dom, file)
   2.116 +        info = XendSaveInfo(xid, dominfo, file)
   2.117          return self.session_begin(info)
   2.118  
   2.119  def instance():