direct-io.hg

changeset 1786:9c6eeedea833

bitkeeper revision 1.1081.1.2 (40f55de2NRzSVtT27hdCdG3fbdnqGg)

Allow console port for a domain to be specified.
author mjw@wray-m-3.hpl.hp.com
date Wed Jul 14 16:22:58 2004 +0000 (2004-07-14)
parents 9a1d945b5038
children 61599b006364
files tools/python/xen/xend/XendConsole.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/console.py tools/python/xen/xm/create.py
line diff
     1.1 --- a/tools/python/xen/xend/XendConsole.py	Wed Jul 14 15:36:10 2004 +0000
     1.2 +++ b/tools/python/xen/xend/XendConsole.py	Wed Jul 14 16:22:58 2004 +0000
     1.3 @@ -154,8 +154,8 @@ class XendConsole:
     1.4          self.refresh()
     1.5          return self.console.values()
     1.6      
     1.7 -    def console_create(self, dom):
     1.8 -        consinfo = daemon.console_create(dom)
     1.9 +    def console_create(self, dom, console_port=None):
    1.10 +        consinfo = daemon.console_create(dom, console_port=console_port)
    1.11          info = self._new_console(consinfo)
    1.12          return info
    1.13      
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Jul 14 15:36:10 2004 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed Jul 14 16:22:58 2004 +0000
     2.3 @@ -349,6 +349,7 @@ class XendDomainInfo:
     2.4          self.migrate = None
     2.5          #Whether to auto-restart
     2.6          self.restart_mode = RESTART_ONREBOOT
     2.7 +        self.console_port = None
     2.8  
     2.9      def setdom(self, dom):
    2.10          self.dom = int(dom)
    2.11 @@ -403,7 +404,12 @@ class XendDomainInfo:
    2.12          self.config = config
    2.13          try:
    2.14              self.name = sxp.child_value(config, 'name')
    2.15 -            self.memory = int(sxp.child_value(config, 'memory', '128'))
    2.16 +            if self.name is None:
    2.17 +                raise VmError('missing domain name')
    2.18 +            self.memory = int(sxp.child_value(config, 'memory'))
    2.19 +            if self.memory is None:
    2.20 +                raise VmError('missing memory size')
    2.21 +            self.configure_console()
    2.22              self.configure_restart()
    2.23              self.configure_backends()
    2.24              image = sxp.child_value(config, 'image')
    2.25 @@ -617,7 +623,7 @@ class XendDomainInfo:
    2.26              if ramdisk and not os.path.isfile(ramdisk):
    2.27                  raise VmError('Kernel ramdisk does not exist: %s' % ramdisk)
    2.28          self.init_domain()
    2.29 -        self.console = xendConsole.console_create(self.dom)
    2.30 +        self.console = xendConsole.console_create(self.dom, console_port=self.console_port)
    2.31          self.build_domain(ostype, kernel, ramdisk, cmdline, vifs_n)
    2.32          self.image = kernel
    2.33          self.ramdisk = ramdisk
    2.34 @@ -680,6 +686,15 @@ class XendDomainInfo:
    2.35              self.config.remove(['device', dev_config])
    2.36          dev.destroy()
    2.37  
    2.38 +    def configure_console(self):
    2.39 +        x = sxp.child_value(self.config, 'console')
    2.40 +        if x:
    2.41 +            try:
    2.42 +                port = int(x)
    2.43 +            except:
    2.44 +                raise VmError('invalid console:' + str(x))
    2.45 +            self.console_port = port
    2.46 +
    2.47      def configure_restart(self):
    2.48          r = sxp.child_value(self.config, 'restart', RESTART_ONREBOOT)
    2.49          if r not in restart_modes:
     3.1 --- a/tools/python/xen/xend/server/console.py	Wed Jul 14 15:36:10 2004 +0000
     3.2 +++ b/tools/python/xen/xend/server/console.py	Wed Jul 14 16:22:58 2004 +0000
     3.3 @@ -6,6 +6,7 @@ from twisted.protocols import telnet
     3.4  
     3.5  from xen.lowlevel import xu
     3.6  
     3.7 +from xen.xend.XendError import XendError
     3.8  from xen.xend import EventServer
     3.9  eserver = EventServer.instance()
    3.10  
    3.11 @@ -77,6 +78,9 @@ class ConsoleControllerFactory(controlle
    3.12      def createInstance(self, dom, console_port=None):
    3.13          if console_port is None:
    3.14              console_port = CONSOLE_PORT_BASE + dom
    3.15 +        for c in self.getInstances():
    3.16 +            if c.console_port == console_port:
    3.17 +                raise XendError('console port in use: ' + str(console_port))
    3.18          console = ConsoleController(self, dom, console_port)
    3.19          self.addInstance(console)
    3.20          eserver.inject('xend.console.create',
     4.1 --- a/tools/python/xen/xm/create.py	Wed Jul 14 15:36:10 2004 +0000
     4.2 +++ b/tools/python/xen/xm/create.py	Wed Jul 14 16:22:58 2004 +0000
     4.3 @@ -68,38 +68,42 @@ gopts.opt('load', short='L', val='FILE',
     4.4            use='Domain saved state to load.')
     4.5  
     4.6  gopts.opt('dryrun', short='n',
     4.7 -         fn=set_true, default=0,
     4.8 -         use="""Dry run - print the config but don't create the domain.
     4.9 +          fn=set_true, default=0,
    4.10 +          use="""Dry run - print the config but don't create the domain.
    4.11  The defaults file is loaded and the SXP configuration is created and printed.         
    4.12  """)
    4.13  
    4.14  gopts.opt('console_autoconnect', short='c',
    4.15 -         fn=set_true, default=0,
    4.16 -         use="Connect to console after domain is created.")
    4.17 +          fn=set_true, default=0,
    4.18 +          use="Connect to console after domain is created.")
    4.19  
    4.20  gopts.var('name', val='NAME',
    4.21            fn=set_value, default=None,
    4.22            use="Domain name.")
    4.23  
    4.24  gopts.var('kernel', val='FILE',
    4.25 -         fn=set_value, default=None,
    4.26 -         use="Path to kernel image.")
    4.27 +          fn=set_value, default=None,
    4.28 +          use="Path to kernel image.")
    4.29  
    4.30  gopts.var('ramdisk', val='FILE',
    4.31 -         fn=set_value, default='',
    4.32 -         use="Path to ramdisk.")
    4.33 +          fn=set_value, default='',
    4.34 +          use="Path to ramdisk.")
    4.35  
    4.36  gopts.var('builder', val='FUNCTION',
    4.37 -         fn=set_value, default='linux',
    4.38 -         use="Function to use to build the domain.")
    4.39 +          fn=set_value, default='linux',
    4.40 +          use="Function to use to build the domain.")
    4.41  
    4.42  gopts.var('memory', val='MEMORY',
    4.43 -         fn=set_value, default=128,
    4.44 -         use="Domain memory in MB.")
    4.45 +          fn=set_value, default=128,
    4.46 +          use="Domain memory in MB.")
    4.47 +
    4.48 +gopts.var('console', val='PORT',
    4.49 +          fn=set_int, default=None,
    4.50 +          use="Console port to use. Default is 9600 + domain id.")
    4.51  
    4.52  gopts.var('restart', val='onreboot|always|never',
    4.53 -         fn=set_value, default=None,
    4.54 -         use="""Whether the domain should be restarted on exit.
    4.55 +          fn=set_value, default=None,
    4.56 +          use="""Whether the domain should be restarted on exit.
    4.57           - onreboot: restart on exit with shutdown code reboot
    4.58           - always:   always restart on exit, ignore exit code
    4.59           - never:    never restart on exit, ignore exit code
    4.60 @@ -114,27 +118,27 @@ gopts.var('netif', val='no|yes',
    4.61            use="Make the domain a network interface backend.")
    4.62  
    4.63  gopts.var('disk', val='phy:DEV,VDEV,MODE',
    4.64 -         fn=append_value, default=[],
    4.65 -         use="""Add a disk device to a domain. The physical device is DEV,
    4.66 +          fn=append_value, default=[],
    4.67 +          use="""Add a disk device to a domain. The physical device is DEV,
    4.68           which is exported to the domain as VDEV. The disk is read-only if MODE
    4.69           is 'r', read-write if MODE is 'w'.
    4.70           The option may be repeated to add more than one disk.
    4.71           """)
    4.72  
    4.73  gopts.var('pci', val='BUS,DEV,FUNC',
    4.74 -         fn=append_value, default=[],
    4.75 -         use="""Add a PCI device to a domain, using given params (in hex).
    4.76 +          fn=append_value, default=[],
    4.77 +          use="""Add a PCI device to a domain, using given params (in hex).
    4.78           For example '-pci c0,02,1a'.
    4.79           The option may be repeated to add more than one pci device.
    4.80           """)
    4.81  
    4.82  gopts.var('ipaddr', val="IPADDR",
    4.83 -         fn=append_value, default=[],
    4.84 -         use="Add an IP address to the domain.")
    4.85 +          fn=append_value, default=[],
    4.86 +          use="Add an IP address to the domain.")
    4.87  
    4.88  gopts.var('vif', val="mac=MAC,bridge=BRIDGE,script=SCRIPT",
    4.89 -         fn=append_value, default=[],
    4.90 -         use="""Add a network interface with the given MAC address and bridge.
    4.91 +          fn=append_value, default=[],
    4.92 +          use="""Add a network interface with the given MAC address and bridge.
    4.93           The vif is configured by calling the given configuration script.
    4.94           If mac is not specified a random MAC address is used.
    4.95           If bridge is not specified the default bridge is used.
    4.96 @@ -144,53 +148,53 @@ gopts.var('vif', val="mac=MAC,bridge=BRI
    4.97           """)
    4.98  
    4.99  gopts.var('nics', val="NUM",
   4.100 -         fn=set_int, default=1,
   4.101 -         use="""Set the number of network interfaces.
   4.102 +          fn=set_int, default=1,
   4.103 +          use="""Set the number of network interfaces.
   4.104           Use the vif option to define interface parameters, otherwise
   4.105           defaults are used. Specifying vifs will increase the
   4.106           number of interfaces as needed.
   4.107           """)
   4.108  
   4.109  gopts.var('root', val='DEVICE',
   4.110 -         fn=set_value, default='',
   4.111 -         use="""Set the root= parameter on the kernel command line.
   4.112 +          fn=set_value, default='',
   4.113 +          use="""Set the root= parameter on the kernel command line.
   4.114           Use a device, e.g. /dev/sda1, or /dev/nfs for NFS root.""")
   4.115  
   4.116  gopts.var('extra', val="ARGS",
   4.117 -         fn=set_value, default='',
   4.118 -         use="Set extra arguments to append to the kernel command line.")
   4.119 +          fn=set_value, default='',
   4.120 +          use="Set extra arguments to append to the kernel command line.")
   4.121  
   4.122  gopts.var('ip', val='IPADDR',
   4.123 -         fn=set_value, default='',
   4.124 -         use="Set the kernel IP interface address.")
   4.125 +          fn=set_value, default='',
   4.126 +          use="Set the kernel IP interface address.")
   4.127  
   4.128  gopts.var('gateway', val="IPADDR",
   4.129 -         fn=set_value, default='',
   4.130 -         use="Set the kernel IP gateway.")
   4.131 +          fn=set_value, default='',
   4.132 +          use="Set the kernel IP gateway.")
   4.133  
   4.134  gopts.var('netmask', val="MASK",
   4.135 -         fn=set_value, default = '',
   4.136 -         use="Set the kernel IP netmask.")
   4.137 +          fn=set_value, default = '',
   4.138 +          use="Set the kernel IP netmask.")
   4.139  
   4.140  gopts.var('hostname', val="NAME",
   4.141 -         fn=set_value, default='',
   4.142 -         use="Set the kernel IP hostname.")
   4.143 +          fn=set_value, default='',
   4.144 +          use="Set the kernel IP hostname.")
   4.145  
   4.146  gopts.var('interface', val="INTF",
   4.147 -         fn=set_value, default="eth0",
   4.148 -         use="Set the kernel IP interface name.")
   4.149 +          fn=set_value, default="eth0",
   4.150 +          use="Set the kernel IP interface name.")
   4.151  
   4.152  gopts.var('dhcp', val="off|dhcp",
   4.153 -         fn=set_value, default='off',
   4.154 -         use="Set the kernel dhcp option.")
   4.155 +          fn=set_value, default='off',
   4.156 +          use="Set the kernel dhcp option.")
   4.157  
   4.158  gopts.var('nfs_server', val="IPADDR",
   4.159 -         fn=set_value, default=None,
   4.160 -         use="Set the address of the NFS server for NFS root.")
   4.161 +          fn=set_value, default=None,
   4.162 +          use="Set the address of the NFS server for NFS root.")
   4.163  
   4.164  gopts.var('nfs_root', val="PATH",
   4.165 -         fn=set_value, default=None,
   4.166 -         use="Set the path of the root NFS directory.")
   4.167 +          fn=set_value, default=None,
   4.168 +          use="Set the path of the root NFS directory.")
   4.169  
   4.170  def strip(pre, s):
   4.171      """Strip prefix 'pre' if present.
   4.172 @@ -244,7 +248,7 @@ def randomMAC():
   4.173      The remaining 3 fields are random, with the first bit of the first
   4.174      random field set 0.
   4.175  
   4.176 -    returns array of 6 ints
   4.177 +    returns MAC address string
   4.178      """
   4.179      mac = [ 0xaa, 0x00, 0x00,
   4.180              random.randint(0x00, 0x7f),
   4.181 @@ -300,6 +304,8 @@ def make_config(vals):
   4.182          config.append(['backend', ['netif']])
   4.183      if vals.restart:
   4.184          config.append(['restart', vals.restart])
   4.185 +    if vals.console:
   4.186 +        config.append(['console', vals.console])
   4.187      
   4.188      configure_image(config, vals)
   4.189      config_devs = []
   4.190 @@ -349,6 +355,7 @@ def preprocess_vifs(opts, vals):
   4.191  
   4.192  def preprocess_ip(opts, vals):
   4.193      setip = (vals.hostname or vals.netmask
   4.194 +             or vals.nfs_server
   4.195               or vals.gateway or vals.dhcp or vals.interface)
   4.196      if not setip: return
   4.197      dummy_nfs_server = '1.2.3.4'