ia64/xen-unstable

changeset 4151:c07e188e4cea

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>
author mjw@wray-m-3.hpl.hp.com
date Tue Mar 15 11:58:01 2005 +0000 (2005-03-15)
parents 1e38b5603716
children b097821b390f
files tools/python/xen/xend/server/blkif.py tools/python/xen/xend/server/channel.py tools/python/xen/xend/server/netif.py
line diff
     1.1 --- a/tools/python/xen/xend/server/blkif.py	Tue Mar 15 11:52:56 2005 +0000
     1.2 +++ b/tools/python/xen/xend/server/blkif.py	Tue Mar 15 11:58:01 2005 +0000
     1.3 @@ -181,6 +181,8 @@ class BlkifBackendInterface(controller.B
     1.4              self.close()
     1.5          d = defer.Deferred()
     1.6          d.addCallback(cb_destroy)
     1.7 +        if self.evtchn:
     1.8 +            channel.eventChannelClose(self.evtchn)
     1.9          self.send_be_disconnect(response=d)
    1.10          
    1.11      def send_be_disconnect(self, response=None):
     2.1 --- a/tools/python/xen/xend/server/channel.py	Tue Mar 15 11:52:56 2005 +0000
     2.2 +++ b/tools/python/xen/xend/server/channel.py	Tue Mar 15 11:58:01 2005 +0000
     2.3 @@ -11,7 +11,31 @@ VIRQ_CONSOLE    = 3  # (DOM0) bytes rece
     2.4  VIRQ_DOM_EXC    = 4  # (DOM0) Exceptional event for some domain.
     2.5  
     2.6  def eventChannel(dom1, dom2):
     2.7 -    return xc.evtchn_bind_interdomain(dom1=dom1, dom2=dom2)
     2.8 +    """Create an event channel between domains.
     2.9 +    The returned dict contains dom1, dom2, port1 and port2 on success.
    2.10 +
    2.11 +    @return dict (empty on error)
    2.12 +    """
    2.13 +    evtchn = xc.evtchn_bind_interdomain(dom1=dom1, dom2=dom2)
    2.14 +    if evtchn:
    2.15 +        evtchn['dom1'] = dom1
    2.16 +        evtchn['dom2'] = dom2
    2.17 +    return evtchn
    2.18 +
    2.19 +def eventChannelClose(evtchn):
    2.20 +    """Close an event channel that was opened by eventChannel().
    2.21 +    """
    2.22 +    def evtchn_close(dom, port):
    2.23 +        if (dom is None) or (port is None): return
    2.24 +        try:
    2.25 +            xc.evtchn_close(dom=dom, port=port)
    2.26 +        except Exception, ex:
    2.27 +            pass
    2.28 +        
    2.29 +    if not evtchn: return
    2.30 +    evtchn_close(evtchn.get('dom1'), evtchn.get('port1'))
    2.31 +    evtchn_close(evtchn.get('dom2'), evtchn.get('port2'))
    2.32 +    
    2.33  
    2.34  class ChannelFactory:
    2.35      """Factory for creating channels.
     3.1 --- a/tools/python/xen/xend/server/netif.py	Tue Mar 15 11:52:56 2005 +0000
     3.2 +++ b/tools/python/xen/xend/server/netif.py	Tue Mar 15 11:58:01 2005 +0000
     3.3 @@ -288,6 +288,8 @@ class NetDev(controller.SplitDev):
     3.4              if change:
     3.5                  self.reportStatus()
     3.6          log.debug("Destroying vif domain=%d vif=%d", self.controller.dom, self.vif)
     3.7 +        if self.evtchn:
     3.8 +            channel.eventChannelClose(self.evtchn)
     3.9          self.vifctl('down')
    3.10          d = self.send_be_disconnect()
    3.11          d.addCallback(cb_destroy)