vhost-device/vhost-device-console
dependabot[bot] c31cbfe8e6 build(deps): bump the vhost-device group with 9 updates
Bumps the vhost-device group with 9 updates:

| Package | From | To |
| --- | --- | --- |
| [thiserror](https://github.com/dtolnay/thiserror) | `1.0.68` | `2.0.3` |
| [libc](https://github.com/rust-lang/libc) | `0.2.161` | `0.2.162` |
| [tempfile](https://github.com/Stebalien/tempfile) | `3.13.0` | `3.14.0` |
| [rstest](https://github.com/la10736/rstest) | `0.19.0` | `0.23.0` |
| [cc](https://github.com/rust-lang/cc-rs) | `1.1.36` | `1.1.37` |
| [fastrand](https://github.com/smol-rs/fastrand) | `2.1.1` | `2.2.0` |
| [rstest_macros](https://github.com/la10736/rstest) | `0.19.0` | `0.23.0` |
| [rustix](https://github.com/bytecodealliance/rustix) | `0.38.39` | `0.38.40` |
| [thiserror-impl](https://github.com/dtolnay/thiserror) | `1.0.68` | `1.0.69` |


Updates `thiserror` from 1.0.68 to 2.0.3
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.68...2.0.3)

Updates `libc` from 0.2.161 to 0.2.162
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Changelog](https://github.com/rust-lang/libc/blob/0.2.162/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.161...0.2.162)

Updates `tempfile` from 3.13.0 to 3.14.0
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/compare/v3.13.0...v3.14.0)

Updates `rstest` from 0.19.0 to 0.23.0
- [Release notes](https://github.com/la10736/rstest/releases)
- [Changelog](https://github.com/la10736/rstest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/la10736/rstest/compare/v0.19.0...v0.23.0)

Updates `cc` from 1.1.36 to 1.1.37
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.36...cc-v1.1.37)

Updates `fastrand` from 2.1.1 to 2.2.0
- [Release notes](https://github.com/smol-rs/fastrand/releases)
- [Changelog](https://github.com/smol-rs/fastrand/blob/master/CHANGELOG.md)
- [Commits](https://github.com/smol-rs/fastrand/compare/v2.1.1...v2.2.0)

Updates `rstest_macros` from 0.19.0 to 0.23.0
- [Release notes](https://github.com/la10736/rstest/releases)
- [Changelog](https://github.com/la10736/rstest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/la10736/rstest/compare/v0.19.0...v0.23.0)

Updates `rustix` from 0.38.39 to 0.38.40
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Changelog](https://github.com/bytecodealliance/rustix/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.39...v0.38.40)

Updates `thiserror-impl` from 1.0.68 to 1.0.69
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.68...1.0.69)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: vhost-device
- dependency-name: libc
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: tempfile
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: vhost-device
- dependency-name: rstest
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: vhost-device
- dependency-name: cc
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: fastrand
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: vhost-device
- dependency-name: rstest_macros
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: vhost-device
- dependency-name: rustix
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: thiserror-impl
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-11 10:02:22 +05:30
..
src vhost-device-console: promote to main workspace 2024-11-09 16:41:28 +00:00
Cargo.toml build(deps): bump the vhost-device group with 9 updates 2024-11-11 10:02:22 +05:30
CHANGELOG.md vhost-device-console: promote to main workspace 2024-11-09 16:41:28 +00:00
LICENSE-APACHE vhost-device-console: promote to main workspace 2024-11-09 16:41:28 +00:00
LICENSE-BSD-3-Clause vhost-device-console: promote to main workspace 2024-11-09 16:41:28 +00:00
README.md vhost-device-console: promote to main workspace 2024-11-09 16:41:28 +00:00

vhost-device-console - Console emulation backend daemon

Description

This program is a vhost-user backend that emulates a VirtIO Console device. The device's binary takes as parameters a socket path, a socket number which is the number of connections, commonly used across all vhost-devices to communicate with the vhost-user frontend devices, and the backend type "nested" or "network".

The "nested" backend allows input/output to the guest console through the current terminal.

The "network" backend creates a local TCP port (specified on vhost-device-console arguments) and allows input/output to the guest console via that socket.

This program is tested with QEMU's vhost-user-device-pci device. Examples' section below.

Synopsis

vhost-device-console --socket-path=<SOCKET_PATH>

Options

.. program:: vhost-device-console

.. option:: -h, --help

Print help.

.. option:: -s, --socket-path=PATH

Location of vhost-user Unix domain sockets, this path will be suffixed with 0,1,2..socket_count-1.

.. option:: -p, --tcp-port=PORT_NUMBER

The localhost's port to be used for each guest, this part will be increased with 0,1,2..socket_count-1.

-- option:: -b, --backend=nested|network

The backend type vhost-device-console to be used. The current implementation supports two types of backends: "nested", "network" (described above). Note: The nested backend is selected by default and can be used only when socket_count equals 1.

Limitations

This device is still work-in-progress (WIP). The current version has been tested with VIRTIO_CONSOLE_F_MULTIPORT, but only for one console (max_nr_ports = 1). Also it does not yet support the VIRTIO_CONSOLE_F_EMERG_WRITE and VIRTIO_CONSOLE_F_SIZE features.

Features

The current device gives access to multiple QEMU guest by providing a login prompt either by connecting to a localhost server port (network backend) or by creating an nested command prompt in the current terminal (nested backend). This prompt appears as soon as the guest is fully booted and gives the ability to user run command as a in regular terminal.

Examples

Dependencies

For testing the device the required dependencies are:

Test the device

The daemon should be started first:

host# vhost-device-console --socket-path=/tmp/console.sock --socket-count=1 \
                           --tcp-port=12345 --backend=network

Note: In case the backend is "nested" there is no need to provide "--socket-count" and "--tcp-port" parameters.

The QEMU invocation needs to create a chardev socket the device can use to communicate as well as share the guests memory over a memfd.

There are two option for running QEMU with vhost-device-console:

  1. Using vhost-user-console-pci:
host# qemu-system                                               \
    <normal QEMU options>                                       \
    -machine <machine options>,memory-backend=mem0              \
    -object memory-backend-memfd,id=mem0,size=<Guest RAM size>  \ # size == -m size
    -chardev socket,path=/tmp/console.sock0,id=con              \
    -device vhost-user-console-pci,chardev=con0,id=console      \
    ...

Note: For testing this scenario the reader needs to clone the QEMU version from the following repo which implements vhost-user-console device.

  1. Using vhost-user-device-pci:
host# qemu-system                                                                   \
    <normal QEMU options>                                                           \
    -machine <machine options>,memory-backend=mem0                                  \
    -object memory-backend-memfd,id=mem0,size=<Guest RAM size>                      \ # size == -m size
    -chardev socket,id=con0,path=/tmp/console.sock0                                 \
    -device vhost-user-device-pci,chardev=con0,virtio-id=3,num_vqs=4,config_size=12 \
    ...

Eventually, the user can connect to the console by running:

host# stty -icanon -echo && nc localhost 12345 && stty echo

Note: stty -icanon -echo is used to force the tty layer to disable buffering and send / receive each character individually. After closing the connection please run stty echo so character are printed back on the local terminal console.

Note: In case the backend is "nested" a nested terminal will be shown into vhost-device-console terminal space.

License

This project is licensed under either of