ia64/xen-unstable

changeset 1193:afe38e38642a

bitkeeper revision 1.807 (4058872eScocwS_6SkwoZWFMzDk9Nw)

utils.c, control_if.h:
Move shared controller-interface definitions out of the xenolinux tree.
console_client.py:
Fix console client.
control_if.h:
bk cp xenolinux-2.4.25-sparse/include/asm-xeno/control_if.h tools/xend/lib/control_if.h
Rewritten the Xen control daemon in Python, with C extensions for the low-level bits. All our Python libraries now throw exceptions on error rather than returning error codes --- this will require our higher-level scripts to be updated at some point.
new file
author kaf24@scramble.cl.cam.ac.uk
date Wed Mar 17 17:13:18 2004 +0000 (2004-03-17)
parents 0c707d7680c9
children 814cfcf225c4
files .rootkeys tools/xenctl/lib/console_client.py tools/xend/lib/control_if.h tools/xend/lib/utils.c tools/xend/setup.py
line diff
     1.1 --- a/.rootkeys	Wed Mar 17 13:49:15 2004 +0000
     1.2 +++ b/.rootkeys	Wed Mar 17 17:13:18 2004 +0000
     1.3 @@ -96,6 +96,7 @@ 4055ee44Bu6oP7U0WxxXypbUt4dNPQ tools/xen
     1.4  40431ac64Hj4ixUnKmlugZKhXPFE_Q tools/xend/Makefile
     1.5  4055ad95Se-FqttgxollqOAAHB94zA tools/xend/lib/__init__.py
     1.6  4055ad97wMLUj0BZT0e_T0EwQN0Bvw tools/xend/lib/console.py
     1.7 +4048c0ddsF0WrU7HUzTvg1MJoCIfWg tools/xend/lib/control_if.h
     1.8  4054a301VEag2GwrBrFBna5U1BGlLA tools/xend/lib/main.py
     1.9  4055ad9ah9IuC3sJT2c_gYIFY5Tw_g tools/xend/lib/manager.py
    1.10  40431ac8wrUEj-XM7B8smFtx_HA7lQ tools/xend/lib/utils.c
     2.1 --- a/tools/xenctl/lib/console_client.py	Wed Mar 17 13:49:15 2004 +0000
     2.2 +++ b/tools/xenctl/lib/console_client.py	Wed Mar 17 17:13:18 2004 +0000
     2.3 @@ -5,7 +5,17 @@
     2.4  # Copyright (c) 2004, K A Fraser
     2.5  ##############################################
     2.6  
     2.7 -import errno, os, signal, socket, struct, sys, termios
     2.8 +import errno, os, signal, socket, struct, sys
     2.9 +
    2.10 +from termios import *
    2.11 +# Indexes into termios.tcgetattr() list.
    2.12 +IFLAG  = 0
    2.13 +OFLAG  = 1
    2.14 +CFLAG  = 2
    2.15 +LFLAG  = 3
    2.16 +ISPEED = 4
    2.17 +OSPEED = 5
    2.18 +CC     = 6
    2.19  
    2.20  def __child_death(signum, frame):
    2.21      global stop
    2.22 @@ -14,7 +24,6 @@ def __child_death(signum, frame):
    2.23  def __recv_from_sock(sock):
    2.24      global stop
    2.25      stop = False
    2.26 -    print "************ REMOTE CONSOLE: CTRL-] TO QUIT ********"
    2.27      while not stop:
    2.28          try:
    2.29              data = sock.recv(1)
    2.30 @@ -22,8 +31,6 @@ def __recv_from_sock(sock):
    2.31          except socket.error, error:
    2.32              if error[0] != errno.EINTR:
    2.33                  raise
    2.34 -    print
    2.35 -    print "************ REMOTE CONSOLE EXITED *****************"
    2.36      os.wait()
    2.37  
    2.38  def __send_to_sock(sock):
    2.39 @@ -41,21 +48,28 @@ def connect(host,port):
    2.40                      struct.pack('ii', 0, 0))
    2.41      sock.connect((host,port))
    2.42  
    2.43 -    oattrs = termios.tcgetattr(0)
    2.44 -    nattrs = termios.tcgetattr(0)
    2.45 -    nattrs[3] = nattrs[3] & ~(termios.ECHO | termios.ICANON)
    2.46 -    nattrs[6][termios.VMIN] = 1
    2.47 -    nattrs[6][termios.VTIME] = 0
    2.48 -    termios.tcsetattr(0, termios.TCSAFLUSH, nattrs)
    2.49 +    oattrs = tcgetattr(0)
    2.50 +    nattrs = tcgetattr(0)
    2.51 +    nattrs[IFLAG] = nattrs[IFLAG] & ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON)
    2.52 +    nattrs[OFLAG] = nattrs[OFLAG] & ~(OPOST)
    2.53 +    nattrs[CFLAG] = nattrs[CFLAG] & ~(CSIZE | PARENB)
    2.54 +    nattrs[CFLAG] = nattrs[CFLAG] | CS8
    2.55 +    nattrs[LFLAG] = nattrs[LFLAG] & ~(ECHO | ICANON | IEXTEN | ISIG)
    2.56 +    nattrs[CC][VMIN] = 1
    2.57 +    nattrs[CC][VTIME] = 0
    2.58  
    2.59 -    try:
    2.60 -        if os.fork():
    2.61 -            signal.signal(signal.SIGCHLD, __child_death)
    2.62 +    if os.fork():
    2.63 +        signal.signal(signal.SIGCHLD, __child_death)
    2.64 +        print "************ REMOTE CONSOLE: CTRL-] TO QUIT ********"
    2.65 +        tcsetattr(0, TCSAFLUSH, nattrs)
    2.66 +        try:
    2.67              __recv_from_sock(sock)
    2.68 -        else:
    2.69 -            __send_to_sock(sock)
    2.70 -    finally:
    2.71 -        termios.tcsetattr(0, termios.TCSAFLUSH, oattrs)
    2.72 +        finally:
    2.73 +            tcsetattr(0, TCSAFLUSH, oattrs)
    2.74 +            print
    2.75 +            print "************ REMOTE CONSOLE EXITED *****************"
    2.76 +    else:
    2.77 +        __send_to_sock(sock)
    2.78  
    2.79  if __name__ == '__main__':
    2.80      connect(str(sys.argv[1]),int(sys.argv[2]))
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/xend/lib/control_if.h	Wed Mar 17 17:13:18 2004 +0000
     3.3 @@ -0,0 +1,35 @@
     3.4 +/******************************************************************************
     3.5 + * control_if.h
     3.6 + * 
     3.7 + * Interface to server controller (e.g., 'xend'). This header file defines the 
     3.8 + * interface that is shared with guest OSes.
     3.9 + * 
    3.10 + * Copyright (c) 2004, K A Fraser
    3.11 + */
    3.12 +
    3.13 +#ifndef __CONTROL_IF_H__
    3.14 +#define __CONTROL_IF_H__
    3.15 +
    3.16 +typedef struct {
    3.17 +    u8 type;     /* echoed in response */
    3.18 +    u8 subtype;  /* echoed in response */
    3.19 +    u8 id;       /* echoed in response */
    3.20 +    u8 length;   /* number of bytes in 'msg' */
    3.21 +    unsigned char msg[60]; /* type-specific message data */
    3.22 +} control_msg_t;
    3.23 +
    3.24 +#define CONTROL_RING_SIZE 8
    3.25 +typedef unsigned int CONTROL_RING_IDX;
    3.26 +#define MASK_CONTROL_IDX(_i) ((_i)&(CONTROL_RING_SIZE-1))
    3.27 +
    3.28 +typedef struct {
    3.29 +    control_msg_t tx_ring[CONTROL_RING_SIZE]; /* guest-OS -> controller */
    3.30 +    control_msg_t rx_ring[CONTROL_RING_SIZE]; /* controller -> guest-OS */
    3.31 +    CONTROL_RING_IDX tx_req_prod, tx_resp_prod;
    3.32 +    CONTROL_RING_IDX rx_req_prod, rx_resp_prod;
    3.33 +} control_if_t;
    3.34 +
    3.35 +#define CMSG_CONSOLE      0
    3.36 +#define CMSG_CONSOLE_DATA 0
    3.37 +
    3.38 +#endif /* __CONTROL_IF_H__ */
     4.1 --- a/tools/xend/lib/utils.c	Wed Mar 17 13:49:15 2004 +0000
     4.2 +++ b/tools/xend/lib/utils.c	Wed Mar 17 17:13:18 2004 +0000
     4.3 @@ -21,7 +21,7 @@
     4.4  #include <errno.h>
     4.5  #include <signal.h>
     4.6  #include <xc.h>
     4.7 -#include <asm-xeno/control_if.h>
     4.8 +#include "control_if.h"
     4.9  
    4.10  /* Needed for Python versions earlier than 2.3. */
    4.11  #ifndef PyMODINIT_FUNC
     5.1 --- a/tools/xend/setup.py	Wed Mar 17 13:49:15 2004 +0000
     5.2 +++ b/tools/xend/setup.py	Wed Mar 17 17:13:18 2004 +0000
     5.3 @@ -2,8 +2,7 @@
     5.4  from distutils.core import setup, Extension
     5.5  
     5.6  utils = Extension("utils",
     5.7 -                  include_dirs         = ["../xc/lib",
     5.8 -                                          "../../xenolinux-sparse/include"],
     5.9 +                  include_dirs         = ["../xc/lib"],
    5.10                    library_dirs         = ["../xc/lib"],
    5.11                    libraries            = ["xc"],
    5.12                    sources              = ["lib/utils.c"])