Skip to content

feat(console): redirect the guest console to a PTY - #548

Merged
Lencerf merged 1 commit into
google:mainfrom
Lencerf:feat/console-pty
Nov 11, 2026
Merged

Lencerf merged 1 commit into
google:mainfrom
Lencerf:feat/console-pty

Conversation

@Lencerf

@Lencerf Lencerf commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

--console pty connects the guest console to a pseudo-terminal, so a user can attach to it from another terminal, e.g. screen /dev/pts/7. The slave path is logged, and link=<path> creates a symbolic link to it at a stable path.

The VMM keeps the slave open itself. Otherwise, on Linux, the master hangs up when the last client closes the slave, and reads fail with EIO.

Writes from the guest never block. When the PTY buffer is full, the oldest output that nobody has read is dropped, so a client attaching late sees the newest output, e.g. the shell prompt. To do so, the VMM discards the unread output with tcflush() and writes back the newest 512 bytes, which it keeps in a small buffer.

`--console pty` connects the guest console to a pseudo-terminal, so a
user can attach to it from another terminal, e.g. `screen /dev/pts/7`.
The slave path is logged, and `link=<path>` creates a symbolic link to
it at a stable path.

The VMM keeps the slave open itself. Otherwise, on Linux, the master
hangs up when the last client closes the slave, and reads fail with
EIO.

Writes from the guest never block. When the PTY buffer is full, the
oldest output that nobody has read is dropped, so a client attaching
late sees the newest output, e.g. the shell prompt. To do so, the VMM
discards the unread output with tcflush() and writes back the newest
512 bytes, which it keeps in a small buffer.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
@Lencerf
Lencerf enabled auto-merge November 11, 2026 19:10
@Lencerf
Lencerf added this pull request to the merge queue Nov 11, 2026
Merged via the queue into google:main with commit 0b7e974 Nov 11, 2026
15 of 20 checks passed
@Lencerf
Lencerf deleted the feat/console-pty branch November 11, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant