[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Improve error reporting for save/restore/migrate.
ChangeSet 1.1159.267.2, 2005/03/11 17:01:00+00:00, mjw@xxxxxxxxxxxxxxxxxxx Improve error reporting for save/restore/migrate. Signed-off-by: Mike Wray <mike.wray@xxxxxx> XendMigrate.py | 158 +++++++++++++++++++++++++++++----------------------- server/SrvDomain.py | 17 ----- 2 files changed, 91 insertions(+), 84 deletions(-) diff -Nru a/tools/python/xen/xend/XendMigrate.py b/tools/python/xen/xend/XendMigrate.py --- a/tools/python/xen/xend/XendMigrate.py 2005-03-25 07:03:06 -05:00 +++ b/tools/python/xen/xend/XendMigrate.py 2005-03-25 07:03:06 -05:00 @@ -6,12 +6,14 @@ import sys import socket import time +import types from twisted.internet import reactor from twisted.internet import defer #defer.Deferred.debug = 1 from twisted.internet.protocol import Protocol from twisted.internet.protocol import ClientFactory +from twisted.python.failure import Failure import sxp import XendDB @@ -45,11 +47,9 @@ sxp.show(req, out=self.transport) def loseConnection(self): - print 'Xfrd>loseConnection>' self.transport.loseConnection() def connectionLost(self, reason): - print 'Xfrd>connectionLost>', reason self.xinfo.connectionLost(reason) def dataReceived(self, data): @@ -70,17 +70,15 @@ self.xinfo = xinfo def startedConnecting(self, connector): - print 'Started to connect', 'self=', self, 'connector=', connector + pass def buildProtocol(self, addr): - print 'buildProtocol>', addr return Xfrd(self.xinfo) def clientConnectionLost(self, connector, reason): - print 'clientConnectionLost>', 'connector=', connector, 'reason=', reason + pass def clientConnectionFailed(self, connector, reason): - print 'clientConnectionFailed>', 'connector=', connector, 'reason=', reason self.xinfo.error(reason) class XfrdInfo: @@ -90,7 +88,7 @@ """Suspend timeout (seconds). We set a timeout because suspending a domain can hang.""" - timeout = 30 + timeout = 10 def __init__(self): from xen.xend import XendDomain @@ -98,6 +96,9 @@ self.deferred = defer.Deferred() self.suspended = {} self.paused = {} + self.state = 'init' + # List of errors encountered. + self.errors = [] def vmconfig(self): dominfo = self.xd.domain_get(self.src_dom) @@ -107,12 +108,38 @@ val = None return val + def add_error(self, err): + """Add an error to the error list. + Returns the error added (which may have been unwrapped if it + was a Twisted Failure). + """ + while isinstance(err, Failure): + err = err.value + if err not in self.errors: + self.errors.append(err) + return err + + def error_summary(self, msg=None): + """Get a XendError summarising the errors (if any). + """ + if msg is None: + msg = "errors" + if self.errors: + errmsg = msg + ': ' + ', '.join(map(str, self.errors)) + else: + errmsg = msg + return XendError(errmsg) + + def get_errors(self): + """Get the list of errors. + """ + return self.errors + def error(self, err): - print 'Error>', err self.state = 'error' + self.add_error(err) if not self.deferred.called: - print 'Error> calling errback' - self.deferred.errback(err) + self.deferred.errback(self.error_summary()) def dispatch(self, xfrd, val): @@ -139,28 +166,23 @@ cbok(val) def unknown(self, xfrd, val): - print 'unknown>', val xfrd.loseConnection() return None def xfr_err(self, xfrd, val): # If we get an error with non-zero code the operation failed. # An error with code zero indicates hello success. - print 'xfr_err>', val v = sxp.child0(val) - print 'xfr_err>', type(v), v err = int(sxp.child0(val)) if not err: return - self.error(err); + self.error("transfer daemon (xfrd) error: " + str(err)) xfrd.loseConnection() return None def xfr_progress(self, xfrd, val): - print 'xfr_progress>', val return None def xfr_vm_destroy(self, xfrd, val): - print 'xfr_vm_destroy>', val try: vmid = sxp.child0(val) val = self.xd.domain_destroy(vmid) @@ -168,28 +190,32 @@ del self.paused[vmid] if vmid in self.suspended: del self.suspended[vmid] - except: + except StandardError, err: + self.add_error("vm_destroy failed") + self.add_error(err) val = errno.EINVAL return ['xfr.err', val] def xfr_vm_pause(self, xfrd, val): - print 'xfr_vm_pause>', val try: vmid = sxp.child0(val) val = self.xd.domain_pause(vmid) self.paused[vmid] = 1 - except: + except StandardError, err: + self.add_error("vm_pause failed") + self.add_error(err) val = errno.EINVAL return ['xfr.err', val] def xfr_vm_unpause(self, xfrd, val): - print 'xfr_vm_unpause>', val try: vmid = sxp.child0(val) val = self.xd.domain_unpause(vmid) if vmid in self.paused: del self.paused[vmid] - except: + except StandardError, err: + self.add_error("vm_unpause failed") + self.add_error(err) val = errno.EINVAL return ['xfr.err', val] @@ -199,7 +225,6 @@ Suspending can hang, so we set a timeout and fail if it takes too long. """ - print 'xfr_vm_suspend>', val try: vmid = sxp.child0(val) d = defer.Deferred() @@ -208,15 +233,15 @@ # the domain died. Set a timeout and error handler so the subscriptions # will be cleaned up if suspending hangs or there is an error. def onSuspended(e, v): - print 'xfr_vm_suspend>onSuspended>', e, v if v[1] != vmid: return subscribe(on=0) - d.callback(v) + if not d.called: + d.callback(v) def onDied(e, v): - print 'xfr_vm_suspend>onDied>', e, v if v[1] != vmid: return - d.errback(XendError('Domain died')) + if not d.called: + d.errback(XendError('Domain %s died while suspending' % vmid)) def subscribe(on=1): if on: @@ -227,24 +252,25 @@ action('xend.domain.died', onDied) def cberr(err): - print 'xfr_vm_suspend>cberr>', err subscribe(on=0) + self.add_error("suspend failed") + self.add_error(err) return err + d.addErrback(cberr) + d.setTimeout(self.timeout) subscribe() val = self.xd.domain_shutdown(vmid, reason='suspend') self.suspended[vmid] = 1 - d.addErrback(cberr) - d.setTimeout(self.timeout) return d except Exception, err: - print 'xfr_vm_suspend> Exception', err + self.add_error("suspend failed") + self.add_error(err) traceback.print_exc() val = errno.EINVAL return ['xfr.err', val] def connectionLost(self, reason=None): - print 'XfrdInfo>connectionLost>', reason for vmid in self.suspended: try: self.xd.domain_destroy(vmid) @@ -279,7 +305,7 @@ ['id', self.xid ], ['state', self.state ], ['live', self.live ], - ['resource', self.resource] ] + ['resource', self.resource ] ] sxpr_src = ['src', ['host', self.src_host], ['domain', self.src_dom] ] sxpr.append(sxpr_src) sxpr_dst = ['dst', ['host', self.dst_host] ] @@ -291,12 +317,12 @@ def request(self, xfrd): vmconfig = self.vmconfig() ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |