Skip to content

feat(openshell-vm): add tty support for exec#939

Open
benoitf wants to merge 1 commit intoNVIDIA:mainfrom
benoitf:openshell-936
Open

feat(openshell-vm): add tty support for exec#939
benoitf wants to merge 1 commit intoNVIDIA:mainfrom
benoitf:openshell-936

Conversation

@benoitf
Copy link
Copy Markdown
Contributor

@benoitf benoitf commented Apr 23, 2026

Summary

Add TTY support for openshell-vm exec, enabling interactive terminal sessions inside VMs.
Both the Rust host (client-side raw mode, terminal resize propagation) and the Python guest agent (PTY allocation, resize handling) are updated to support the new tty flag

openshell-exec-tty.mov

Related Issue

#936

Changes

  • Rust host (crates/openshell-vm/src/exec.rs):
    • Add Resize { cols, rows } variant to ClientFrame for terminal resize events
    • Add RawModeGuard RAII struct that switches stdin to raw mode and restores on drop
    • Add get_terminal_size() helper using TIOCGWINSZ ioctl
    • Send initial terminal size before starting the stdin pump when tty is enabled
    • Detect terminal resize changes during pump_stdin and forward Resize frames
    • Add comprehensive unit tests for frame serialization, deserialization, round-trip compatibility, env validation, and Python agent wire-format compatibility
  • Python guest agent (crates/openshell-vm/scripts/openshell-vm-exec-agent.py):
    • Add set_winsize() helper to apply terminal dimensions via TIOCSWINSZ ioctl
    • Add handle_client_tty() handler that allocates a PTY (pty.openpty), attaches the subprocess to it, and relays I/O over the VSOCK protocol
    • Refactor handle_client() to dispatch between pipe mode (handle_client_pipe) and TTY mode based on the tty field in the exec request
    • Handle resize frames to dynamically update PTY dimensions

Testing

  • mise run pre-commit passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

add support on both side (rust and python)

fixes NVIDIA#936

Signed-off-by: Florent Benoit <fbenoit@redhat.com>
@benoitf benoitf requested a review from a team as a code owner April 23, 2026 16:49
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