From: Shahar Havivi <shaharh@redhat.com>
To: "David S. Ahern" <daahern@cisco.com>
Cc: Dor Laor <dlaor@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] terminal attributes is not restored when using /dev/tty monitor
Date: Sat, 20 Feb 2010 18:59:36 +0200 [thread overview]
Message-ID: <20100220165935.GA9999@redhat.com> (raw)
In-Reply-To: <4B7FFD5E.7010704@cisco.com>
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" <daahern@cisco.com>
> To: Shahar Havivi <shaharh@redhat.com>
> CC: qemu-devel@nongnu.org, Dor Laor <dlaor@redhat.com>
> 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 <shaharh@redhat.com>
> > ---
> > 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__ */
next prev parent reply other threads:[~2010-02-20 16:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-20 8:30 [Qemu-devel] [PATCH] terminal attributes is not restored when using /dev/tty monitor Shahar Havivi
2010-02-20 15:18 ` David S. Ahern
2010-02-20 16:59 ` Shahar Havivi [this message]
2010-02-20 17:03 ` Anthony Liguori
2010-02-20 19:42 ` Shahar Havivi
2010-02-21 14:32 ` David S. Ahern
2010-02-21 15:06 ` Shahar Havivi
2010-02-21 14:26 ` David S. Ahern
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=20100220165935.GA9999@redhat.com \
--to=shaharh@redhat.com \
--cc=daahern@cisco.com \
--cc=dlaor@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.