Skip to content

Add serial TCP mode#23

Merged
hertrste merged 11 commits intocyberus-technology:gardenlinuxfrom
hertrste:tcp-serial
Sep 30, 2025
Merged

Add serial TCP mode#23
hertrste merged 11 commits intocyberus-technology:gardenlinuxfrom
hertrste:tcp-serial

Conversation

@hertrste
Copy link
Collaborator

@hertrste hertrste commented Sep 17, 2025

This MR adds a TCP mode to the serial device configuration, allowing to send and receive serial communication via TCP.

The MR is meant for early review and shouldn't be merged until we have some feedback from the upstream maintainers how the API can look like.

Best reviewed commit by commit. Please watch out for wild unwraps ;)

Further, I think the current structure of the code, especially in the serial_manager.rs, looks pretty sub-optimal. Please avoid fix the world suggestions for now, I think that should be done in an separate effort.

Usage:

cloud-hypervisor --serial tcp=127.0.0.1:2222,file=/tmp/vm.log ...
socat - TCP:localhost:2222

Opens:

  • Currently, only the TCP mode allows for an additional file parameter. I guess for upstreaming, also TTY and PTY modes require the ability to log to file in parallel. Any idea how to elegantly add that to the current codebase?
  • Any unittests to add?

@hertrste hertrste force-pushed the tcp-serial branch 6 times, most recently from c9a3669 to 919f56a Compare September 17, 2025 11:34
Copy link
Member

@phip1611 phip1611 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! There are a few things but after that, ship it.

Copy link

@olivereanderson olivereanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PoC 🙂

In addition to configuration options like pty, file, tty, ... we allow
setting the serial device to be accessed via some open TCP port on the
host.

Signed-off-by: Stefan Kober <stefan.kober@cyberus-technology.de>
Signed-off-by: Stefan Kober <stefan.kober@cyberus-technology.de>
Adding the TCP socket support to the serial device handling requires to
add a new syscall to the seccomp filter list.

Signed-off-by: Stefan Kober <stefan.kober@cyberus-technology.de>
Renaming the error makes it also usable for the new TCP socket support
in the serial device.

Signed-off-by: Stefan Kober <stefan.kober@cyberus-technology.de>
Similar to the unix socket implementation, we allow a user to set a port
were the serial is reachable.

Signed-off-by: Stefan Kober <stefan.kober@cyberus-technology.de>
Signed-off-by: Stefan Kober <stefan.kober@cyberus-technology.de>
When using the TCP serial mode, we also want to write the serial output
to a file. We use a generic write combiner that would allow us adding
even more writers.

Signed-off-by: Stefan Kober <stefan.kober@cyberus-technology.de>
When using the newly added TCP serial mode, we allow specifying an
additional file to log into. This allows users to access the complete
bootlog of a VM, as the TCP socket does not buffer anything.

Signed-off-by: Stefan Kober <stefan.kober@cyberus-technology.de>
Use the user provided file path that can be additionally specified when
TCP mode is selected for serial.

Signed-off-by: Stefan Kober <stefan.kober@cyberus-technology.de>
Signed-off-by: Stefan Kober <stefan.kober@cyberus-technology.de>
@hertrste hertrste marked this pull request as ready for review September 29, 2025 14:20
@hertrste hertrste changed the title Draft: Add serial TCP mode Add serial TCP mode Sep 30, 2025
Fix the clippy error in auto converge interation increasing.
@hertrste hertrste merged commit fd140ac into cyberus-technology:gardenlinux Sep 30, 2025
20 of 22 checks passed
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.

3 participants