From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NjCmp-0007CD-FR for qemu-devel@nongnu.org; Sun, 21 Feb 2010 09:27:55 -0500 Received: from [199.232.76.173] (port=52002 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjCmp-0007C5-3j for qemu-devel@nongnu.org; Sun, 21 Feb 2010 09:27:55 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NjCmn-0000iM-Ik for qemu-devel@nongnu.org; Sun, 21 Feb 2010 09:27:54 -0500 Received: from mx20.gnu.org ([199.232.41.8]:7400) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NjCmm-0000ea-Iy for qemu-devel@nongnu.org; Sun, 21 Feb 2010 09:27:53 -0500 Received: from sj-iport-5.cisco.com ([171.68.10.87]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NjCmX-00084c-1a for qemu-devel@nongnu.org; Sun, 21 Feb 2010 09:27:37 -0500 Message-ID: <4B814285.5000309@cisco.com> Date: Sun, 21 Feb 2010 07:26:13 -0700 From: "David S. Ahern" MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] terminal attributes is not restored when using /dev/tty monitor References: <20100220083052.GA3582@redhat.com> <4B7FFD5E.7010704@cisco.com> <4B8015ED.4030300@codemonkey.ws> In-Reply-To: <4B8015ED.4030300@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Dor Laor , Shahar Havivi , qemu-devel@nongnu.org On 02/20/2010 10:03 AM, Anthony Liguori wrote: > On 02/20/2010 09:18 AM, David S. Ahern wrote: >> On 02/20/2010 01:30 AM, Shahar Havivi wrote: >> >>> when exiting qemu that run with "-monitor /dev/tty", the launching >>> terminal get weird behaviour because no restore terminals action has >>> taken. >>> added chr_close and register atexit() code for tty devices (like stdio >>> does) >>> >>> Signed-off-by: Shahar Havivi >>> --- >>> qemu-char.c | 14 ++++++++++++++ >>> 1 files changed, 14 insertions(+), 0 deletions(-) >>> >>> diff --git a/qemu-char.c b/qemu-char.c >>> index 75dbf66..de16883 100644 >>> --- a/qemu-char.c >>> +++ b/qemu-char.c >>> @@ -1002,6 +1002,7 @@ static void tty_serial_init(int fd, int speed, >>> speed, parity, data_bits, stop_bits); >>> #endif >>> tcgetattr (fd,&tty); >>> + oldtty = tty; >>> >>> #define check_speed(val) if (speed<= val) { spd = B##val; break; } >>> speed = speed * 10 / 11; >>> @@ -1173,6 +1174,17 @@ static int tty_serial_ioctl(CharDriverState >>> *chr, int cmd, void *arg) >>> return 0; >>> } >>> >>> +static void tty_exit(void) >>> +{ >>> + tcsetattr(0, TCSANOW,&oldtty); >>> +} >>> + >>> +static void qemu_chr_close_tty(struct CharDriverState *chr) >>> +{ >>> + tty_exit(); >>> + fd_chr_close(chr); >>> +} >>> >> >> The close callback needs to close the fd for the device as well. I have >> sent a patch to handle this; waiting for it to be included: >> >> http://permalink.gmane.org/gmane.comp.emulators.qemu/63472 >> > > It didn't apply with git-am. I'm not sure why, am investigating now. > > Regards, > > Anthony Liguori > Are you referring to my patch? I'm still learning the git commands, so maybe I messed something up. I used git format-patch followed git send-mail. If I save the email (Thunderbird client, saving the copy I received of what I sent using git send-mail), strip out the mail headers and use patch it applies fine - but with the warning "(Stripping trailing CRs from patch.)" David