direct-io.hg

changeset 1652:b4bc38d3acd4

bitkeeper revision 1.1041.1.6 (40e3e568dXMUca5bKVlAd9SLsmVpEw)

Release the channel and port when a domain is destroyed.
Allows the domain to finally go away.
author mjw@wray-m-3.hpl.hp.com
date Thu Jul 01 10:20:24 2004 +0000 (2004-07-01)
parents bb0cd2c046b0
children aa6d5eac6275 90b354900bbf
files tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/SrvDaemon.py tools/python/xen/xend/server/channel.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Jul 01 07:41:58 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Jul 01 10:20:24 2004 +0000
     1.3 @@ -504,6 +504,9 @@ class XendDomainInfo:
     1.4          devices have been released.
     1.5          """
     1.6          if self.dom is None: return 0
     1.7 +        chan = xend.getDomChannel(self.dom)
     1.8 +        if chan:
     1.9 +            chan.close()
    1.10          return xc.domain_destroy(dom=self.dom)
    1.11  
    1.12      def cleanup(self):
     2.1 --- a/tools/python/xen/xend/server/SrvDaemon.py	Thu Jul 01 07:41:58 2004 +0000
     2.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py	Thu Jul 01 10:20:24 2004 +0000
     2.3 @@ -663,6 +663,15 @@ class Daemon:
     2.4          reactor.diconnectAll()
     2.5          sys.exit(0)
     2.6  
     2.7 +    def getDomChannel(self, dom):
     2.8 +        """Get the channel to a domain.
     2.9 +
    2.10 +        dom domain
    2.11 +
    2.12 +        returns channel (or None)
    2.13 +        """
    2.14 +        return self.channelF.getDomChannel(dom)
    2.15 +
    2.16      def blkif_set_control_domain(self, dom, recreate=0):
    2.17          """Set the block device backend control domain.
    2.18          """
     3.1 --- a/tools/python/xen/xend/server/channel.py	Thu Jul 01 07:41:58 2004 +0000
     3.2 +++ b/tools/python/xen/xend/server/channel.py	Thu Jul 01 10:20:24 2004 +0000
     3.3 @@ -48,15 +48,31 @@ class ChannelFactory:
     3.4      def domChannel(self, dom):
     3.5          """Get the channel for the given domain.
     3.6          Construct if necessary.
     3.7 +
     3.8 +        dom domain
     3.9 +
    3.10 +        returns channel
    3.11 +        """
    3.12 +        chan = self.getDomChannel(dom)
    3.13 +        if not chan:
    3.14 +            chan = Channel(self, dom)
    3.15 +            self.addChannel(chan)
    3.16 +        return chan
    3.17 +
    3.18 +    def getDomChannel(self, dom):
    3.19 +        """Get the channel for the given domain.
    3.20 +
    3.21 +        dom domain
    3.22 +
    3.23 +        returns channel (or None)
    3.24          """
    3.25          dom = int(dom)
    3.26          for chan in self.channels.values():
    3.27              if not isinstance(chan, Channel): continue
    3.28              if chan.dom == dom:
    3.29                  return chan
    3.30 -        chan = Channel(self, dom)
    3.31 -        self.addChannel(chan)
    3.32 -        return chan
    3.33 +        return None
    3.34 +        
    3.35  
    3.36      def virqChannel(self, virq):
    3.37          """Get the channel for the given virq.
    3.38 @@ -109,12 +125,11 @@ class BaseChannel:
    3.39  
    3.40      def notificationReceived(self):
    3.41          """Called when a notification is received.
    3.42 -        Closes the channel on error, otherwise calls
    3.43 -        handleNotification(type), which should be defined
    3.44 +        Calls handleNotification(), which should be defined
    3.45          in a subclass.
    3.46          """
    3.47 -        if not self.closed:
    3.48 -            self.handleNotification(type)
    3.49 +        if self.closed: return
    3.50 +        self.handleNotification()
    3.51  
    3.52      def close(self):
    3.53          """Close the channel. Calls channelClosed() on the factory.
    3.54 @@ -122,7 +137,7 @@ class BaseChannel:
    3.55          """
    3.56          self.factory.channelClosed(self)
    3.57  
    3.58 -    def handleNotification(self, type):
    3.59 +    def handleNotification(self):
    3.60          """Handle notification.
    3.61          Define in subclass.
    3.62          """
    3.63 @@ -172,7 +187,7 @@ class VirqChannel(BaseChannel):
    3.64          """
    3.65          self.clients.append(client)
    3.66  
    3.67 -    def handleNotification(self, type):
    3.68 +    def handleNotification(self):
    3.69          for c in self.clients:
    3.70              c.virqReceived(self.virq)
    3.71  
    3.72 @@ -221,13 +236,14 @@ class Channel(BaseChannel):
    3.73          """Close the channel. Calls lostChannel() on all its devices and
    3.74          channelClosed() on the factory.
    3.75          """
    3.76 +        if self.closed: return
    3.77          self.closed = 1
    3.78          for d in self.devs:
    3.79              d.lostChannel()
    3.80          self.factory.channelClosed(self)
    3.81          self.devs = []
    3.82          self.devs_by_type = {}
    3.83 -        del self.port
    3.84 +        self.port.disconnect()
    3.85  
    3.86      def registerDevice(self, types, dev):
    3.87          """Register a device controller.
    3.88 @@ -271,7 +287,10 @@ class Channel(BaseChannel):
    3.89                     self.getLocalPort(),
    3.90                     self.getRemotePort()))
    3.91  
    3.92 -    def handleNotification(self, type):
    3.93 +    def handleNotification(self):
    3.94 +        if self.closed:
    3.95 +            print 'handleNotification> Notification on closed channel', self
    3.96 +            return
    3.97          work = 0
    3.98          work += self.handleRequests()
    3.99          work += self.handleResponses()