ia64/xen-unstable

changeset 8741:da6297243495

There is a known "xm console" issue related with VMX. When "serial" is
enabled in script and no once uses "xm console" to read the console,
VMX boting will hang due to the buffer is full.
I added a "select" before "write". If it could not be written,
unix_write will Return immediately and it will not block the VMX
booting. With this fix, we can make VMX's serial enable by default.

Signed-off-by: Yu Ping <ping.y.yu@intel.com>

Modified to patch xmexample.hvm. Put through xenrt on a VMX box.

Signed-off-by: James Bulpin <james@xensource.com>
author jrb44@plym.cl.cam.ac.uk
date Thu Feb 02 19:15:22 2006 +0100 (2006-02-02)
parents 3d7ea7972b39
children 2494b4e00cbb
files tools/examples/xmexample.hvm tools/ioemu/vl.c
line diff
     1.1 --- a/tools/examples/xmexample.hvm	Thu Feb 02 17:16:00 2006 +0000
     1.2 +++ b/tools/examples/xmexample.hvm	Thu Feb 02 19:15:22 2006 +0100
     1.3 @@ -130,7 +130,7 @@ vncviewer=1
     1.4  #-----------------------------------------------------------------------------
     1.5  #   serial port re-direct to pty deivce, /dev/pts/n 
     1.6  #   then xm console or minicom can connect
     1.7 -#serial='pty'
     1.8 +serial='pty'
     1.9  
    1.10  #----------------------------------------------------------------------------
    1.11  # enable ne2000, default = 0(use pcnet)
     2.1 --- a/tools/ioemu/vl.c	Thu Feb 02 17:16:00 2006 +0000
     2.2 +++ b/tools/ioemu/vl.c	Thu Feb 02 19:15:22 2006 +0100
     2.3 @@ -957,19 +957,34 @@ static CharDriverState *stdio_clients[ST
     2.4  
     2.5  static int unix_write(int fd, const uint8_t *buf, int len1)
     2.6  {
     2.7 -    int ret, len;
     2.8 +    int ret,sel_ret,len;
     2.9 +    int max_fd;
    2.10 +    fd_set writefds;
    2.11 +    struct timeval timeout;
    2.12 +
    2.13 +    max_fd = fd;  
    2.14  
    2.15      len = len1;
    2.16      while (len > 0) {
    2.17 -        ret = write(fd, buf, len);
    2.18 -        if (ret < 0) {
    2.19 -            if (errno != EINTR && errno != EAGAIN)
    2.20 -                return -1;
    2.21 -        } else if (ret == 0) {
    2.22 -            break;
    2.23 -        } else {
    2.24 -            buf += ret;
    2.25 -            len -= ret;
    2.26 +        FD_ZERO(&writefds);
    2.27 +        FD_SET(fd, &writefds);
    2.28 +	timeout.tv_sec = 0;
    2.29 +	timeout.tv_usec = 0;
    2.30 +	sel_ret = select(max_fd + 1, NULL, &writefds, 0, &timeout);
    2.31 +	if (sel_ret <= 0) {
    2.32 +		/* Timeout or select error */
    2.33 +            return -1;
    2.34 +	} else {
    2.35 +            ret = write(fd, buf, len);
    2.36 +            if (ret < 0) {
    2.37 +                if (errno != EINTR && errno != EAGAIN)
    2.38 +                    return -1;
    2.39 +            } else if (ret == 0) {
    2.40 +            	    break;
    2.41 +            } else {
    2.42 +            	    buf += ret;
    2.43 +                    len -= ret;
    2.44 +            }
    2.45          }
    2.46      }
    2.47      return len1 - len;