direct-io.hg

changeset 4655:bd15906125a7

bitkeeper revision 1.1327.2.8 (426cead1A05puWeKCli1otyMkZ6B9A)

Refresh domain list periodically.
Signed-off-by: Mike Wray <mike.wray@hp.com>
author mjw@wray-m-3.hpl.hp.com
date Mon Apr 25 13:04:17 2005 +0000 (2005-04-25)
parents e81b04e1c86a
children 369e382b2f81
files tools/python/xen/xend/XendDomain.py tools/python/xen/xend/server/SrvDaemon.py tools/python/xen/xend/server/channel.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomain.py	Fri Apr 22 17:07:05 2005 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomain.py	Mon Apr 25 13:04:17 2005 +0000
     1.3 @@ -109,7 +109,7 @@ class XendDomain:
     1.4          """Event handler for virq.
     1.5          """
     1.6          print 'onVirq>', val
     1.7 -        self.reap()
     1.8 +        self.refresh_schedule(delay=0)
     1.9  
    1.10      def schedule_later(self, _delay, _name, _fn, *args):
    1.11          """Schedule a function to be called later (if not already scheduled).
    1.12 @@ -128,18 +128,6 @@ class XendDomain:
    1.13          """
    1.14          self.scheduler.cancel(name)
    1.15  
    1.16 -    def reap_schedule(self, delay=1):
    1.17 -        """Schedule reap to be called later.
    1.18 -
    1.19 -        @param delay: delay in seconds
    1.20 -        """
    1.21 -        self.schedule_later(delay, 'reap', self.reap)
    1.22 -
    1.23 -    def reap_cancel(self):
    1.24 -        """Cancel any scheduled reap.
    1.25 -        """
    1.26 -        self.schedule_cancel('reap')
    1.27 -
    1.28      def refresh_schedule(self, delay=1):
    1.29          """Schedule refresh to be called later.
    1.30          
    1.31 @@ -289,7 +277,6 @@ class XendDomain:
    1.32          """Look for domains that have crashed or stopped.
    1.33          Tidy them up.
    1.34          """
    1.35 -        self.reap_cancel()
    1.36          casualties = []
    1.37          doms = self.xen_domains()
    1.38          for d in doms.values():
    1.39 @@ -311,7 +298,7 @@ class XendDomain:
    1.40              log.debug('XendDomain>reap> domain died name=%s id=%s', name, id)
    1.41              if d['shutdown']:
    1.42                  reason = XendDomainInfo.shutdown_reason(d['shutdown_reason'])
    1.43 -                log.debug('XendDomain>reap> shutdown id=%s reason=%s', id, reason)
    1.44 +                log.debug('XendDomain>reap> shutdown name=%s id=%s reason=%s', name, id, reason)
    1.45                  if reason in ['suspend']:
    1.46                      if dominfo and dominfo.is_terminated():
    1.47                          log.debug('XendDomain>reap> Suspended domain died id=%s', id)
    1.48 @@ -327,21 +314,24 @@ class XendDomain:
    1.49              self.final_domain_destroy(id)
    1.50          if self.domain_restarts_exist():
    1.51              self.domain_restarts_schedule()
    1.52 -        if destroyed:
    1.53 -            self.refresh_schedule(delay=5)
    1.54  
    1.55      def refresh(self):
    1.56          """Refresh domain list from Xen.
    1.57          """
    1.58          self.refresh_cancel()
    1.59 +        self.refresh_schedule(delay=10)
    1.60 +        self.reap()
    1.61          doms = self.xen_domains()
    1.62          # Add entries for any domains we don't know about.
    1.63          for (id, d) in doms.items():
    1.64              if id not in self.domain_by_id:
    1.65 -                log.warning("Created entry for unknown domain: %s", id)
    1.66 +                log.info("Creating entry for unknown domain: id=%s", id)
    1.67                  savedinfo = None
    1.68 -                dominfo = XendDomainInfo.vm_recreate(savedinfo, d)
    1.69 -                self._add_domain(dominfo)
    1.70 +                try:
    1.71 +                    dominfo = XendDomainInfo.vm_recreate(savedinfo, d)
    1.72 +                    self._add_domain(dominfo)
    1.73 +                except Exception, ex:
    1.74 +                    log.exception("Error creating domain info: id=%s", id)
    1.75          # Remove entries for domains that no longer exist.
    1.76          # Update entries for existing domains.
    1.77          for d in self.domain_by_id.values():
    1.78 @@ -352,7 +342,6 @@ class XendDomain:
    1.79                  pass
    1.80              else:
    1.81                  self._delete_domain(d.id)
    1.82 -        self.reap_schedule(delay=1)
    1.83  
    1.84      def update_domain(self, id):
    1.85          """Update the saved info for a domain.
    1.86 @@ -416,7 +405,7 @@ class XendDomain:
    1.87  
    1.88          @param dominfo: domain object
    1.89          """
    1.90 -        log.info("Restarting domain: id=%s name=%s", dominfo.id, dominfo.name)
    1.91 +        log.info("Restarting domain: name=%s id=%s", dominfo.name, dominfo.id)
    1.92          eserver.inject("xend.domain.restart",
    1.93                         [dominfo.name, dominfo.id, "begin"])
    1.94          try:
     2.1 --- a/tools/python/xen/xend/server/SrvDaemon.py	Fri Apr 22 17:07:05 2005 +0000
     2.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py	Mon Apr 25 13:04:17 2005 +0000
     2.3 @@ -41,8 +41,11 @@ class Daemon:
     2.4      """The xend daemon.
     2.5      """
     2.6      def __init__(self):
     2.7 +        self.channelF = None
     2.8          self.shutdown = 0
     2.9          self.traceon = 0
    2.10 +        self.tracefile = None
    2.11 +        self.traceindent = 0
    2.12  
    2.13      def daemon_pids(self):
    2.14          pids = []
    2.15 @@ -352,7 +355,8 @@ class Daemon:
    2.16  
    2.17      def exit(self, rc=0):
    2.18          #reactor.disconnectAll()
    2.19 -        self.channelF.stop()
    2.20 +        if self.channelF:
    2.21 +            self.channelF.stop()
    2.22          # Calling sys.exit() raises a SystemExit exception, which only
    2.23          # kills the current thread. Calling os._exit() makes the whole
    2.24          # Python process exit immediately. There doesn't seem to be another
     3.1 --- a/tools/python/xen/xend/server/channel.py	Fri Apr 22 17:07:05 2005 +0000
     3.2 +++ b/tools/python/xen/xend/server/channel.py	Mon Apr 25 13:04:17 2005 +0000
     3.3 @@ -6,6 +6,8 @@ import select
     3.4  import xen.lowlevel.xc; xc = xen.lowlevel.xc.new()
     3.5  from xen.lowlevel import xu
     3.6  
     3.7 +from xen.xend.XendLogging import log
     3.8 +
     3.9  from messages import *
    3.10  
    3.11  VIRQ_MISDIRECT  = 0  # Catch-all interrupt for unbound VIRQs.
    3.12 @@ -74,6 +76,7 @@ class ChannelFactory:
    3.13      def bind_virq(self, virq):
    3.14          port = self.notifier.bind_virq(virq)
    3.15          self.virqPorts[port] = virq
    3.16 +        log.info("Virq %s on port %s", virq, port)
    3.17  
    3.18      def virq(self):
    3.19          self.notifier.virq_send(self.virqPort)
    3.20 @@ -112,16 +115,21 @@ class ChannelFactory:
    3.21          # Note we use keyword args to lambda to save the values -
    3.22          # otherwise lambda will use the variables, which will get
    3.23          # assigned by the loop and the lambda will get the changed values.
    3.24 +        received = 0
    3.25          for chan in self.channels.values():
    3.26              if self.thread == None: return
    3.27              msg = chan.readResponse()
    3.28              if msg:
    3.29 +                received += 1
    3.30                  chan.responseReceived(msg)
    3.31          for chan in self.channels.values():
    3.32              if self.thread == None: return
    3.33              msg = chan.readRequest()
    3.34              if msg:
    3.35 +                received += 1
    3.36                  self.runInThread(lambda chan=chan, msg=msg: chan.requestReceived(msg))
    3.37 +        if port and received == 0:
    3.38 +            log.warning("Port %s notified, but no messages found", port)
    3.39  
    3.40      def runInThread(self, thunk):
    3.41          thread = threading.Thread(target = thunk)