mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
bitkeeper revision 1.1159.269.4 (4236cdc9eib4ejH25MkiyfkGp022dQ)
Add channel function to close an event channel and
call when devices are destroyed.
Signed-off-by: Mike Wray <mike.wray@hp.com>
This commit is contained in:
1 parent
8d90977141
commit
421b18073a
3 files changed
+29
-1
No files matched your search
@@ -181,6 +181,8 @@ class BlkifBackendInterface(controller.BackendInterface):
|
||||
self.close()
|
||||
d = defer.Deferred()
|
||||
d.addCallback(cb_destroy)
|
||||
if self.evtchn:
|
||||
channel.eventChannelClose(self.evtchn)
|
||||
self.send_be_disconnect(response=d)
|
||||
|
||||
def send_be_disconnect(self, response=None):
|
||||
|
||||
@@ -11,7 +11,31 @@ VIRQ_CONSOLE = 3 # (DOM0) bytes received on emergency console.
|
||||
VIRQ_DOM_EXC = 4 # (DOM0) Exceptional event for some domain.
|
||||
|
||||
def eventChannel(dom1, dom2):
|
||||
return xc.evtchn_bind_interdomain(dom1=dom1, dom2=dom2)
|
||||
"""Create an event channel between domains.
|
||||
The returned dict contains dom1, dom2, port1 and port2 on success.
|
||||
|
||||
@return dict (empty on error)
|
||||
"""
|
||||
evtchn = xc.evtchn_bind_interdomain(dom1=dom1, dom2=dom2)
|
||||
if evtchn:
|
||||
evtchn['dom1'] = dom1
|
||||
evtchn['dom2'] = dom2
|
||||
return evtchn
|
||||
|
||||
def eventChannelClose(evtchn):
|
||||
"""Close an event channel that was opened by eventChannel().
|
||||
"""
|
||||
def evtchn_close(dom, port):
|
||||
if (dom is None) or (port is None): return
|
||||
try:
|
||||
xc.evtchn_close(dom=dom, port=port)
|
||||
except Exception, ex:
|
||||
pass
|
||||
|
||||
if not evtchn: return
|
||||
evtchn_close(evtchn.get('dom1'), evtchn.get('port1'))
|
||||
evtchn_close(evtchn.get('dom2'), evtchn.get('port2'))
|
||||
|
||||
|
||||
class ChannelFactory:
|
||||
"""Factory for creating channels.
|
||||
|
||||
@@ -288,6 +288,8 @@ class NetDev(controller.SplitDev):
|
||||
if change:
|
||||
self.reportStatus()
|
||||
log.debug("Destroying vif domain=%d vif=%d", self.controller.dom, self.vif)
|
||||
if self.evtchn:
|
||||
channel.eventChannelClose(self.evtchn)
|
||||
self.vifctl('down')
|
||||
d = self.send_be_disconnect()
|
||||
d.addCallback(cb_destroy)
|
||||
|
||||