[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Refresh domain list periodically.



ChangeSet 1.1327.2.8, 2005/04/25 14:04:17+01:00, mjw@xxxxxxxxxxxxxxxxxxx

        Refresh domain list periodically.
        Signed-off-by: Mike Wray <mike.wray@xxxxxx>



 XendDomain.py       |   33 +++++++++++----------------------
 server/SrvDaemon.py |    6 +++++-
 server/channel.py   |    8 ++++++++
 3 files changed, 24 insertions(+), 23 deletions(-)


diff -Nru a/tools/python/xen/xend/XendDomain.py 
b/tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       2005-05-13 16:04:15 -04:00
+++ b/tools/python/xen/xend/XendDomain.py       2005-05-13 16:04:15 -04:00
@@ -109,7 +109,7 @@
         """Event handler for virq.
         """
         print 'onVirq>', val
-        self.reap()
+        self.refresh_schedule(delay=0)
 
     def schedule_later(self, _delay, _name, _fn, *args):
         """Schedule a function to be called later (if not already scheduled).
@@ -128,18 +128,6 @@
         """
         self.scheduler.cancel(name)
 
-    def reap_schedule(self, delay=1):
-        """Schedule reap to be called later.
-
-        @param delay: delay in seconds
-        """
-        self.schedule_later(delay, 'reap', self.reap)
-
-    def reap_cancel(self):
-        """Cancel any scheduled reap.
-        """
-        self.schedule_cancel('reap')
-
     def refresh_schedule(self, delay=1):
         """Schedule refresh to be called later.
         
@@ -289,7 +277,6 @@
         """Look for domains that have crashed or stopped.
         Tidy them up.
         """
-        self.reap_cancel()
         casualties = []
         doms = self.xen_domains()
         for d in doms.values():
@@ -311,7 +298,7 @@
             log.debug('XendDomain>reap> domain died name=%s id=%s', name, id)
             if d['shutdown']:
                 reason = XendDomainInfo.shutdown_reason(d['shutdown_reason'])
-                log.debug('XendDomain>reap> shutdown id=%s reason=%s', id, 
reason)
+                log.debug('XendDomain>reap> shutdown name=%s id=%s reason=%s', 
name, id, reason)
                 if reason in ['suspend']:
                     if dominfo and dominfo.is_terminated():
                         log.debug('XendDomain>reap> Suspended domain died 
id=%s', id)
@@ -327,21 +314,24 @@
             self.final_domain_destroy(id)
         if self.domain_restarts_exist():
             self.domain_restarts_schedule()
-        if destroyed:
-            self.refresh_schedule(delay=5)
 
     def refresh(self):
         """Refresh domain list from Xen.
         """
         self.refresh_cancel()
+        self.refresh_schedule(delay=10)
+        self.reap()
         doms = self.xen_domains()
         # Add entries for any domains we don't know about.
         for (id, d) in doms.items():
             if id not in self.domain_by_id:
-                log.warning("Created entry for unknown domain: %s", id)
+                log.info("Creating entry for unknown domain: id=%s", id)
                 savedinfo = None
-                dominfo = XendDomainInfo.vm_recreate(savedinfo, d)
-                self._add_domain(dominfo)
+                try:
+                    dominfo = XendDomainInfo.vm_recreate(savedinfo, d)
+                    self._add_domain(dominfo)
+                except Exception, ex:
+                    log.exception("Error creating domain info: id=%s", id)
         # Remove entries for domains that no longer exist.
         # Update entries for existing domains.
         for d in self.domain_by_id.values():
@@ -352,7 +342,6 @@
                 pass
             else:
                 self._delete_domain(d.id)
-        self.reap_schedule(delay=1)
 
     def update_domain(self, id):
         """Update the saved info for a domain.
@@ -416,7 +405,7 @@
 
         @param dominfo: domain object
         """
-        log.info("Restarting domain: id=%s name=%s", dominfo.id, dominfo.name)
+        log.info("Restarting domain: name=%s id=%s", dominfo.name, dominfo.id)
         eserver.inject("xend.domain.restart",
                        [dominfo.name, dominfo.id, "begin"])
         try:
diff -Nru a/tools/python/xen/xend/server/SrvDaemon.py 
b/tools/python/xen/xend/server/SrvDaemon.py
--- a/tools/python/xen/xend/server/SrvDaemon.py 2005-05-13 16:04:15 -04:00
+++ b/tools/python/xen/xend/server/SrvDaemon.py 2005-05-13 16:04:15 -04:00
@@ -41,8 +41,11 @@
     """The xend daemon.
     """
     def __init__(self):
+        self.channelF = None
         self.shutdown = 0
         self.traceon = 0
+        self.tracefile = None
+        self.traceindent = 0
 
     def daemon_pids(self):
         pids = []
@@ -352,7 +355,8 @@
 
     def exit(self, rc=0):
         #reactor.disconnectAll()
-        self.channelF.stop()
+        if self.channelF:
+            self.channelF.stop()
         # Calling sys.exit() raises a SystemExit exception, which only
         # kills the current thread. Calling os._exit() makes the whole
         # Python process exit immediately. There doesn't seem to be another
diff -Nru a/tools/python/xen/xend/server/channel.py 
b/tools/python/xen/xend/server/channel.py
--- a/tools/python/xen/xend/server/channel.py   2005-05-13 16:04:15 -04:00
+++ b/tools/python/xen/xend/server/channel.py   2005-05-13 16:04:15 -04:00
@@ -6,6 +6,8 @@
 import xen.lowlevel.xc; xc = xen.lowlevel.xc.new()
 from xen.lowlevel import xu
 
+from xen.xend.XendLogging import log
+
 from messages import *
 
 VIRQ_MISDIRECT  = 0  # Catch-all interrupt for unbound VIRQs.
@@ -74,6 +76,7 @@
     def bind_virq(self, virq):
         port = self.notifier.bind_virq(virq)
         self.virqPorts[port] = virq
+        log.info("Virq %s on port %s", virq, port)
 
     def virq(self):
         self.notifier.virq_send(self.virqPort)
@@ -112,16 +115,21 @@
         # Note we use keyword args to lambda to save the values -
         # otherwise lambda will use the variables, which will get
         # assigned by the loop and the lambda will get the changed values.
+        received = 0
         for chan in self.channels.values():
             if self.thread == None: return
             msg = chan.readResponse()
             if msg:
+                received += 1
                 chan.responseReceived(msg)
         for chan in self.channels.values():
             if self.thread == None: return
             msg = chan.readRequest()
             if msg:
+                received += 1
                 self.runInThread(lambda chan=chan, msg=msg: 
chan.requestReceived(msg))
+        if port and received == 0:
+            log.warning("Port %s notified, but no messages found", port)
 
     def runInThread(self, thunk):
         thread = threading.Thread(target = thunk)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.