From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NjDOc-0000Tr-2T for qemu-devel@nongnu.org; Sun, 21 Feb 2010 10:06:58 -0500 Received: from [199.232.76.173] (port=46042 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjDOb-0000Th-NH for qemu-devel@nongnu.org; Sun, 21 Feb 2010 10:06:57 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NjDOZ-0002Gd-Tm for qemu-devel@nongnu.org; Sun, 21 Feb 2010 10:06:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52427) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NjDOZ-0002GP-GX for qemu-devel@nongnu.org; Sun, 21 Feb 2010 10:06:55 -0500 Date: Sun, 21 Feb 2010 17:06:30 +0200 From: Shahar Havivi Subject: Re: [Qemu-devel] [PATCH] terminal attributes is not restored when using /dev/tty monitor Message-ID: <20100221150629.GB21867@redhat.com> References: <20100220083052.GA3582@redhat.com> <4B7FFD5E.7010704@cisco.com> <4B8015ED.4030300@codemonkey.ws> <20100220194241.GA12328@redhat.com> <4B814409.8060004@cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4B814409.8060004@cisco.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "David S. Ahern" Cc: Dor Laor , qemu-devel@nongnu.org On Sun, Feb 21, 2010 at 07:32:41AM -0700, David S. Ahern wrote: > Date: Sun, 21 Feb 2010 07:32:41 -0700 > From: "David S. Ahern" > To: Shahar Havivi > CC: Anthony Liguori , Dor Laor , > qemu-devel@nongnu.org > Subject: Re: [Qemu-devel] [PATCH] terminal attributes is not restored when > using /dev/tty monitor > > > > On 02/20/2010 12:42 PM, Shahar Havivi wrote: > > On Sat, Feb 20, 2010 at 11:03:41AM -0600, Anthony Liguori wrote: > >> Date: Sat, 20 Feb 2010 11:03:41 -0600 > >> From: Anthony Liguori > >> To: "David S. Ahern" > >> Cc: Dor Laor , Shahar Havivi , > >> qemu-devel@nongnu.org > >> Subject: Re: [Qemu-devel] [PATCH] terminal attributes is not restored when > >> using /dev/tty monitor > >> > >> 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 > >> > > Note that the method fd_chr_close() is closing the fd_in, no need to the > > close logic again, and when opening a monitor with /dev/tty the > > chr->chr_close not called that is why you need to register with > > atexit(). (same as stdio monitor does). > > Shahar. > > I don't see that fd_chr_close() closes the fd; it only unregisters the > handler. > > David you right, my bad.