qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] terminal attributes is not restored when using


From: Shahar Havivi
Subject: Re: [Qemu-devel] [PATCH] terminal attributes is not restored when using /dev/tty monitor
Date: Sat, 20 Feb 2010 18:59:36 +0200
User-agent: Mutt/1.5.20 (2009-08-17)

On Sat, Feb 20, 2010 at 08:18:54AM -0700, David S. Ahern wrote:
> Date: Sat, 20 Feb 2010 08:18:54 -0700
> From: "David S. Ahern" <address@hidden>
> To: Shahar Havivi <address@hidden>
> CC: address@hidden, Dor Laor <address@hidden>
> Subject: Re: [Qemu-devel] [PATCH] terminal attributes is not restored when
>  using /dev/tty monitor
> 
> 
> 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 <address@hidden>
> > ---
> >  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
> 
> David
Sure you right about the fd but the chr->chr_close not called all the
time that is why I added the atexit() call, and the restore tty flags.
Shaahr.
> 
> 
> > +
> >  static CharDriverState *qemu_chr_open_tty(QemuOpts *opts)
> >  {
> >      const char *filename = qemu_opt_get(opts, "path");
> > @@ -1190,6 +1202,8 @@ static CharDriverState *qemu_chr_open_tty(QemuOpts 
> > *opts)
> >          return NULL;
> >      }
> >      chr->chr_ioctl = tty_serial_ioctl;
> > +    chr->chr_close = qemu_chr_close_tty;
> > +    atexit(tty_exit);
> >      return chr;
> >  }
> >  #else  /* ! __linux__ && ! __sun__ */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]