Skip to content

Conversation

mtjhrc
Copy link
Collaborator

@mtjhrc mtjhrc commented Oct 8, 2025

This PR adds a new krun_add_virtio_console_multiport API function, which attaches a blank (no ports) virtio console to the VM. To specify the ports you can use the provided krun_add_console_port_inout and krun_add_console_port_tty.

Apart from the krun_add_console_port_inout being necessary for Android, this also adds basic support for attaching multiple tty session to the guest (see the consoles example), however they have to be statically configured and opened on VM startup. In the future it should also be possible to extend the API to be able to open console ports dynamically while the VM is running (but probably libkrun 2.x).

Make PortDescription a struct instead of an enum with variants. This will allow
for more flexibility when describing behavior of console ports.

Signed-off-by: Matej Hrica <[email protected]>
@mtjhrc mtjhrc force-pushed the multiport-console-api branch 7 times, most recently from 6a3e3a1 to d3c3cee Compare October 13, 2025 11:52
Make sure we always use the user provided descriptors instead of
STDIN/STDOUT/STDERR. This behavior should be more in line with the behavior
specified in the header.

Signed-off-by: Matej Hrica <[email protected]>
Previosly we were assuming stdin is terminal using it to determine the terminal
size. Attach a PortTerminalProperties trait object to each port for querying the
correct terminal size.

Note that this still only supports dynamically resizing the first port
(upon SIGWINCH).

Signed-off-by: Matej Hrica <[email protected]>
This restriction is actually unecessary, you can create such virtio-consoles
just fine.

Signed-off-by: Matej Hrica <[email protected]>
Add an example which shows the new multiport console functionality with multiple
terminals. The example uses tmux to create the the terminals in the background.

Signed-off-by: Matej Hrica <[email protected]>
@mtjhrc mtjhrc force-pushed the multiport-console-api branch from d3c3cee to fdca2ec Compare October 13, 2025 12:07
@mtjhrc mtjhrc marked this pull request as ready for review October 13, 2025 12:11
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