[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Add channel function to close an event channel and



ChangeSet 1.1159.267.4, 2005/03/15 11:58:01+00:00, mjw@xxxxxxxxxxxxxxxxxxx

         Add channel function to close an event channel and
         call when devices are destroyed.
            
         Signed-off-by: Mike Wray <mike.wray@xxxxxx>



 blkif.py   |    2 ++
 channel.py |   26 +++++++++++++++++++++++++-
 netif.py   |    2 ++
 3 files changed, 29 insertions(+), 1 deletion(-)


diff -Nru a/tools/python/xen/xend/server/blkif.py 
b/tools/python/xen/xend/server/blkif.py
--- a/tools/python/xen/xend/server/blkif.py     2005-03-25 07:03:14 -05:00
+++ b/tools/python/xen/xend/server/blkif.py     2005-03-25 07:03:14 -05:00
@@ -181,6 +181,8 @@
             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):
diff -Nru a/tools/python/xen/xend/server/channel.py 
b/tools/python/xen/xend/server/channel.py
--- a/tools/python/xen/xend/server/channel.py   2005-03-25 07:03:14 -05:00
+++ b/tools/python/xen/xend/server/channel.py   2005-03-25 07:03:14 -05:00
@@ -11,7 +11,31 @@
 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.
diff -Nru a/tools/python/xen/xend/server/netif.py 
b/tools/python/xen/xend/server/netif.py
--- a/tools/python/xen/xend/server/netif.py     2005-03-25 07:03:14 -05:00
+++ b/tools/python/xen/xend/server/netif.py     2005-03-25 07:03:14 -05:00
@@ -288,6 +288,8 @@
             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)


-------------------------------------------------------
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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.