mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
bitkeeper revision 1.1327.2.8 (426cead1A05puWeKCli1otyMkZ6B9A)
Refresh domain list periodically. Signed-off-by: Mike Wray <mike.wray@hp.com>
This commit is contained in:
1 parent
4ef819374f
commit
890ea518d9
3 files changed
+24
-23
No files matched your search
@@ -109,7 +109,7 @@ class XendDomain:
|
||||
"""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 @@ class XendDomain:
|
||||
"""
|
||||
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 @@ class XendDomain:
|
||||
"""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 @@ class XendDomain:
|
||||
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 @@ class XendDomain:
|
||||
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 @@ class XendDomain:
|
||||
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 @@ class XendDomain:
|
||||
|
||||
@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:
|
||||
|
||||
@@ -41,8 +41,11 @@ class Daemon:
|
||||
"""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 @@ class Daemon:
|
||||
|
||||
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
|
||||
|
||||
@@ -6,6 +6,8 @@ import select
|
||||
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 @@ class ChannelFactory:
|
||||
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 @@ class ChannelFactory:
|
||||
# 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)
|
||||
|
||||