From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JsR2J-0002Th-Mi for qemu-devel@nongnu.org; Sat, 03 May 2008 19:20:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JsR2I-0002Rw-G2 for qemu-devel@nongnu.org; Sat, 03 May 2008 19:20:59 -0400 Received: from [199.232.76.173] (port=34837 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JsR2I-0002Rn-E7 for qemu-devel@nongnu.org; Sat, 03 May 2008 19:20:58 -0400 Received: from mtaout03-winn.ispmail.ntl.com ([81.103.221.49]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JsR2I-0006Cm-5K for qemu-devel@nongnu.org; Sat, 03 May 2008 19:20:58 -0400 Date: Sun, 4 May 2008 00:20:47 +0100 From: Samuel Thibault Subject: Re: [Qemu-devel] PATCH: Put Psuedo-TTY in rawmode for char devices Message-ID: <20080503232047.GM8032@implementation> References: <20080422005057.GD3649@redhat.com> <20080501171424.GF21335@redhat.com> <20080503230850.GA6745@volta.aurel32.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Qbvjkv9qwOGw/5Fx" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20080503230850.GA6745@volta.aurel32.net> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --Qbvjkv9qwOGw/5Fx Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Aurelien Jarno, le Sun 04 May 2008 01:08:50 +0200, a écrit : > On Thu, May 01, 2008 at 06:14:24PM +0100, Daniel P. Berrange wrote: > > Re-posting patch for review/inclusion... > > > > On Tue, Apr 22, 2008 at 01:50:57AM +0100, Daniel P. Berrange wrote: > > > If running a QEMU instance with a serial/parallel device connected to a > > > Psuedo-TTY, eg '-serial pty', every \r\n sequence output by the guest > > > is getting translated into a \n\n sequence by the TTY layer. So clients > > > interacting with the serial port via a TTY done get the correct \r\n > > > sequence and text marches to the right and wraps. This is because the > > > TTY is not put into rawmode when QEMU sets it up. > > > > > > The following patch is a re-diff of a patch applied to Xen's QEMU code. > > > It uses cfmakeraw() to ensure the TTY is put into rawmode, thus avoiding > > > the incorrect \r\n translations. It also switches to tcsetattr() on the > > > slave_fd instead of master_fd - although this is effectively the same on > > > Linux, only slave_fd works on Solaris. Finally it stops using the 'name' > > > arg to openpty() which is a security risk because its buffer size is > > > undefined. Instead it makes use of the ptsname() function. > > > > cfmakeraw() is Linux specific, though also available on most BSD > systems. It is unavailable on Solaris, and probably the same on WIN32. Indeed, in Xen we keep a local definition of cfmakeraw for the solaris case. That being said, the same lines as term_init could be added, see attached patch. Samuel --Qbvjkv9qwOGw/5Fx Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename=patch Content-Transfer-Encoding: 8bit Index: vl.c =================================================================== --- vl.c (r�vision 4294) +++ vl.c (copie de travail) @@ -2285,7 +2285,11 @@ /* Disabling local echo and line-buffered output */ tcgetattr (master_fd, &tty); - tty.c_lflag &= ~(ECHO|ICANON|ISIG); + tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP + |INLCR|IGNCR|ICRNL|IXON); + tty.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); + tty.c_cflag &= ~(CSIZE|PARENB); + tty.c_cflag |= CS8; tty.c_cc[VMIN] = 1; tty.c_cc[VTIME] = 0; tcsetattr (master_fd, TCSAFLUSH, &tty); --Qbvjkv9qwOGw/5Fx--