diff options
author | emellor@ewan <emellor@ewan> | 2005-09-30 11:40:59 +0100 |
---|---|---|
committer | emellor@ewan <emellor@ewan> | 2005-09-30 11:40:59 +0100 |
commit | 1b19d438d2ee5511b40c3e538437596f63d50527 (patch) | |
tree | 7977bd944825f64da920cde5b93797dd3061098c /tools | |
parent | e9a3ddb1b2786eb1c8917f2cd84a6267cf4504f9 (diff) | |
download | xen-1b19d438d2ee5511b40c3e538437596f63d50527.tar.gz xen-1b19d438d2ee5511b40c3e538437596f63d50527.tar.bz2 xen-1b19d438d2ee5511b40c3e538437596f63d50527.zip |
Remove the bizarre arrangement whereby EventChannel inherits from dict. Move
the channel-creation logic into eventChannel, making the EventChannel class
simpler. Remove the closeEventChannel method -- it was simply doing a check
for None, and that isn't enough value to justify the extra method when there
is an EventChannel.close method there too.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/python/xen/xend/XendDomainInfo.py | 4 | ||||
-rw-r--r-- | tools/python/xen/xend/image.py | 3 | ||||
-rwxr-xr-x | tools/python/xen/xend/server/channel.py | 62 |
3 files changed, 27 insertions, 42 deletions
diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 45c0b2be44..6a3757693c 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -32,7 +32,7 @@ import errno import xen.lowlevel.xc from xen.util.blkif import blkdev_uname_to_file -from xen.xend.server.channel import EventChannel +from xen.xend.server import channel from xen.xend import image from xen.xend import scheduler @@ -1032,7 +1032,7 @@ class XendDomainInfo: except: # if anything goes wrong, assume the port was not yet set pass - ret = EventChannel.interdomain(0, self.domid, port1=port, port2=0) + ret = channel.eventChannel(0, self.domid, port1=port, port2=0) self.storeDom(path, ret.port1) return ret diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py index 8f0c1c6a7b..0e71568c1d 100644 --- a/tools/python/xen/xend/image.py +++ b/tools/python/xen/xend/image.py @@ -358,7 +358,8 @@ class VmxImageHandler(ImageHandler): return vncconnect def destroy(self): - channel.eventChannelClose(self.device_channel) + if self.device_channel: + self.device_channel.close() import signal if not self.pid: return diff --git a/tools/python/xen/xend/server/channel.py b/tools/python/xen/xend/server/channel.py index a34e31fbb2..095a14786a 100755 --- a/tools/python/xen/xend/server/channel.py +++ b/tools/python/xen/xend/server/channel.py @@ -13,59 +13,42 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #============================================================================ # Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com> +# Copyright (C) 2005 XenSource Ltd #============================================================================ -import threading -import select - -import xen.lowlevel.xc; xc = xen.lowlevel.xc.new() +import xen.lowlevel.xc from xen.xend.XendLogging import log -DEBUG = 0 -RESPONSE_TIMEOUT = 20.0 +xc = xen.lowlevel.xc.new() + -class EventChannel(dict): +class EventChannel: """An event channel between domains. """ - def interdomain(cls, dom1, dom2, port1=0, port2=0): - """Create an event channel between domains. - - @return EventChannel (None on error) - """ - v = xc.evtchn_bind_interdomain(dom1=dom1, dom2=dom2, - port1=port1, port2=port2) - if v: - v = cls(dom1, dom2, v) - return v - - interdomain = classmethod(interdomain) - - def __init__(self, dom1, dom2, d): - d['dom1'] = dom1 - d['dom2'] = dom2 - self.update(d) + def __init__(self, dom1, dom2, port1, port2): self.dom1 = dom1 self.dom2 = dom2 - self.port1 = d.get('port1') - self.port2 = d.get('port2') + self.port1 = port1 + self.port2 = port2 + def close(self): - """Close the event channel. + """Close the event channel. Nothrow guarantee. """ def evtchn_close(dom, port): try: xc.evtchn_close(dom=dom, port=port) - except Exception, ex: - pass + except Exception: + log.exception("Exception closing event channel %d, %d.", dom, + port) - if DEBUG: - print 'EventChannel>close>', self evtchn_close(self.dom1, self.port1) evtchn_close(self.dom2, self.port2) + def sxpr(self): return ['event-channel', ['dom1', self.dom1 ], @@ -74,19 +57,20 @@ class EventChannel(dict): ['port2', self.port2 ] ] + def __repr__(self): return ("<EventChannel dom1:%d:%d dom2:%d:%d>" % (self.dom1, self.port1, self.dom2, self.port2)) -def eventChannel(dom1, dom2, port1=0, port2=0): + +def eventChannel(dom1, dom2, port1 = 0, port2 = 0): """Create an event channel between domains. @return EventChannel (None on error) """ - return EventChannel.interdomain(dom1, dom2, port1=port1, port2=port2) - -def eventChannelClose(evtchn): - """Close an event channel. - """ - if not evtchn: return - evtchn.close() + v = xc.evtchn_bind_interdomain(dom1=dom1, dom2=dom2, + port1=port1, port2=port2) + if v and v.get('port1'): + return EventChannel(dom1, dom2, v['port1'], v['port2']) + else: + return None |