Skip to content

Commit

Permalink
Update vhost-device-console
Browse files Browse the repository at this point in the history
Simplify the code, include Epilys's comments.
The device was tested with:
1) Upstream QEMU's vhost-user-device

    qemu-system-x86_64  \
            -m 4096 \
            -numa node,memdev=mem \
            -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on \
            -chardev socket,id=char1,path=/tmp/console.sock \
            -device vhost-user-device-pci,chardev=char1,virtio-id=3,num_vqs=4,config_size=12 \
            ...

2) A new QEMU vhost-user-console device which can be found in the following repo:
- https://github.com/virtualopensystems/qemu/tree/vhu-console-rfc

Signed-off-by: Timos Ampelikiotis <t.ampelikiotis@virtualopensystems.com>
  • Loading branch information
TimosAmpel committed Jan 31, 2024
1 parent b712245 commit 7af25d5
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 198 deletions.
2 changes: 1 addition & 1 deletion staging/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = [
"vhost-device-video",
"vhost-device-console",
"vhost-device-video",
]
17 changes: 10 additions & 7 deletions staging/vhost-device-console/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ console = "0.15.7"
queues = "1.0.2"
clap = { version = "4.4", features = ["derive"] }
env_logger = "0.10"
epoll = "4.3"
libc = "0.2"
log = "0.4"
rand = "0.8.5"
tempfile = "3.9"
thiserror = "1.0"
vhost = { version = "0.8", features = ["vhost-user-slave"] }
vhost-user-backend = "0.10"
virtio-bindings = "0.2.1"
virtio-queue = "0.9"
vm-memory = "0.12"
vhost = { version = "0.9", features = ["vhost-user-backend"] }
vhost-user-backend = "0.11"
virtio-bindings = "0.2.2"
virtio-queue = "0.10"
vm-memory = "0.13.1"
vmm-sys-util = "0.11"

[dev-dependencies]
assert_matches = "1.5"
virtio-queue = { version = "0.9", features = ["test-utils"] }
vm-memory = { version = "0.12", features = ["backend-mmap", "backend-atomic"] }
virtio-queue = { version = "0.10", features = ["test-utils"] }
vm-memory = { version = "0.13", features = ["backend-mmap", "backend-atomic"] }
89 changes: 72 additions & 17 deletions staging/vhost-device-console/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# vhost-device-console - Console emulation backend daemon

## Description
This program is a vhost-user backend that emulates a VirtIO Console device.

## Synopsis
```text
vhost-device-can --socket-path=<SOCKET_PATH>
```

## Options

Expand All @@ -15,31 +15,86 @@ This program is a vhost-user backend that emulates a VirtIO Console device.

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

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

.. option:: -p, --console-path=PATH

Location of Unix socket, this socket will be used to forward all the virtio
console traffic (not used in the current code version)
## Description

## Examples
This program is a vhost-user backend that emulates a VirtIO Console device.
The device's binary takes as parameter a socket which is commonly used
across all vhost-devices to communicate with the vhost-user frontend device.

The daemon should be started first:
This program is tested with QEMU's `vhost-user-device-pci` device and
Virtio-loopback's `-device vhost-user-can`.
Examples' section below.

::
This program is a vhost-user backend that emulates a VirtIO Console device.

host# vhost-device-console --socket-path=console.sock
## Limitations

The virtio-loopback invocation needs to insert the [virtio-loopback-transport](https://git.virtualopensystems.com/virtio-loopback/loopback_driver/-/tree/epsilon-release) driver and then start the [virtio-loopback-adapter](https://git.virtualopensystems.com/virtio-loopback/adapter_app/-/tree/epsilon-release) which is the intermediate between vhost-device and virtio-loopback-transport driver.
This device is still work-in-progress (WIP). Currently the device works
only with one guest at the time (no multi-guest support).

For more information please check the virtio-loopback [guide](https://git.virtualopensystems.com/virtio-loopback/docs/-/tree/epsilon-release) and the [design document](https://git.virtualopensystems.com/virtio-loopback/docs/-/blob/epsilon-release/design_docs/EG-VIRT_VOSYS_virtio_loopback_design_v1.4_2023_04_03.pdf).
## Next steps

::
Next development steps are:
1) Enable multi-guest support
2) Update the restart process of the device

host# sudo insmod loopback_driver.ko
host# sudo ./adapter -s /path/to/console.sock0 -d vhuconsole
## Features

The current device gives access to a QEMU guest by providing a login prompt.
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:
- Linux:
- Set `CONFIG_VIRTIO_CONSOLE=y`
- QEMU (optional):
- A new vhost-user-console device has been implemented in the following repo:
- https://github.com/virtualopensystems/qemu/tree/vhu-console-rfc


### Test the device

The daemon should be started first:
```shell
host# vhost-device-can --socket-path=can.sock --can-in="can0" --can-out="can1"
```

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`:
```text
host# qemu-system \
-m 4096 \
-numa node,memdev=mem \
-object memory-backend-memfd,id=mem,size=4G,share=on \
-chardev socket,path=/tmp/console.sock,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.
> - https://github.com/virtualopensystems/qemu/tree/vhu-console-rfc
2) Using `vhost-user-device-pci`:
```text
host# qemu-system \
-m 4096 \
-numa node,memdev=mem \
-object memory-backend-memfd,id=mem,size=4G,share=on \
-chardev socket,id=con0,path=/tmp/console.sock \
-device vhost-user-device-pci,chardev=con0,virtio-id=3,num_vqs=4,config_size=12 \
...
```

## License

Expand Down

0 comments on commit 7af25d5

Please sign in to comment.