From: "Yu, Ping Y" Subject: [PATCH]make "xm console" will not block VMX booting Date: Fri, 20 Jan 2006 10:28:35 +0800 Message-ID: <2BF508F394C196468CCBEC031320DCDF384667@pdsmsx405> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Return-path: Content-class: urn:content-classes:message List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org There is a known "xm console" issue related with VMX. When "serial" is enabled=20 in script and no once uses "xm console" to read the console, VMX boting will hang=20 due to the buffer is full. I added a "select" before "write". If it could not be written, unix_write will=20 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 diff -r 6ce7c026320e tools/examples/xmexample.vmx --- a/tools/examples/xmexample.vmx Mon Jan 16 23:54:24 2006 +++ b/tools/examples/xmexample.vmx Wed Jan 18 16:23:10 2006 @@ -132,7 +132,7 @@ =20 #----------------------------------------------------------------------- ------ # serial port re-direct to pty deivce, /dev/pts/n=20 # then xm console or minicom can connect -#serial=3D'pty' +serial=3D'pty' =20 =20 #----------------------------------------------------------------------- ----- # enable ne2000, default =3D 0(use pcnet) diff -r 6ce7c026320e tools/ioemu/vl.c --- a/tools/ioemu/vl.c Mon Jan 16 23:54:24 2006 +++ b/tools/ioemu/vl.c Wed Jan 18 16:23:10 2006 @@ -957,19 +957,34 @@ =20 static int unix_write(int fd, const uint8_t *buf, int len1) { - int ret, len; + int ret,sel_ret,len; + int max_fd; + fd_set writefds; + struct timeval timeout; + + max_fd =3D fd; =20 =20 len =3D len1; while (len > 0) { - ret =3D write(fd, buf, len); - if (ret < 0) { - if (errno !=3D EINTR && errno !=3D EAGAIN) - return -1; - } else if (ret =3D=3D 0) { - break; - } else { - buf +=3D ret; - len -=3D ret; + FD_ZERO(&writefds); + FD_SET(fd, &writefds); + timeout.tv_sec =3D 0; + timeout.tv_usec =3D 0; + sel_ret =3D select(max_fd + 1, NULL, &writefds, 0, &timeout); + if (sel_ret <=3D 0) { + /* Timeout or select error */ + return -1; + } else { + ret =3D write(fd, buf, len); + if (ret < 0) { + if (errno !=3D EINTR && errno !=3D EAGAIN) + return -1; + } else if (ret =3D=3D 0) { + break; + } else { + buf +=3D ret; + len -=3D ret; + } } } return len1 - len; Ping