qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] PATCH: Put Psuedo-TTY in rawmode for char devices
Date: Sun, 4 May 2008 00:20:47 +0100	[thread overview]
Message-ID: <20080503232047.GM8032@implementation> (raw)
In-Reply-To: <20080503230850.GA6745@volta.aurel32.net>

[-- Attachment #1: Type: text/plain, Size: 1552 bytes --]

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

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 608 bytes --]

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);

  reply	other threads:[~2008-05-03 23:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-22  0:50 [Qemu-devel] PATCH: Put Psuedo-TTY in rawmode for char devices Daniel P. Berrange
2008-05-01 17:14 ` Daniel P. Berrange
2008-05-03 23:08   ` Aurelien Jarno
2008-05-03 23:20     ` Samuel Thibault [this message]
2008-05-04 18:20     ` Daniel P. Berrange
2008-05-04 18:33       ` Samuel Thibault
2008-05-04 21:10         ` Daniel P. Berrange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080503232047.GM8032@implementation \
    --to=samuel.thibault@ens-lyon.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).