Skip to content

Commit

Permalink
feat(vhost-user-vsock): added support
Browse files Browse the repository at this point in the history
Signed-off-by: João Peixoto <[email protected]>
  • Loading branch information
joaopeixoto13 committed Sep 26, 2024
1 parent 9ab1fb5 commit 0533281
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The full list of supported (and work in progress) devices is presented below:
| Vhost-Net | [Net](src/virtio/src/net/README.md) | Vhost | - |
| Virtio-Vsock | [Vsock](src/virtio/src/vsock/README.md) | VirtIO | - |
| Vhost-Vsock | [Vsock](src/virtio/src/vsock/README.md) | Vhost | [x](src/virtio/src/vsock/vhost/README.md) |
| Vhost-User-Vsock | [Vsock](src/virtio/src/vsock/README.md) | Vhost-user | - |
| Vhost-User-Vsock | [Vsock](src/virtio/src/vsock/README.md) | Vhost-user | [x](src/virtio/src/vsock/vhost_user/README.md) |

## Contributing
Contributions to enhance the functionality and features of Bao Hypervisor VirtIO Device
Expand Down
31 changes: 31 additions & 0 deletions src/virtio/src/vsock/vhost_user/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Vhost-user vsock

## Requirements
- Vhost vsock device support on the Backend VM (e.g. `CONFIG_VHOST_VSOCK` on buildroot)

## Quick start

Follow these steps to quickly set up and run the vhost-user vsock device with Bao Hypervisor.

1. **Prepare Configuration File**: Create a configuration file (*config-virtio-vsock.yaml*) specifying
the settings for the vhost-user vsock device. One example of a configuration file could be:

```
devices:
- id: 0
type: "vsock"
mmio_addr: 0xa003e00
data_plane: vhost_user
socket_path: "/tmp/"
```

2. Launch the [vhost-user vsock backend](https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-vsock):
```
nohup vhost-device-vsock --vm guest-cid=4,uds-path=/tmp/vm4.vsock,socket=/tmp/Vsock.sock > /etc/vhost-vsock.log 2>&1 &
```

3. Launch the device model:

```
nohup bao-virtio-dm --config /PATH/TO/YOUR/config-virtio-vsock.yaml > /etc/bao-virtio-dm.log 2>&1 &
```
11 changes: 6 additions & 5 deletions src/virtio/src/vsock/vhost_user/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl VirtioDeviceT for VhostUserVsock {
config.socket_path.as_ref().unwrap(),
VirtioDevType::from(VirtioDevType::Vsock).to_string()
),
num_queues: 1, // Currently, multiple queues are not supported by the vhost-user backend (feature `VhostUserProtocolFeatures::MQ` not negotiated).
num_queues: 2, // The Rust-VMM backend (https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-vsock) does not supports event queues yet.
queue_size: queues[0].size(),
};

Expand Down Expand Up @@ -116,9 +116,10 @@ impl VirtioDeviceT for VhostUserVsock {
Ok(0)
}

fn config_space(config: &DeviceConfig) -> Result<Vec<u8>> {
// Retrieve the guest CID from the device configuration space.
Ok(config.guest_cid.unwrap().to_le_bytes().to_vec())
fn config_space(_config: &DeviceConfig) -> Result<Vec<u8>> {
// Here we can leave empty since the vhost-user backend device is responsible for managing the configuration space.
// VhostUserProtocolFeatures::CONFIG
Ok(Vec::new())
}
}

Expand Down Expand Up @@ -163,7 +164,7 @@ impl VirtioDeviceActions for VhostUserVsock {
.queues
.iter()
.enumerate()
.take(1) // Currently, multiple queues are not supported by the vhost-user backend (feature `VhostUserProtocolFeatures::MQ` not negotiated).
.take(2) // The Rust-VMM backend (https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-vsock) does not supports event queues yet.
.zip(ioevents)
.map(|((i, queue), ioevent)| (i, queue.clone(), ioevent))
.collect::<Vec<_>>();
Expand Down

0 comments on commit 0533281

Please sign in to comment.