ia64/xen-unstable

changeset 8337:ef2fff896422

Merged.
author emellor@leeni.uk.xensource.com
date Tue Dec 13 10:57:18 2005 +0000 (2005-12-13)
parents d01b3b50ea64 7f2ccea5a4ec
children 82f1b5364f94 1dc393b65019 7256d2425fa7
files tools/examples/vif-nat tools/examples/xmexample.vmx tools/python/xen/xm/create.py
line diff
     1.1 --- a/docs/src/user.tex	Tue Dec 13 10:57:04 2005 +0000
     1.2 +++ b/docs/src/user.tex	Tue Dec 13 10:57:18 2005 +0000
     1.3 @@ -1087,16 +1087,17 @@ for concrete examples.
     1.4  \item[vcpus] The number of virtual CPUs. 
     1.5  \item[console] Port to export the domain console on (default 9600 +
     1.6    domain ID).
     1.7 -\item[nics] Number of virtual network interfaces.
     1.8 -\item[vif] List of MAC addresses (random addresses are assigned if not
     1.9 -  given) and bridges to use for the domain's network interfaces, e.g.\ 
    1.10 +\item[vif] Network interface configuration.  This may simply contain
    1.11 +an empty string for each desired interface, or may override various
    1.12 +settings, e.g.\ 
    1.13  \begin{verbatim}
    1.14  vif = [ 'mac=00:16:3E:00:00:11, bridge=xen-br0',
    1.15          'bridge=xen-br1' ]
    1.16  \end{verbatim}
    1.17    to assign a MAC address and bridge to the first interface and assign
    1.18    a different bridge to the second interface, leaving \xend\ to choose
    1.19 -  the MAC address.
    1.20 +  the MAC address.  The settings that may be overridden in this way are
    1.21 +  type, mac, bridge, ip, script, backend, and vifname.
    1.22  \item[disk] List of block devices to export to the domain e.g. 
    1.23    \verb_disk = [ 'phy:hda1,sda1,r' ]_ 
    1.24    exports physical device \path{/dev/hda1} to the domain as
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_32	Tue Dec 13 10:57:04 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_32	Tue Dec 13 10:57:18 2005 +0000
     2.3 @@ -1,7 +1,7 @@
     2.4  #
     2.5  # Automatically generated make config: don't edit
     2.6  # Linux kernel version: 2.6.12.6-xen
     2.7 -# Mon Nov 28 11:04:51 2005
     2.8 +# Mon Dec 12 10:42:00 2005
     2.9  #
    2.10  CONFIG_XEN=y
    2.11  CONFIG_ARCH_XEN=y
    2.12 @@ -417,7 +417,7 @@ CONFIG_BLK_DEV_SX8=m
    2.13  # CONFIG_BLK_DEV_UB is not set
    2.14  CONFIG_BLK_DEV_RAM=y
    2.15  CONFIG_BLK_DEV_RAM_COUNT=16
    2.16 -CONFIG_BLK_DEV_RAM_SIZE=8192
    2.17 +CONFIG_BLK_DEV_RAM_SIZE=16384
    2.18  CONFIG_BLK_DEV_INITRD=y
    2.19  CONFIG_INITRAMFS_SOURCE=""
    2.20  CONFIG_LBD=y
    2.21 @@ -2726,8 +2726,6 @@ CONFIG_PROC_FS=y
    2.22  CONFIG_PROC_KCORE=y
    2.23  CONFIG_SYSFS=y
    2.24  # CONFIG_DEVFS_FS is not set
    2.25 -# CONFIG_DEVFS_MOUNT is not set
    2.26 -# CONFIG_DEVFS_DEBUG is not set
    2.27  CONFIG_DEVPTS_FS_XATTR=y
    2.28  CONFIG_DEVPTS_FS_SECURITY=y
    2.29  CONFIG_TMPFS=y
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Dec 13 10:57:04 2005 +0000
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Dec 13 10:57:18 2005 +0000
     3.3 @@ -540,8 +540,8 @@ static void network_alloc_rx_buffers(str
     3.4  		 * tailroom then round down to SKB_DATA_ALIGN boundary.
     3.5  		 */
     3.6  		skb = alloc_xen_skb(
     3.7 -			(PAGE_SIZE - 16 - sizeof(struct skb_shared_info)) &
     3.8 -			(-SKB_DATA_ALIGN(1)));
     3.9 +			((PAGE_SIZE - sizeof(struct skb_shared_info)) &
    3.10 +			 (-SKB_DATA_ALIGN(1))) - 16);
    3.11  		if (skb == NULL)
    3.12  			break;
    3.13  		__skb_queue_tail(&np->rx_batch, skb);
     4.1 --- a/tools/examples/vif-common.sh	Tue Dec 13 10:57:04 2005 +0000
     4.2 +++ b/tools/examples/vif-common.sh	Tue Dec 13 10:57:18 2005 +0000
     4.3 @@ -62,7 +62,8 @@ function frob_iptable()
     4.4      local c="-D"
     4.5    fi
     4.6  
     4.7 -  iptables "$c" FORWARD -m physdev --physdev-in "$vif" "$@" -j ACCEPT ||
     4.8 +  iptables "$c" FORWARD -m physdev --physdev-in "$vif" "$@" -j ACCEPT \
     4.9 +    2>/dev/null ||
    4.10      [ "$c" == "-D" ] ||
    4.11      log err \
    4.12       "iptables $c FORWARD -m physdev --physdev-in $vif $@ -j ACCEPT failed.
     5.1 --- a/tools/examples/vif-nat	Tue Dec 13 10:57:04 2005 +0000
     5.2 +++ b/tools/examples/vif-nat	Tue Dec 13 10:57:18 2005 +0000
     5.3 @@ -42,8 +42,8 @@ then
     5.4  fi
     5.5  
     5.6  
     5.7 -domid=$(echo "$XENBUS_PATH" | sed -n 's#.*/\([0-9]*\)/[0-9]*$#\1#p')
     5.8 -vifid=$(echo "$XENBUS_PATH" | sed -n 's#.*/[0-9]*/\([0-9]*\)$#\1#p')
     5.9 +domid=$(xenstore_read "$XENBUS_PATH/frontend-id")
    5.10 +vifid=$(xenstore_read "$XENBUS_PATH/handle")
    5.11  vifid=$(( $vifid + 1 ))
    5.12  
    5.13  
     6.1 --- a/tools/examples/xend-config.sxp	Tue Dec 13 10:57:04 2005 +0000
     6.2 +++ b/tools/examples/xend-config.sxp	Tue Dec 13 10:57:18 2005 +0000
     6.3 @@ -40,7 +40,20 @@
     6.4  # xend-relocation-server is set.
     6.5  # Meaning and default as for xend-address above.
     6.6  #(xend-relocation-address '')
     6.7 -(xend-relocation-address localhost)
     6.8 +
     6.9 +# The hosts allowed to talk to the relocation port.  If this is empty (the
    6.10 +# default), then all connections are allowed (assuming that the connection
    6.11 +# arrives on a port and interface on which we are listening; see
    6.12 +# xend-relocation-port and xend-relocation-address above).  Otherwise, this
    6.13 +# should be a space-separated sequence of regular expressions.  Any host with
    6.14 +# a fully-qualified domain name or an IP address that matches one of these
    6.15 +# regular expressions will be accepted.
    6.16 +#
    6.17 +# For example:
    6.18 +#  (xend-relocation-hosts-allow '^localhost$ ^.*\.example\.org$')
    6.19 +#
    6.20 +#(xend-relocation-hosts-allow '')
    6.21 +(xend-relocation-hosts-allow '^localhost$')
    6.22  
    6.23  # The limit (in kilobytes) on the size of the console buffer
    6.24  #(console-limit 1024)
     7.1 --- a/tools/examples/xmexample.nbd	Tue Dec 13 10:57:04 2005 +0000
     7.2 +++ b/tools/examples/xmexample.nbd	Tue Dec 13 10:57:18 2005 +0000
     7.3 @@ -12,9 +12,7 @@ kernel = "/boot/vmlinuz-2.6.13-15b-xen"
     7.4  ramdisk = "/boot/initrd-2.6.13-15b-xen"
     7.5  memory = 128
     7.6  name = "nbd4"
     7.7 -nics=1
     7.8 -# Please change MAC
     7.9 -vif = [ 'mac=aa:cc:10:10:00:a0, bridge=xenbr0' ]
    7.10 +vif = [ '' ]
    7.11  # Please change PORT
    7.12  disk = [ 'nbd:134.100.233.115 20004,hda1,w' ]
    7.13  dhcp = "dhcp"
     8.1 --- a/tools/examples/xmexample.vmx	Tue Dec 13 10:57:04 2005 +0000
     8.2 +++ b/tools/examples/xmexample.vmx	Tue Dec 13 10:57:18 2005 +0000
     8.3 @@ -37,9 +37,7 @@ vcpus=1
     8.4  
     8.5  # Optionally define mac and/or bridge for the network interfaces.
     8.6  # Random MACs are assigned if not given.
     8.7 -# nics default is 1
     8.8 -#vif = [ 'type=ioemu, mac=aa:00:00:00:00:11, bridge=xenbr0' ]
     8.9 -nics=1 
    8.10 +#vif = [ 'type=ioemu, mac=00:16:3e:00:00:11, bridge=xenbr0' ]
    8.11  # type=ioemu specify the NIC is an ioemu device not netfront
    8.12  vif = [ 'type=ioemu, bridge=xenbr0' ]
    8.13  # for multiple NICs in device model, 3 in this example
     9.1 --- a/tools/examples/xmexample.vti	Tue Dec 13 10:57:04 2005 +0000
     9.2 +++ b/tools/examples/xmexample.vti	Tue Dec 13 10:57:18 2005 +0000
     9.3 @@ -28,12 +28,9 @@ name = "ExampleVMXDomain"
     9.4  #cpus = "0"        # all vcpus run on CPU0
     9.5  #cpus = "0-3,5,^1" # run on cpus 0,2,3,5
     9.6  
     9.7 -# Disable vif for now
     9.8 -nics=0
     9.9 -
    9.10  # Optionally define mac and/or bridge for the network interfaces.
    9.11  # Random MACs are assigned if not given.
    9.12 -#vif = [ 'mac=aa:00:00:00:00:11, bridge=xen-br0' ]
    9.13 +#vif = [ 'mac=00:16:3e:00:00:11, bridge=xen-br0' ]
    9.14  
    9.15  #----------------------------------------------------------------------------
    9.16  # Define the disk devices you want the domain to have access to, and
    10.1 --- a/tools/examples/xmexample1	Tue Dec 13 10:57:04 2005 +0000
    10.2 +++ b/tools/examples/xmexample1	Tue Dec 13 10:57:18 2005 +0000
    10.3 @@ -33,12 +33,20 @@ name = "ExampleDomain"
    10.4  #----------------------------------------------------------------------------
    10.5  # Define network interfaces.
    10.6  
    10.7 -# Number of network interfaces. Default is 1.
    10.8 -#nics=1
    10.9 +# By default, no network interfaces are configured.  You may have one created
   10.10 +# with sensible defaults using an empty vif clause:
   10.11 +#
   10.12 +# vif = [ '' ]
   10.13 +#
   10.14 +# or optionally override backend, bridge, ip, mac, script, type, or vifname:
   10.15 +#
   10.16 +# vif = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0' ]
   10.17 +#
   10.18 +# or more than one interface may be configured:
   10.19 +#
   10.20 +# vif = [ '', 'bridge=xenbr1' ]
   10.21  
   10.22 -# Optionally define mac and/or bridge for the network interfaces.
   10.23 -# Random MACs are assigned if not given.
   10.24 -#vif = [ 'mac=aa:00:00:00:00:11, bridge=xenbr0' ]
   10.25 +vif = [ '' ]
   10.26  
   10.27  #----------------------------------------------------------------------------
   10.28  # Define the disk devices you want the domain to have access to, and
    11.1 --- a/tools/examples/xmexample2	Tue Dec 13 10:57:04 2005 +0000
    11.2 +++ b/tools/examples/xmexample2	Tue Dec 13 10:57:18 2005 +0000
    11.3 @@ -64,12 +64,20 @@ vcpus = 4 # make your domain a 4-way
    11.4  #----------------------------------------------------------------------------
    11.5  # Define network interfaces.
    11.6  
    11.7 -# Number of network interfaces. Default is 1.
    11.8 -#nics=1
    11.9 +# By default, no network interfaces are configured.  You may have one created
   11.10 +# with sensible defaults using an empty vif clause:
   11.11 +#
   11.12 +# vif = [ '' ]
   11.13 +#
   11.14 +# or optionally override backend, bridge, ip, mac, script, type, or vifname:
   11.15 +#
   11.16 +# vif = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0' ]
   11.17 +#
   11.18 +# or more than one interface may be configured:
   11.19 +#
   11.20 +# vif = [ '', 'bridge=xenbr1' ]
   11.21  
   11.22 -# Optionally define mac and/or bridge for the network interfaces.
   11.23 -# Random MACs are assigned if not given.
   11.24 -#vif = [ 'mac=aa:00:00:00:00:11, bridge=xenbr0' ]
   11.25 +vif = [ '' ]
   11.26  
   11.27  #----------------------------------------------------------------------------
   11.28  # Define the disk devices you want the domain to have access to, and
    12.1 --- a/tools/examples/xmexample3	Tue Dec 13 10:57:04 2005 +0000
    12.2 +++ b/tools/examples/xmexample3	Tue Dec 13 10:57:18 2005 +0000
    12.3 @@ -60,9 +60,6 @@ cpus = "%s" % vmid # set based on vmid (
    12.4  #----------------------------------------------------------------------------
    12.5  # Define network interfaces.
    12.6  
    12.7 -# Number of network interfaces. Default is 1.
    12.8 -#nics=1
    12.9 -
   12.10  # Optionally define mac and/or bridge for the network interfaces.
   12.11  # Random MACs are assigned if not given.
   12.12  
    13.1 --- a/tools/python/xen/web/connection.py	Tue Dec 13 10:57:04 2005 +0000
    13.2 +++ b/tools/python/xen/web/connection.py	Tue Dec 13 10:57:18 2005 +0000
    13.3 @@ -19,7 +19,6 @@
    13.4  
    13.5  import sys
    13.6  import threading
    13.7 -import select
    13.8  import socket
    13.9  import fcntl
   13.10  
   13.11 @@ -31,21 +30,17 @@ for TCP and unix-domain sockets (see tcp
   13.12  """
   13.13  
   13.14  BUFFER_SIZE = 1024
   13.15 +BACKLOG = 5
   13.16  
   13.17  
   13.18  class SocketServerConnection:
   13.19      """An accepted connection to a server.
   13.20      """
   13.21  
   13.22 -    def __init__(self, sock, protocol, addr, server):
   13.23 +    def __init__(self, sock, protocol_class):
   13.24          self.sock = sock
   13.25 -        self.protocol = protocol
   13.26 -        self.addr = addr
   13.27 -        self.server = server
   13.28 +        self.protocol = protocol_class()
   13.29          self.protocol.setTransport(self)
   13.30 -
   13.31 -
   13.32 -    def run(self):
   13.33          threading.Thread(target=self.main).start()
   13.34  
   13.35  
   13.36 @@ -68,6 +63,10 @@ class SocketServerConnection:
   13.37                  pass
   13.38  
   13.39  
   13.40 +    def close(self):
   13.41 +        self.sock.close()
   13.42 +
   13.43 +
   13.44      def write(self, data):
   13.45          self.sock.send(data)
   13.46  
   13.47 @@ -77,52 +76,38 @@ class SocketListener:
   13.48      Accepts connections and runs a thread for each one.
   13.49      """
   13.50  
   13.51 -    def __init__(self, protocol_class, backlog=None):
   13.52 -        if backlog is None:
   13.53 -            backlog = 5
   13.54 +    def __init__(self, protocol_class, hosts_allow = ''):
   13.55          self.protocol_class = protocol_class
   13.56 -        self.sock = None
   13.57 -        self.backlog = backlog
   13.58 -        self.thread = None
   13.59 +        self.sock = self.createSocket()
   13.60 +        threading.Thread(target=self.main).start()
   13.61 +
   13.62 +
   13.63 +    def close(self):
   13.64 +        try:
   13.65 +            self.sock.close()
   13.66 +        except:
   13.67 +            pass
   13.68  
   13.69  
   13.70      def createSocket(self):
   13.71          raise NotImplementedError()
   13.72  
   13.73  
   13.74 -    def setCloExec(self):
   13.75 -        fcntl.fcntl(self.sock.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC)
   13.76 -
   13.77 -
   13.78      def acceptConnection(self, sock, protocol, addr):
   13.79 -        return SocketServerConnection(sock, protocol, addr, self)
   13.80 -
   13.81 -
   13.82 -    def listen(self):
   13.83 -        if self.sock or self.thread:
   13.84 -            raise IOError("already listening")
   13.85 -        self.sock = self.createSocket()
   13.86 -        self.sock.listen(self.backlog)
   13.87 -        self.run()
   13.88 -
   13.89 -
   13.90 -    def run(self):
   13.91 -        self.thread = threading.Thread(target=self.main)
   13.92 -        self.thread.start()
   13.93 +        raise NotImplementedError()
   13.94  
   13.95  
   13.96      def main(self):
   13.97          try:
   13.98 +            fcntl.fcntl(self.sock.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC)
   13.99 +            self.sock.listen(BACKLOG)
  13.100 +
  13.101              while True:
  13.102                  try:
  13.103                      (sock, addr) = self.sock.accept()
  13.104 -                    self.acceptConnection(sock, self.protocol_class(),
  13.105 -                                          addr).run()
  13.106 +                    self.acceptConnection(sock, addr)
  13.107                  except socket.error, ex:
  13.108                      if ex.args[0] not in (EWOULDBLOCK, EAGAIN, EINTR):
  13.109                          break
  13.110          finally:
  13.111 -            try:
  13.112 -                self.sock.close()
  13.113 -            except:
  13.114 -                pass
  13.115 +            self.close()
    14.1 --- a/tools/python/xen/web/tcp.py	Tue Dec 13 10:57:04 2005 +0000
    14.2 +++ b/tools/python/xen/web/tcp.py	Tue Dec 13 10:57:18 2005 +0000
    14.3 @@ -17,20 +17,25 @@
    14.4  #============================================================================
    14.5  
    14.6  
    14.7 +import errno
    14.8 +import re
    14.9  import socket
   14.10  import time
   14.11 -import errno
   14.12  
   14.13 -from connection import *
   14.14 +import connection
   14.15 +
   14.16 +from xen.xend.XendLogging import log
   14.17  
   14.18  
   14.19 -class TCPListener(SocketListener):
   14.20 +class TCPListener(connection.SocketListener):
   14.21  
   14.22 -    def __init__(self, port, protocol, backlog=None, interface=''):
   14.23 -        SocketListener.__init__(self, protocol, backlog=backlog)
   14.24 +    def __init__(self, protocol_class, port, interface, hosts_allow):
   14.25          self.port = port
   14.26          self.interface = interface
   14.27 -        
   14.28 +        self.hosts_allow = hosts_allow
   14.29 +        connection.SocketListener.__init__(self, protocol_class)
   14.30 +
   14.31 +
   14.32      def createSocket(self):
   14.33          sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
   14.34          sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
   14.35 @@ -49,11 +54,23 @@ class TCPListener(SocketListener):
   14.36                  else:
   14.37                      raise
   14.38  
   14.39 -    def acceptConnection(self, sock, protocol, addr):
   14.40 -        return SocketServerConnection(sock, protocol, addr, self)
   14.41 -
   14.42  
   14.43 -def listenTCP(port, protocol, interface='', backlog=None):
   14.44 -    l = TCPListener(port, protocol, interface=interface, backlog=backlog)
   14.45 -    l.listen()
   14.46 -    l.setCloExec()
   14.47 +    def acceptConnection(self, sock, addrport):
   14.48 +        addr = addrport[0]
   14.49 +        if self.hosts_allow is None:
   14.50 +                connection.SocketServerConnection(sock, self.protocol_class)
   14.51 +        else:
   14.52 +            fqdn = socket.getfqdn(addr)
   14.53 +            for h in self.hosts_allow:
   14.54 +                if h.match(fqdn) or h.match(addr):
   14.55 +                    log.debug("Match %s %s", fqdn, h.pattern)
   14.56 +                    connection.SocketServerConnection(sock,
   14.57 +                                                      self.protocol_class)
   14.58 +                    return
   14.59 +
   14.60 +            try:
   14.61 +                log.warn("Rejected connection from %s:%d (%s) for port %d.",
   14.62 +                         addr, addrport[1], fqdn, self.port)
   14.63 +                sock.close()
   14.64 +            except:
   14.65 +                pass
    15.1 --- a/tools/python/xen/web/unix.py	Tue Dec 13 10:57:04 2005 +0000
    15.2 +++ b/tools/python/xen/web/unix.py	Tue Dec 13 10:57:18 2005 +0000
    15.3 @@ -21,15 +21,15 @@ import socket
    15.4  import os
    15.5  import os.path
    15.6  
    15.7 -from connection import *
    15.8 +import connection
    15.9  
   15.10  
   15.11 -class UnixListener(SocketListener):
   15.12 +class UnixListener(connection.SocketListener):
   15.13 +    def __init__(self, path, protocol_class):
   15.14 +        self.path = path
   15.15 +        connection.SocketListener.__init__(self, protocol_class)
   15.16  
   15.17 -    def __init__(self, path, protocol, backlog=None):
   15.18 -        SocketListener.__init__(self, protocol, backlog=backlog)
   15.19 -        self.path = path
   15.20 -        
   15.21 +
   15.22      def createSocket(self):
   15.23          pathdir = os.path.dirname(self.path)
   15.24          if not os.path.exists(pathdir):
   15.25 @@ -45,9 +45,6 @@ class UnixListener(SocketListener):
   15.26          sock.bind(self.path)
   15.27          return sock
   15.28  
   15.29 -    def acceptConnection(self, sock, protocol, addr):
   15.30 -        return SocketServerConnection(sock, protocol, self.path, self)
   15.31  
   15.32 -
   15.33 -def listenUNIX(path, protocol, backlog=None):
   15.34 -    UnixListener(path, protocol, backlog=backlog).listen()
   15.35 +    def acceptConnection(self, sock, _):
   15.36 +        connection.SocketServerConnection(sock, self.protocol_class)
    16.1 --- a/tools/python/xen/xend/XendRoot.py	Tue Dec 13 10:57:04 2005 +0000
    16.2 +++ b/tools/python/xen/xend/XendRoot.py	Tue Dec 13 10:57:18 2005 +0000
    16.3 @@ -75,6 +75,8 @@ class XendRoot:
    16.4      """Default port xend serves relocation at. """
    16.5      xend_relocation_port_default = '8002'
    16.6  
    16.7 +    xend_relocation_hosts_allow_default = ''
    16.8 +
    16.9      """Default for the flag indicating whether xend should run a unix-domain server."""
   16.10      xend_unix_server_default = 'yes'
   16.11  
   16.12 @@ -194,6 +196,10 @@ class XendRoot:
   16.13          """
   16.14          return self.get_config_int('xend-relocation-port', self.xend_relocation_port_default)
   16.15  
   16.16 +    def get_xend_relocation_hosts_allow(self):
   16.17 +        return self.get_config_value("xend-relocation-hosts-allow",
   16.18 +                                     self.xend_relocation_hosts_allow_default)
   16.19 +
   16.20      def get_xend_address(self):
   16.21          """Get the address xend listens at for its HTTP port.
   16.22          This defaults to the empty string which allows all hosts to connect.
    17.1 --- a/tools/python/xen/xend/server/SrvDaemon.py	Tue Dec 13 10:57:04 2005 +0000
    17.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py	Tue Dec 13 10:57:18 2005 +0000
    17.3 @@ -16,10 +16,10 @@ import traceback
    17.4  
    17.5  import xen.lowlevel.xc
    17.6  
    17.7 -from xen.xend.server import SrvServer
    17.8  from xen.xend.XendLogging import log
    17.9  
   17.10  import relocate
   17.11 +import SrvServer
   17.12  from params import *
   17.13  
   17.14  
   17.15 @@ -167,8 +167,9 @@ class Daemon:
   17.16              while True:
   17.17                  pid = self.fork_pid()
   17.18                  if pid:
   17.19 -                    os.close(w)
   17.20 -                    w = False
   17.21 +                    if w is not None:
   17.22 +                        os.close(w)
   17.23 +                        w = None
   17.24  
   17.25                      (_, status) = os.waitpid(pid, 0)
   17.26  
    18.1 --- a/tools/python/xen/xend/server/SrvServer.py	Tue Dec 13 10:57:04 2005 +0000
    18.2 +++ b/tools/python/xen/xend/server/SrvServer.py	Tue Dec 13 10:57:18 2005 +0000
    18.3 @@ -40,6 +40,7 @@
    18.4  # todo Support command-line args.
    18.5  
    18.6  import fcntl
    18.7 +import time
    18.8  from threading import Thread
    18.9  
   18.10  from xen.web.httpserver import HttpServer, UnixHttpServer
   18.11 @@ -48,7 +49,6 @@ from xen.xend import XendRoot
   18.12  from xen.xend import Vifctl
   18.13  from xen.xend.XendLogging import log
   18.14  from xen.web.SrvDir import SrvDir
   18.15 -import time
   18.16  
   18.17  from SrvRoot import SrvRoot
   18.18  
    19.1 --- a/tools/python/xen/xend/server/relocate.py	Tue Dec 13 10:57:04 2005 +0000
    19.2 +++ b/tools/python/xen/xend/server/relocate.py	Tue Dec 13 10:57:18 2005 +0000
    19.3 @@ -16,6 +16,7 @@
    19.4  # Copyright (C) 2005 XenSource Ltd
    19.5  #============================================================================
    19.6  
    19.7 +import re
    19.8  import sys
    19.9  import StringIO
   19.10  
   19.11 @@ -116,8 +117,16 @@ def listenRelocation():
   19.12      xroot = XendRoot.instance()
   19.13      if xroot.get_xend_unix_server():
   19.14          path = '/var/lib/xend/relocation-socket'
   19.15 -        unix.listenUNIX(path, RelocationProtocol)
   19.16 +        unix.UnixListener(path, RelocationProtocol)
   19.17      if xroot.get_xend_relocation_server():
   19.18          port = xroot.get_xend_relocation_port()
   19.19          interface = xroot.get_xend_relocation_address()
   19.20 -        tcp.listenTCP(port, RelocationProtocol, interface=interface)
   19.21 +
   19.22 +        hosts_allow = xroot.get_xend_relocation_hosts_allow()
   19.23 +        if hosts_allow == '':
   19.24 +            hosts_allow = None
   19.25 +        else:
   19.26 +            hosts_allow = map(re.compile, hosts_allow.split(" "))
   19.27 +
   19.28 +        tcp.TCPListener(RelocationProtocol, port, interface = interface,
   19.29 +                        hosts_allow = hosts_allow)
    20.1 --- a/tools/python/xen/xend/sxp.py	Tue Dec 13 10:57:04 2005 +0000
    20.2 +++ b/tools/python/xen/xend/sxp.py	Tue Dec 13 10:57:18 2005 +0000
    20.3 @@ -696,13 +696,16 @@ def to_string(sxpr):
    20.4      io.close()
    20.5      return val
    20.6  
    20.7 -def from_string(str):
    20.8 +def from_string(s):
    20.9      """Create an sxpr by parsing a string.
   20.10  
   20.11 -    str string
   20.12 +    s string
   20.13      returns sxpr
   20.14      """
   20.15 -    io = StringIO(str)
   20.16 +    if s == '':
   20.17 +        return []
   20.18 +
   20.19 +    io = StringIO(s)
   20.20      vals = parse(io)
   20.21      if vals is []:
   20.22          return None
   20.23 @@ -710,13 +713,13 @@ def from_string(str):
   20.24          return vals[0]
   20.25      
   20.26  
   20.27 -def all_from_string(str):
   20.28 +def all_from_string(s):
   20.29      """Create an sxpr list by parsing a string.
   20.30  
   20.31 -    str string
   20.32 +    s string
   20.33      returns sxpr list
   20.34      """
   20.35 -    io = StringIO(str)
   20.36 +    io = StringIO(s)
   20.37      vals = parse(io)
   20.38      return vals
   20.39  
    21.1 --- a/tools/python/xen/xm/create.py	Tue Dec 13 10:57:04 2005 +0000
    21.2 +++ b/tools/python/xen/xm/create.py	Tue Dec 13 10:57:18 2005 +0000
    21.3 @@ -253,17 +253,12 @@ gopts.var('usb', val='PATH',
    21.4            use="""Add a physical USB port to a domain, as specified by the path
    21.5            to that port.  This option may be repeated to add more than one port.""")
    21.6  
    21.7 -gopts.var('ipaddr', val="IPADDR",
    21.8 -          fn=append_value, default=[],
    21.9 -          use="Add an IP address to the domain.")
   21.10 -
   21.11 -gopts.var('vif', val="type=TYPE,mac=MAC,be_mac=MAC,bridge=BRIDGE,script=SCRIPT,backend=DOM,vifname=NAME",
   21.12 +gopts.var('vif', val="type=TYPE,mac=MAC,bridge=BRIDGE,ip=IPADDR,script=SCRIPT,backend=DOM,vifname=NAME",
   21.13            fn=append_value, default=[],
   21.14            use="""Add a network interface with the given MAC address and bridge.
   21.15            The vif is configured by calling the given configuration script.
   21.16            If type is not specified, default is netfront not ioemu device.
   21.17            If mac is not specified a random MAC address is used.
   21.18 -          The MAC address of the backend interface can be selected with be_mac.
   21.19            If not specified then the network backend chooses it's own MAC address.
   21.20            If bridge is not specified the first bridge found is used.
   21.21            If script is not specified the default script is used.
   21.22 @@ -284,8 +279,10 @@ gopts.var('vtpm', val="instance=INSTANCE
   21.23            given domain.""")
   21.24  
   21.25  gopts.var('nics', val="NUM",
   21.26 -          fn=set_int, default=1,
   21.27 -          use="""Set the number of network interfaces.
   21.28 +          fn=set_int, default=-1,
   21.29 +          use="""DEPRECATED.  Use empty vif entries instead.
   21.30 +
   21.31 +          Set the number of network interfaces.
   21.32            Use the vif option to define interface parameters, otherwise
   21.33            defaults are used. Specifying vifs will increase the
   21.34            number of interfaces as needed.""")
   21.35 @@ -487,58 +484,38 @@ def configure_vtpm(config_devs, vals):
   21.36                  config_vtpm.append(['backend', backend])
   21.37              config_devs.append(['device', config_vtpm])
   21.38  
   21.39 +
   21.40  def configure_vifs(config_devs, vals):
   21.41      """Create the config for virtual network interfaces.
   21.42      """
   21.43 -    vifs = vals.vif
   21.44 -    vifs_n = max(vals.nics, len(vifs))
   21.45  
   21.46 -    for idx in range(0, vifs_n):
   21.47 -        if idx < len(vifs):
   21.48 -            d = vifs[idx]
   21.49 -            mac = d.get('mac')
   21.50 -            be_mac = d.get('be_mac')
   21.51 -            bridge = d.get('bridge')
   21.52 -            script = d.get('script')
   21.53 -            backend = d.get('backend')
   21.54 -            ip = d.get('ip')
   21.55 -            vifname = d.get('vifname')
   21.56 -            type = d.get('type')
   21.57 -        else:
   21.58 -            mac = None
   21.59 -            be_mac = None
   21.60 -            bridge = None
   21.61 -            script = None
   21.62 -            backend = None
   21.63 -            ip = None
   21.64 -            vifname = None
   21.65 -            type = None
   21.66 +    vifs = vals.vif
   21.67 +    vifs_n = len(vifs)
   21.68 +
   21.69 +    if hasattr(vals, 'nics'):
   21.70 +        if vals.nics > 0:
   21.71 +            warn("The nics option is deprecated.  Please use an empty vif "
   21.72 +                 "entry instead:\n\n  vif = [ '' ]\n")
   21.73 +            for _ in range(vifs_n, vals.nics):
   21.74 +                vifs.append('')
   21.75 +            vifs_n = len(vifs)
   21.76 +        elif vals.nics == 0:
   21.77 +            warn("The nics option is deprecated.  Please remove it.")
   21.78 +
   21.79 +    for c in vifs:
   21.80 +        d = comma_sep_kv_to_dict(c)
   21.81          config_vif = ['vif']
   21.82 -        if mac:
   21.83 -            config_vif.append(['mac', mac])
   21.84 -        if vifname:
   21.85 -            config_vif.append(['vifname', vifname])
   21.86 -        if be_mac:
   21.87 -            config_vif.append(['be_mac', be_mac])
   21.88 -        if bridge:
   21.89 -            config_vif.append(['bridge', bridge])
   21.90 -        if script:
   21.91 -            config_vif.append(['script', script])
   21.92 -        if backend:
   21.93 -            config_vif.append(['backend', backend])
   21.94 -        if ip:
   21.95 -            config_vif.append(['ip', ip])
   21.96 -        if type:
   21.97 -            config_vif.append(['type', type])
   21.98 +
   21.99 +        def f(k):
  21.100 +            if k not in ['backend', 'bridge', 'ip', 'mac', 'script', 'type',
  21.101 +                         'vifname']:
  21.102 +                err('Invalid vif option: ' + k)
  21.103 +
  21.104 +            config_vif.append([k, d[k]])
  21.105 +
  21.106 +        map(f, d.keys())
  21.107          config_devs.append(['device', config_vif])
  21.108  
  21.109 -def configure_vfr(config, vals):
  21.110 -     if not vals.ipaddr: return
  21.111 -     config_vfr = ['vfr']
  21.112 -     idx = 0 # No way of saying which IP is for which vif?
  21.113 -     for ip in vals.ipaddr:
  21.114 -         config_vfr.append(['vif', ['id', idx], ['ip', ip]])
  21.115 -     config.append(config_vfr)
  21.116  
  21.117  def configure_vmx(config_image, vals):
  21.118      """Create the config for VMX devices.
  21.119 @@ -648,22 +625,6 @@ def preprocess_ioports(vals):
  21.120          ioports.append(hexd)
  21.121      vals.ioports = ioports
  21.122          
  21.123 -def preprocess_vifs(vals):
  21.124 -    if not vals.vif: return
  21.125 -    vifs = []
  21.126 -    for vif in vals.vif:
  21.127 -        d = {}
  21.128 -        a = vif.split(',')
  21.129 -        for b in a:
  21.130 -            (k, v) = b.strip().split('=', 1)
  21.131 -            k = k.strip()
  21.132 -            v = v.strip()
  21.133 -            if k not in ['type', 'mac', 'be_mac', 'bridge', 'script', 'backend', 'ip', 'vifname']:
  21.134 -                err('Invalid vif specifier: ' + vif)
  21.135 -            d[k] = v
  21.136 -        vifs.append(d)
  21.137 -    vals.vif = vifs
  21.138 -
  21.139  def preprocess_vtpm(vals):
  21.140      if not vals.vtpm: return
  21.141      vtpms = []
  21.142 @@ -765,12 +726,30 @@ def preprocess(vals):
  21.143      preprocess_disk(vals)
  21.144      preprocess_pci(vals)
  21.145      preprocess_ioports(vals)
  21.146 -    preprocess_vifs(vals)
  21.147      preprocess_ip(vals)
  21.148      preprocess_nfs(vals)
  21.149      preprocess_vnc(vals)
  21.150      preprocess_vtpm(vals)
  21.151 -         
  21.152 +
  21.153 +
  21.154 +def comma_sep_kv_to_dict(c):
  21.155 +    """Convert comma-separated, equals-separated key-value pairs into a
  21.156 +    dictionary.
  21.157 +    """
  21.158 +    d = {}
  21.159 +    c = c.strip()
  21.160 +    if len(c) > 0:
  21.161 +        a = c.split(',')
  21.162 +        for b in a:
  21.163 +            if b.find('=') == -1:
  21.164 +                err("%s should be a pair, separated by an equals sign." % b)
  21.165 +            (k, v) = b.split('=', 1)
  21.166 +            k = k.strip()
  21.167 +            v = v.strip()
  21.168 +            d[k] = v
  21.169 +    return d
  21.170 +
  21.171 +
  21.172  def make_domain(opts, config):
  21.173      """Create, build and start a domain.
  21.174  
    22.1 --- a/tools/python/xen/xm/tests/test_create.py	Tue Dec 13 10:57:04 2005 +0000
    22.2 +++ b/tools/python/xen/xm/tests/test_create.py	Tue Dec 13 10:57:18 2005 +0000
    22.3 @@ -36,7 +36,7 @@ class test_create(unittest.TestCase):
    22.4          (fd, fname) = tempfile.mkstemp()
    22.5          os.close(fd)
    22.6          self.t('-f %s kernel=/mykernel display=fakedisplay '
    22.7 -               'macaddr=ab:cd:ef:ed nics=0' % fname,
    22.8 +               'macaddr=ab:cd:ef:ed' % fname,
    22.9                 { 'name'      : os.path.basename(fname),
   22.10                   'xm_file'   : fname,
   22.11                   'defconfig' : fname,
   22.12 @@ -50,6 +50,7 @@ class test_create(unittest.TestCase):
   22.13                   'interface' : 'eth0',
   22.14                   'path'      : '.:/etc/xen',
   22.15                   'builder'   : 'linux',
   22.16 +                 'nics'      : -1,
   22.17                   })
   22.18  
   22.19  
   22.20 @@ -62,7 +63,6 @@ kernel = "/boot/vmlinuz-xenU-smp"
   22.21  memory = 768
   22.22  name = "dom1"
   22.23  vcpus = 4
   22.24 -nics = 1
   22.25  disk = ['phy:/dev/virt-blkdev-backend/dom1,sda1,w',
   22.26  'phy:/dev/virt-blkdev-backend/usr,sda2,r']
   22.27  root = "/dev/sda1 ro"
   22.28 @@ -79,7 +79,7 @@ on_crash    = 'destroy'
   22.29                   'memory'      : 768,
   22.30                   'name'        : 'dom1',
   22.31                   'vcpus'       : 4,
   22.32 -                 'nics'        : 1,
   22.33 +                 'nics'        : -1,
   22.34                   'root'        : '/dev/sda1 ro',
   22.35                   'extra'       : ' profile=1 GATEWAY=10.0.1.254 NETMASK=255.255.0.0 IPADDR=10.0.134.1 HOSTNAME=dom1',
   22.36                   'on_poweroff' : 'destroy',
   22.37 @@ -118,7 +118,7 @@ cpu_weight = 0.75
   22.38          finally:
   22.39              os.close(fd)
   22.40  
   22.41 -        self.t('-f %s display=fakedisplay macaddr=ab:cd:ef:ed nics=0' %
   22.42 +        self.t('-f %s display=fakedisplay macaddr=ab:cd:ef:ed' %
   22.43            fname,
   22.44                 { 'name'       : 'testname',
   22.45                   'xm_file'    : fname,
   22.46 @@ -137,6 +137,7 @@ cpu_weight = 0.75
   22.47                   'interface'  : 'eth0',
   22.48                   'path'       : '.:/etc/xen',
   22.49                   'builder'    : 'linux',
   22.50 +                 'nics'       : -1,
   22.51                   })
   22.52              
   22.53  
    23.1 --- a/tools/xm-test/lib/XmTestLib/XenDomain.py	Tue Dec 13 10:57:04 2005 +0000
    23.2 +++ b/tools/xm-test/lib/XmTestLib/XenDomain.py	Tue Dec 13 10:57:18 2005 +0000
    23.3 @@ -203,7 +203,6 @@ class XmTestVmxDomain(XenDomain):
    23.4          # Defaults
    23.5          self.defaults = {"memory"    : 64,
    23.6                           "vcpus"     : 1,
    23.7 -                         "nics"      : 0,
    23.8                           "kernel"    : "/usr/lib/xen/boot/vmxloader",
    23.9                           "builder"   : "\'vmx\'",
   23.10                           "name"      : name or self.getUniqueName()
   23.11 @@ -264,7 +263,6 @@ class XmTestPvDomain(XenDomain):
   23.12          # Defaults
   23.13          self.defaults = {"memory"  : 64,
   23.14                           "vcpus"   : 1,
   23.15 -                         "nics"    : 0,
   23.16                           "kernel"  : getDefaultKernel(),
   23.17                           "root"    : "/dev/ram0",
   23.18                           "name"    : name or self.getUniqueName(),
    24.1 --- a/tools/xm-test/tests/create/13_create_multinic_pos.py	Tue Dec 13 10:57:04 2005 +0000
    24.2 +++ b/tools/xm-test/tests/create/13_create_multinic_pos.py	Tue Dec 13 10:57:18 2005 +0000
    24.3 @@ -6,7 +6,8 @@
    24.4  from XmTestLib import *
    24.5  
    24.6  for i in range(0,10):
    24.7 -    domain = XmTestDomain(extraOpts={"nics":"%i" % i})
    24.8 +    domain = XmTestDomain()
    24.9 +    domain.configSetVar('vif', str(['' for _ in range(0, i)]))
   24.10  
   24.11      try:
   24.12          domain.start()
    25.1 --- a/tools/xm-test/tests/network/02_network_local_ping_pos.py	Tue Dec 13 10:57:04 2005 +0000
    25.2 +++ b/tools/xm-test/tests/network/02_network_local_ping_pos.py	Tue Dec 13 10:57:18 2005 +0000
    25.3 @@ -28,7 +28,7 @@ ip   = Net.ip("dom1", "eth0")
    25.4  mask = Net.mask("dom1", "eth0")
    25.5  
    25.6  # Fire up a guest domain w/1 nic
    25.7 -domain = XmTestDomain(extraOpts={ 'nics' : 1 })
    25.8 +domain = XmTestDomain()
    25.9  try:
   25.10      domain.configSetVar('vif', " [ 'ip=" + ip + "' ]")
   25.11      domain.start()
    26.1 --- a/tools/xm-test/tests/network/05_network_dom0_ping_pos.py	Tue Dec 13 10:57:04 2005 +0000
    26.2 +++ b/tools/xm-test/tests/network/05_network_dom0_ping_pos.py	Tue Dec 13 10:57:18 2005 +0000
    26.3 @@ -31,7 +31,7 @@ except NetworkError, e:
    26.4          FAIL(str(e))
    26.5  
    26.6  # Fire up a guest domain w/1 nic
    26.7 -domain = XmTestDomain(extraOpts={ 'nics' : 1 })
    26.8 +domain = XmTestDomain()
    26.9  try:
   26.10      domain.configSetVar('vif', " [ 'ip=" + ip + "' ]")
   26.11      domain.start()
    27.1 --- a/tools/xm-test/tests/network/11_network_domU_ping_pos.py	Tue Dec 13 10:57:04 2005 +0000
    27.2 +++ b/tools/xm-test/tests/network/11_network_domU_ping_pos.py	Tue Dec 13 10:57:18 2005 +0000
    27.3 @@ -21,7 +21,7 @@ from XmTestLib import *
    27.4  
    27.5  
    27.6  def netDomain(ip):
    27.7 -    dom = XmTestDomain(extraOpts={ 'nics' : 1 })
    27.8 +    dom = XmTestDomain()
    27.9      try:
   27.10          dom.configSetVar('vif', " [ 'ip=" + ip + "' ]")
   27.11          dom.start()
    28.1 --- a/tools/xm-test/tests/restore/04_restore_withdevices_pos.py	Tue Dec 13 10:57:04 2005 +0000
    28.2 +++ b/tools/xm-test/tests/restore/04_restore_withdevices_pos.py	Tue Dec 13 10:57:18 2005 +0000
    28.3 @@ -7,7 +7,9 @@ from XmTestLib import *
    28.4  
    28.5  import re
    28.6  
    28.7 -domain = XmTestDomain(extraOpts={"nics":2})
    28.8 +domain = XmTestDomain()
    28.9 +
   28.10 +domain.configSetVar('vif', "[ '', '' ]")
   28.11  
   28.12  domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
   28.13  domain.configAddDisk("phy:/dev/ram1", "hdb2", "w")