ia64/xen-unstable

changeset 1667:172f2a1c8a79

bitkeeper revision 1.1041.5.3 (40e52bb9WJhGe1FCqVgmhmhFHxEFRg)

Merge xenbk@gandalf:/var/bk/xeno-unstable.bk
into wray-m-3.hpl.hp.com:/home/mjw/repos-bk/xeno-unstable.bk
author mjw@wray-m-3.hpl.hp.com
date Fri Jul 02 09:32:41 2004 +0000 (2004-07-02)
parents 52c04d5d2a8e bbd6af62af53
children 025e093088ad
files tools/libxutil/Makefile tools/libxutil/allocate.h tools/libxutil/file_stream.h tools/libxutil/gzip_stream.c tools/libxutil/gzip_stream.h tools/libxutil/kernel_stream.h tools/libxutil/string_stream.h tools/libxutil/sys_net.h tools/libxutil/sys_string.h tools/python/xen/xend/server/blkif.py tools/python/xen/xend/server/channel.py tools/python/xen/xend/server/console.py tools/python/xen/xend/server/controller.py tools/python/xen/xend/server/netif.py
line diff
     1.1 --- a/tools/libxutil/Makefile	Fri Jul 02 09:32:06 2004 +0000
     1.2 +++ b/tools/libxutil/Makefile	Fri Jul 02 09:32:41 2004 +0000
     1.3 @@ -8,7 +8,7 @@ LIB_SRCS += allocate.c
     1.4  LIB_SRCS += file_stream.c
     1.5  LIB_SRCS += gzip_stream.c
     1.6  LIB_SRCS += iostream.c
     1.7 -LIB_SRCS += sys_net.c
     1.8 +#LIB_SRCS += sys_net.c
     1.9  LIB_SRCS += sys_string.c
    1.10  
    1.11  LIB_OBJS := $(LIB_SRCS:.c=.o)
     2.1 --- a/tools/libxutil/allocate.h	Fri Jul 02 09:32:06 2004 +0000
     2.2 +++ b/tools/libxutil/allocate.h	Fri Jul 02 09:32:41 2004 +0000
     2.3 @@ -16,8 +16,8 @@
     2.4   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     2.5   */
     2.6  
     2.7 -#ifndef _XEN_LIB_ALLOCATE_H_
     2.8 -#define _XEN_LIB_ALLOCATE_H_
     2.9 +#ifndef _XUTIL_ALLOCATE_H_
    2.10 +#define _XUTIL_ALLOCATE_H_
    2.11  
    2.12  /** Allocate memory for a given type, and cast. */
    2.13  #define ALLOCATE(ctype) (ctype *)allocate(sizeof(ctype))
    2.14 @@ -33,7 +33,7 @@ extern void memzero(void *p, int size);
    2.15  typedef void AllocateFailedFn(int size, int type);
    2.16  extern AllocateFailedFn *allocate_failed_fn;
    2.17  
    2.18 -#endif /* _XEN_LIB_ALLOCATE_H_ */
    2.19 +#endif /* _XUTIL_ALLOCATE_H_ */
    2.20  
    2.21  
    2.22  
     3.1 --- a/tools/libxutil/file_stream.h	Fri Jul 02 09:32:06 2004 +0000
     3.2 +++ b/tools/libxutil/file_stream.h	Fri Jul 02 09:32:41 2004 +0000
     3.3 @@ -16,8 +16,8 @@
     3.4   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     3.5   */
     3.6  
     3.7 -#ifndef _XEN_LIB_FILE_STREAM_H_
     3.8 -#define _XEN_LIB_FILE_STREAM_H_
     3.9 +#ifndef _XUTIL_FILE_STREAM_H_
    3.10 +#define _XUTIL_FILE_STREAM_H_
    3.11  
    3.12  #ifndef __KERNEL__
    3.13  #include "iostream.h"
    3.14 @@ -32,4 +32,4 @@ extern IOStream get_stream_stdin(void);
    3.15  
    3.16  extern int file_stream_setvbuf(IOStream *io, char *buf, int mode, size_t size);
    3.17  #endif
    3.18 -#endif /* !_XEN_LIB_FILE_STREAM_H_ */
    3.19 +#endif /* !_XUTIL_FILE_STREAM_H_ */
     4.1 --- a/tools/libxutil/gzip_stream.c	Fri Jul 02 09:32:06 2004 +0000
     4.2 +++ b/tools/libxutil/gzip_stream.c	Fri Jul 02 09:32:41 2004 +0000
     4.3 @@ -1,4 +1,3 @@
     4.4 -/* $Id: gzip_stream.c,v 1.4 2003/09/30 15:22:53 mjw Exp $ */
     4.5  /*
     4.6   * Copyright (C) 2003 Hewlett-Packard Company.
     4.7   *
     5.1 --- a/tools/libxutil/gzip_stream.h	Fri Jul 02 09:32:06 2004 +0000
     5.2 +++ b/tools/libxutil/gzip_stream.h	Fri Jul 02 09:32:41 2004 +0000
     5.3 @@ -1,4 +1,3 @@
     5.4 -#/* $Id: gzip_stream.h,v 1.3 2003/09/30 15:22:53 mjw Exp $ */
     5.5  /*
     5.6   * Copyright (C) 2003 Hewlett-Packard Company.
     5.7   *
     5.8 @@ -17,8 +16,8 @@
     5.9   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    5.10   */
    5.11  
    5.12 -#ifndef _SP_GZIP_STREAM_H_
    5.13 -#define _SP_GZIP_STREAM_H_
    5.14 +#ifndef _XUTIL_GZIP_STREAM_H_
    5.15 +#define _XUTIL_GZIP_STREAM_H_
    5.16  
    5.17  #ifndef __KERNEL__
    5.18  #include "iostream.h"
    5.19 @@ -28,4 +27,4 @@ extern IOStream *gzip_stream_new(gzFile 
    5.20  extern IOStream *gzip_stream_fopen(const char *file, const char *flags);
    5.21  extern IOStream *gzip_stream_fdopen(int fd, const char *flags);
    5.22  #endif
    5.23 -#endif /* !_SP_FILE_STREAM_H_ */
    5.24 +#endif /* !_XUTIL_GZIP_STREAM_H_ */
     6.1 --- a/tools/libxutil/kernel_stream.h	Fri Jul 02 09:32:06 2004 +0000
     6.2 +++ b/tools/libxutil/kernel_stream.h	Fri Jul 02 09:32:41 2004 +0000
     6.3 @@ -16,8 +16,8 @@
     6.4   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     6.5   */
     6.6  
     6.7 -#ifndef _XEN_LIB_KERNEL_STREAM_H_
     6.8 -#define _XEN_LIB_KERNEL_STREAM_H_
     6.9 +#ifndef _XUTIL_KERNEL_STREAM_H_
    6.10 +#define _XUTIL_KERNEL_STREAM_H_
    6.11  
    6.12  #ifdef __KERNEL__
    6.13  #include "iostream.h"
    6.14 @@ -26,4 +26,4 @@ extern IOStream get_stream_kernel(void);
    6.15  #define get_stream_stdout get_stream_kernel
    6.16  
    6.17  #endif /* __KERNEL__ */
    6.18 -#endif /* !_XEN_LIB_KERNEL_STREAM_H_ */
    6.19 +#endif /* !_XUTIL_KERNEL_STREAM_H_ */
     7.1 --- a/tools/libxutil/string_stream.h	Fri Jul 02 09:32:06 2004 +0000
     7.2 +++ b/tools/libxutil/string_stream.h	Fri Jul 02 09:32:41 2004 +0000
     7.3 @@ -1,4 +1,3 @@
     7.4 -/* $Id: string_stream.h,v 1.1 2003/08/22 14:25:48 mjw Exp $ */
     7.5  /*
     7.6   * Copyright (C) 2001, 2002 Hewlett-Packard Company.
     7.7   *
     7.8 @@ -17,8 +16,8 @@
     7.9   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    7.10   */
    7.11  
    7.12 -#ifndef _SP_STRING_STREAM_H_
    7.13 -#define _SP_STRING_STREAM_H_
    7.14 +#ifndef _XUTIL_STRING_STREAM_H_
    7.15 +#define _XUTIL_STRING_STREAM_H_
    7.16  
    7.17  #include "iostream.h"
    7.18  
    7.19 @@ -43,4 +42,4 @@ extern IOMethods *string_stream_get_meth
    7.20  extern IOStream *string_stream_new(char *s, int n);
    7.21  extern void string_stream_init(IOStream *stream, StringData *data, char *s, int n);
    7.22  
    7.23 -#endif /* !_SP_STRING_STREAM_H_ */
    7.24 +#endif /* !_XUTIL_STRING_STREAM_H_ */
     8.1 --- a/tools/libxutil/sys_net.h	Fri Jul 02 09:32:06 2004 +0000
     8.2 +++ b/tools/libxutil/sys_net.h	Fri Jul 02 09:32:41 2004 +0000
     8.3 @@ -16,8 +16,8 @@
     8.4   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     8.5   */
     8.6  
     8.7 -#ifndef _XEN_LIB_SYS_NET_H_
     8.8 -#define _XEN_LIB_SYS_NET_H_
     8.9 +#ifndef _XUTIL_SYS_NET_H_
    8.10 +#define _XUTIL_SYS_NET_H_
    8.11  /** @file
    8.12   *
    8.13   * Replacement for standard network includes.
    8.14 @@ -72,7 +72,7 @@ extern int inet_aton(const char *address
    8.15  extern char *mac_ntoa(const unsigned char *macaddr);
    8.16  extern int mac_aton(const char *addr, unsigned char *macaddr);
    8.17  
    8.18 -#endif /* !_SP_SYS_NET_H_ */
    8.19 +#endif /* !_XUTIL_SYS_NET_H_ */
    8.20  
    8.21  
    8.22  
     9.1 --- a/tools/libxutil/sys_string.h	Fri Jul 02 09:32:06 2004 +0000
     9.2 +++ b/tools/libxutil/sys_string.h	Fri Jul 02 09:32:41 2004 +0000
     9.3 @@ -16,8 +16,8 @@
     9.4   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     9.5   */
     9.6  
     9.7 -#ifndef _XEN_LIB_SYS_STRING_H_
     9.8 -#define _XEN_LIB_SYS_STRING_H_
     9.9 +#ifndef _XUTIL_SYS_STRING_H_
    9.10 +#define _XUTIL_SYS_STRING_H_
    9.11  /** @file
    9.12   * Replacement for standard string includes.
    9.13   * Works in user or kernel code.
    9.14 @@ -88,4 +88,4 @@ static inline size_t strnlen(const char 
    9.15  extern int convert_atoul(const char *s, unsigned long *v);
    9.16  extern int path_concat(char *s, char *t, char **val);
    9.17  
    9.18 -#endif /* !_XEN_LIB_SYS_STRING_H_ */
    9.19 +#endif /* !_XUTIL_SYS_STRING_H_ */
    10.1 --- a/tools/python/xen/xend/server/blkif.py	Fri Jul 02 09:32:06 2004 +0000
    10.2 +++ b/tools/python/xen/xend/server/blkif.py	Fri Jul 02 09:32:41 2004 +0000
    10.3 @@ -210,9 +210,6 @@ class BlkifController(controller.Control
    10.4                          self.evtchn['port2']])
    10.5          return val
    10.6  
    10.7 -    def lostChannel(self):
    10.8 -        controller.Controller.lostChannel(self)
    10.9 -
   10.10      def getDevices(self):
   10.11          return self.devices.values()
   10.12  
    11.1 --- a/tools/python/xen/xend/server/channel.py	Fri Jul 02 09:32:06 2004 +0000
    11.2 +++ b/tools/python/xen/xend/server/channel.py	Fri Jul 02 09:32:41 2004 +0000
    11.3 @@ -174,9 +174,9 @@ class VirqChannel(BaseChannel):
    11.4          """Close the channel. Calls lostChannel(self) on all its clients and
    11.5          channelClosed() on the factory.
    11.6          """
    11.7 -        for c in self.clients:
    11.8 +        for c in self.clients[:]:
    11.9              c.lostChannel(self)
   11.10 -        del self.clients
   11.11 +        self.clients = []
   11.12          BaseChannel.close(self)
   11.13  
   11.14      def registerClient(self, client):
   11.15 @@ -238,7 +238,7 @@ class Channel(BaseChannel):
   11.16          """
   11.17          if self.closed: return
   11.18          self.closed = 1
   11.19 -        for d in self.devs:
   11.20 +        for d in self.devs[:]:
   11.21              d.lostChannel()
   11.22          self.factory.channelClosed(self)
   11.23          self.devs = []
    12.1 --- a/tools/python/xen/xend/server/console.py	Fri Jul 02 09:32:06 2004 +0000
    12.2 +++ b/tools/python/xen/xend/server/console.py	Fri Jul 02 09:32:41 2004 +0000
    12.3 @@ -93,10 +93,15 @@ class ConsoleController(controller.Contr
    12.4      output and the connected TCP sockets to post console input.
    12.5      """
    12.6  
    12.7 +    STATUS_NEW       = 'new'
    12.8 +    STATUS_CLOSED    = 'closed'
    12.9 +    STATUS_CONNECTED = 'connected'
   12.10 +    STATUS_LISTENING = 'listening'
   12.11 +
   12.12      def __init__(self, factory, dom, console_port):
   12.13          controller.Controller.__init__(self, factory, dom)
   12.14          self.majorTypes = [ CMSG_CONSOLE ]
   12.15 -        self.status = "new"
   12.16 +        self.status = self.STATUS_NEW
   12.17          self.addr = None
   12.18          self.conn = None
   12.19          self.rbuf = xu.buffer()
   12.20 @@ -123,28 +128,31 @@ class ConsoleController(controller.Contr
   12.21          return not (self.closed() or self.rbuf.empty())
   12.22  
   12.23      def closed(self):
   12.24 -        return self.status == 'closed'
   12.25 +        return self.status == self.STATUS_CLOSED
   12.26  
   12.27      def connected(self):
   12.28 -        return self.status == 'connected'
   12.29 +        return self.status == self.STATUS_CONNECTED
   12.30  
   12.31      def close(self):
   12.32 -        try:
   12.33 -            self.status = "closed"
   12.34 -            if self.conn:
   12.35 -                self.conn.loseConnection()
   12.36 -            self.listener.stopListening()
   12.37 -            self.deregisterChannel()
   12.38 -            self.lostChannel()
   12.39 -        except Exception, ex:
   12.40 -            print 'ConsoleController>close>', ex
   12.41 -            raise
   12.42 +        """Close the console controller.
   12.43 +        """
   12.44 +        self.lostChannel()
   12.45 +
   12.46 +    def lostChannel(self):
   12.47 +        """The channel to the domain has been lost.
   12.48 +        Cleanup: disconnect TCP connections and listeners, notify the controller.
   12.49 +        """
   12.50 +        self.status = self.STATUS_CLOSED
   12.51 +        if self.conn:
   12.52 +            self.conn.loseConnection()
   12.53 +        self.listener.stopListening()
   12.54 +        controller.Controller.lostChannel(self)
   12.55  
   12.56      def listen(self):
   12.57          """Listen for TCP connections to the console port..
   12.58          """
   12.59          if self.closed(): return
   12.60 -        self.status = "listening"
   12.61 +        self.status = self.STATUS_LISTENING
   12.62          if self.listener:
   12.63              #self.listener.startListening()
   12.64              pass
   12.65 @@ -153,15 +161,25 @@ class ConsoleController(controller.Contr
   12.66              self.listener = reactor.listenTCP(self.console_port, f)
   12.67  
   12.68      def connect(self, addr, conn):
   12.69 +        """Connect a TCP connection to the console.
   12.70 +        Fails if closed or already connected.
   12.71 +
   12.72 +        addr peer address
   12.73 +        conn connection
   12.74 +
   12.75 +        returns 0 if ok, negative otherwise
   12.76 +        """
   12.77          if self.closed(): return -1
   12.78          if self.connected(): return -1
   12.79          self.addr = addr
   12.80          self.conn = conn
   12.81 -        self.status = "connected"
   12.82 +        self.status = self.STATUS_CONNECTED
   12.83          self.handleOutput()
   12.84          return 0
   12.85  
   12.86      def disconnect(self):
   12.87 +        """Disconnect the TCP connection to the console.
   12.88 +        """
   12.89          if self.conn:
   12.90              self.conn.loseConnection()
   12.91          self.addr = None
   12.92 @@ -169,15 +187,29 @@ class ConsoleController(controller.Contr
   12.93          self.listen()
   12.94  
   12.95      def requestReceived(self, msg, type, subtype):
   12.96 +        """Receive console data from the console channel.
   12.97 +
   12.98 +        msg     console message
   12.99 +        type    major message type
  12.100 +        subtype minor message typ
  12.101 +        """
  12.102          self.rbuf.write(msg.get_payload())
  12.103          self.handleOutput()
  12.104          
  12.105      def responseReceived(self, msg, type, subtype):
  12.106 -        # Just ignore responses.
  12.107 +        """Handle a response to a request written to the console channel.
  12.108 +        Just ignore it because the return values are not interesting.
  12.109 +
  12.110 +        msg     console message
  12.111 +        type    major message type
  12.112 +        subtype minor message typ
  12.113 +        """
  12.114          pass
  12.115  
  12.116      def produceRequests(self):
  12.117 -        # Send as much pending console data as there is room for.
  12.118 +        """Write pending console data to the console channel.
  12.119 +        Writes as much to the channel as it can.
  12.120 +        """
  12.121          work = 0
  12.122          while not self.wbuf.empty() and self.channel.writeReady():
  12.123              msg = xu.message(CMSG_CONSOLE, 0, 0)
  12.124 @@ -187,7 +219,12 @@ class ConsoleController(controller.Contr
  12.125  
  12.126      def handleInput(self, conn, data):
  12.127          """Handle some external input aimed at the console.
  12.128 -        Called from a TCP connection (conn).
  12.129 +        Called from a TCP connection (conn). Ignores the input
  12.130 +        if the calling connection (conn) is not the one connected
  12.131 +        to the console (self.conn).
  12.132 +
  12.133 +        conn connection
  12.134 +        data input data
  12.135          """
  12.136          if self.closed(): return -1
  12.137          if conn != self.conn: return 0
    13.1 --- a/tools/python/xen/xend/server/controller.py	Fri Jul 02 09:32:06 2004 +0000
    13.2 +++ b/tools/python/xen/xend/server/controller.py	Fri Jul 02 09:32:41 2004 +0000
    13.3 @@ -205,12 +205,12 @@ class Controller(CtrlMsgRcvr):
    13.4      def close(self):
    13.5          """Close the controller.
    13.6          """
    13.7 -        self.deregisterChannel()
    13.8          self.lostChannel()
    13.9  
   13.10      def lostChannel(self):
   13.11          """The controller channel has been lost.
   13.12          """
   13.13 +        self.deregisterChannel()
   13.14          self.factory.instanceClosed(self)
   13.15  
   13.16  class Dev:
    14.1 --- a/tools/python/xen/xend/server/netif.py	Fri Jul 02 09:32:06 2004 +0000
    14.2 +++ b/tools/python/xen/xend/server/netif.py	Fri Jul 02 09:32:41 2004 +0000
    14.3 @@ -198,8 +198,9 @@ class NetifController(controller.Control
    14.4      def randomMAC(self):
    14.5          """Generate a random MAC address.
    14.6  
    14.7 -        The OUI (Organisation Unique Identifier) used is AA:00:00, which
    14.8 -        is a currently unassigned one that used to belong to DEC.
    14.9 +        Uses OUI (Organizationally Unique Identifier) AA:00:00, an
   14.10 +        unassigned one that used to belong to DEC. The OUI list is
   14.11 +        available at 'standards.ieee.org'.
   14.12  
   14.13          The remaining 3 fields are random, with the first bit of the first
   14.14          random field set 0.