From: Peter Hurley <peter@hurleysoftware.com>
To: Nan Li <nli@suse.com>
Cc: gregkh@linuxfoundation.org, jslaby@suse.cz,
linux-kernel@vger.kernel.org, ptesarik@suse.cz
Subject: Re: [PATCH 1/1] pty: BREAK for pseudoterminals
Date: Tue, 17 Feb 2015 14:03:58 -0500 [thread overview]
Message-ID: <54E3909E.30203@hurleysoftware.com> (raw)
In-Reply-To: <54E1EAC2.6020906@hurleysoftware.com>
On 02/16/2015 08:04 AM, Peter Hurley wrote:
> On 02/05/2015 02:11 PM, Nan Li wrote:
>> This will greatly enhance the usefulness of QEMU virtual serial ports, because the Linux kernel interprets a break on the serial console as a SysRq, but there is currently no way to pass this signal over a pseudo-terminal. This patch will work for transmitting BREAK from master to slave through pseudo-terminal.
>
> pty is an IPC mechanism, not a virtualization driver.
>
> Those programs that know they're consuming from a slave pty may not
> have bothered to set termios for BREAKs, and may not be prepared
> for NULLs in the input stream.
I'm not even seeing how this works as advertised.
In QEMU, the *master* end is the source/sink for the guest VM, while the
*slave* pty is sink/source for the host. Like this:
Host <--> slave pty <===> master pty <--> qemu <==> emulated serial port
So this patch enables the guest VM to transmit BREAK to the host.
Why is that useful?
Regards,
Peter Hurley
>> Signed-off-by: Nan Li <nli@suse.com>
>> ---
>> drivers/tty/pty.c | 19 +++++++++++++++++++
>> 1 file changed, 19 insertions(+)
>>
>> diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
>> index e72ee62..ac8893a 100644
>> --- a/drivers/tty/pty.c
>> +++ b/drivers/tty/pty.c
>> @@ -31,6 +31,7 @@
>> static struct tty_driver *ptm_driver;
>> static struct tty_driver *pts_driver;
>> static DEFINE_MUTEX(devpts_mutex);
>> +#define BREAK_STRING '\0'
>> #endif
>>
>> static void pty_close(struct tty_struct *tty, struct file *filp)
>> @@ -674,6 +675,23 @@ static void pty_unix98_shutdown(struct tty_struct *tty)
>> devpts_kill_index(tty->driver_data, tty->index);
>> }
>>
>> +static int pty_unix98_break_ctl(struct tty_struct *tty, int break_state)
>> +{
>> + int c;
>> + struct tty_struct *to = tty->link;
>> +
>> + if (break_state) {
>> + /* Stuff the break data into the input queue of the other end */
>> + c = tty_insert_flip_char(to->port, BREAK_STRING, TTY_BREAK);
>> + /* And shovel */
>> + if (c)
>> + tty_flip_buffer_push(to->port);
>> + else
>> + return -ENOMEM;
>> + }
>> + return 0;
>> +}
>> +
>> static const struct tty_operations ptm_unix98_ops = {
>> .lookup = ptm_unix98_lookup,
>> .install = pty_unix98_install,
>> @@ -686,6 +704,7 @@ static const struct tty_operations ptm_unix98_ops = {
>> .chars_in_buffer = pty_chars_in_buffer,
>> .unthrottle = pty_unthrottle,
>> .ioctl = pty_unix98_ioctl,
>> + .break_ctl = pty_unix98_break_ctl,
>> .resize = pty_resize,
>> .shutdown = pty_unix98_shutdown,
>> .cleanup = pty_cleanup
>>
>
next prev parent reply other threads:[~2015-02-17 19:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-05 19:11 [PATCH 1/1] pty: BREAK for pseudoterminals Nan Li
2015-02-16 13:04 ` Peter Hurley
2015-02-16 13:22 ` Petr Tesarik
2015-02-16 16:24 ` Peter Hurley
2015-02-16 17:16 ` Petr Tesarik
2015-02-16 18:30 ` Peter Hurley
2015-02-16 19:01 ` Peter Hurley
2015-02-17 19:03 ` Peter Hurley [this message]
2015-02-18 7:05 ` Petr Tesarik
2015-02-23 10:53 ` One Thousand Gnomes
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=54E3909E.30203@hurleysoftware.com \
--to=peter@hurleysoftware.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=nli@suse.com \
--cc=ptesarik@suse.cz \
/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.