ia64/xen-unstable

changeset 2711:8d04913d2ee3

bitkeeper revision 1.1159.129.1 (417910b3OLNctbN0leCgFvn5gSulDQ)

Fix control channel reconnect after xend restart.
author cl349@freefall.cl.cam.ac.uk
date Fri Oct 22 13:52:51 2004 +0000 (2004-10-22)
parents 3897c6ce9024
children 7275617d86ce
files tools/python/xen/xend/XendConsole.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/SrvDaemon.py tools/python/xen/xend/server/channel.py tools/python/xen/xend/server/console.py tools/python/xen/xend/server/controller.py
line diff
     1.1 --- a/tools/python/xen/xend/XendConsole.py	Thu Oct 21 19:31:52 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendConsole.py	Fri Oct 22 13:52:51 2004 +0000
     1.3 @@ -32,8 +32,9 @@ class XendConsole:
     1.4      def consoles(self):
     1.5          return daemon.get_consoles()
     1.6      
     1.7 -    def console_create(self, dom, console_port=None):
     1.8 -        consinfo = daemon.console_create(dom, console_port=console_port)
     1.9 +    def console_create(self, dom, console_port=None, remote_port=0):
    1.10 +        consinfo = daemon.console_create(dom, console_port=console_port,
    1.11 +                                         remote_port=remote_port)
    1.12          return consinfo
    1.13      
    1.14      def console_get(self, id):
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Oct 21 19:31:52 2004 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Oct 22 13:52:51 2004 +0000
     2.3 @@ -733,7 +733,8 @@ class XendDomainInfo:
     2.4          if self.console:
     2.5              self.console.registerChannel()
     2.6          else:
     2.7 -            self.console = xendConsole.console_create(self.dom, console_port=self.console_port)
     2.8 +            self.console = xendConsole.console_create(
     2.9 +                self.dom, console_port=self.console_port, remote_port=1)
    2.10          self.build_domain(ostype, kernel, ramdisk, cmdline)
    2.11          self.image = kernel
    2.12          self.ramdisk = ramdisk
     3.1 --- a/tools/python/xen/xend/server/SrvDaemon.py	Thu Oct 21 19:31:52 2004 +0000
     3.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py	Fri Oct 22 13:52:51 2004 +0000
     3.3 @@ -669,12 +669,13 @@ class Daemon:
     3.4      def netif_get(self, dom):
     3.5          return self.netifCF.getControllerByDom(dom)
     3.6  
     3.7 -    def console_create(self, dom, console_port=None):
     3.8 +    def console_create(self, dom, console_port=None, remote_port=0):
     3.9          """Create a console for a domain.
    3.10          """
    3.11          console = self.consoleCF.getControllerByDom(dom)
    3.12          if console is None:
    3.13 -            console = self.consoleCF.createController(dom, console_port)
    3.14 +            console = self.consoleCF.createController(dom, console_port,
    3.15 +                                                      remote_port=remote_port)
    3.16          return console
    3.17  
    3.18      def consoles(self):
     4.1 --- a/tools/python/xen/xend/server/channel.py	Thu Oct 21 19:31:52 2004 +0000
     4.2 +++ b/tools/python/xen/xend/server/channel.py	Fri Oct 22 13:52:51 2004 +0000
     4.3 @@ -45,7 +45,7 @@ class ChannelFactory:
     4.4              del self.channels[idx]
     4.5              self.notifier.unbind(idx)
     4.6  
     4.7 -    def domChannel(self, dom):
     4.8 +    def domChannel(self, dom, remote_port=0):
     4.9          """Get the channel for the given domain.
    4.10          Construct if necessary.
    4.11  
    4.12 @@ -55,7 +55,7 @@ class ChannelFactory:
    4.13          """
    4.14          chan = self.getDomChannel(dom)
    4.15          if not chan:
    4.16 -            chan = Channel(self, dom)
    4.17 +            chan = Channel(self, dom, remote_port=remote_port)
    4.18              self.addChannel(chan)
    4.19          return chan
    4.20  
    4.21 @@ -91,10 +91,10 @@ class ChannelFactory:
    4.22          """
    4.23          self.delChannel(channel.idx)
    4.24  
    4.25 -    def createPort(self, dom):
    4.26 +    def createPort(self, dom, remote_port=0):
    4.27          """Create a port for a channel to the given domain.
    4.28          """
    4.29 -        return xu.port(dom)
    4.30 +        return xu.port(dom, remote_port)
    4.31  
    4.32  def channelFactory():
    4.33      """Singleton constructor for the channel factory.
    4.34 @@ -200,7 +200,7 @@ class Channel(BaseChannel):
    4.35      are multiplexed over the channel (console, block devs, net devs).
    4.36      """
    4.37  
    4.38 -    def __init__(self, factory, dom):
    4.39 +    def __init__(self, factory, dom, remote_port=0):
    4.40          """Create a channel to the given domain using the given factory.
    4.41  
    4.42          Do not call directly, use domChannel on the factory.
    4.43 @@ -209,7 +209,7 @@ class Channel(BaseChannel):
    4.44          # Domain.
    4.45          self.dom = int(dom)
    4.46          # Domain port (object).
    4.47 -        self.port = self.factory.createPort(dom)
    4.48 +        self.port = self.factory.createPort(dom, remote_port=remote_port)
    4.49          # Channel port (int).
    4.50          self.idx = self.port.local_port
    4.51          # Registered devices.
     5.1 --- a/tools/python/xen/xend/server/console.py	Thu Oct 21 19:31:52 2004 +0000
     5.2 +++ b/tools/python/xen/xend/server/console.py	Fri Oct 22 13:52:51 2004 +0000
     5.3 @@ -81,13 +81,14 @@ class ConsoleControllerFactory(controlle
     5.4      """Factory for creating console controllers.
     5.5      """
     5.6  
     5.7 -    def createController(self, dom, console_port=None):
     5.8 +    def createController(self, dom, console_port=None, remote_port=0):
     5.9          if console_port is None:
    5.10              console_port = CONSOLE_PORT_BASE + dom
    5.11          for c in self.getControllers():
    5.12              if c.console_port == console_port:
    5.13                  raise XendError('console port in use: ' + str(console_port))
    5.14 -        console = ConsoleController(self, dom, console_port)
    5.15 +        console = ConsoleController(self, dom, console_port,
    5.16 +                                    remote_port=remote_port)
    5.17          self.addController(console)
    5.18          log.info("Created console id=%s domain=%d port=%d",
    5.19                   console.idx, console.dom, console.console_port)
    5.20 @@ -111,8 +112,9 @@ class ConsoleController(controller.Contr
    5.21      STATUS_CONNECTED = 'connected'
    5.22      STATUS_LISTENING = 'listening'
    5.23  
    5.24 -    def __init__(self, factory, dom, console_port):
    5.25 -        controller.Controller.__init__(self, factory, dom)
    5.26 +    def __init__(self, factory, dom, console_port, remote_port=0):
    5.27 +        controller.Controller.__init__(self, factory, dom,
    5.28 +                                       remote_port=remote_port)
    5.29          self.addMethod(CMSG_CONSOLE, 0, None)
    5.30          self.status = self.STATUS_NEW
    5.31          self.addr = None
     6.1 --- a/tools/python/xen/xend/server/controller.py	Thu Oct 21 19:31:52 2004 +0000
     6.2 +++ b/tools/python/xen/xend/server/controller.py	Fri Oct 22 13:52:51 2004 +0000
     6.3 @@ -68,7 +68,7 @@ class CtrlMsgRcvr:
     6.4      @type responders: {int:Responder}
     6.5      """
     6.6  
     6.7 -    def __init__(self):
     6.8 +    def __init__(self, remote_port = 0):
     6.9          self.channelFactory = channel.channelFactory()
    6.10          self.majorTypes = {}
    6.11          self.dom = None
    6.12 @@ -76,6 +76,7 @@ class CtrlMsgRcvr:
    6.13          self.idx = None
    6.14          self.responders = {}
    6.15          self.timeout = 10
    6.16 +        self.remote_port = remote_port
    6.17  
    6.18      def setTimeout(self, timeout):
    6.19          self.timeout = timeout
    6.20 @@ -217,7 +218,8 @@ class CtrlMsgRcvr:
    6.21          channel to our domain. Once we have registered, the channel
    6.22          will call requestReceived or responseReceived for our messages.
    6.23          """
    6.24 -        self.channel = self.channelFactory.domChannel(self.dom)
    6.25 +        self.channel = self.channelFactory.domChannel(self.dom,
    6.26 +                                                      self.remote_port)
    6.27          self.idx = self.channel.getIndex()
    6.28          if self.majorTypes:
    6.29              self.channel.registerDevice(self.getMajorTypes(), self)
    6.30 @@ -362,8 +364,8 @@ class Controller(CtrlMsgRcvr):
    6.31      @type idx:     String
    6.32      """
    6.33  
    6.34 -    def __init__(self, factory, dom):
    6.35 -        CtrlMsgRcvr.__init__(self)
    6.36 +    def __init__(self, factory, dom, remote_port=0):
    6.37 +        CtrlMsgRcvr.__init__(self, remote_port=remote_port)
    6.38          self.factory = factory
    6.39          self.dom = int(dom)
    6.40          self.channel = None