diff --git a/Cargo.lock b/Cargo.lock index 022c9e0..c21fcdf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -348,7 +348,7 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "vhost" version = "0.10.0" -source = "git+https://github.com/joaopeixoto13/vhost?branch=vhost-user-frontend#cf0c49322d8bff5f55591421298c9cb6699279a1" +source = "git+https://github.com/joaopeixoto13/vhost?branch=vhost-user-frontend#30a1e665079b8e4ca9c76219de2e2c6b5b28f568" dependencies = [ "bitflags 2.5.0", "libc", @@ -359,7 +359,7 @@ dependencies = [ [[package]] name = "vhost-user-frontend" version = "0.1.0" -source = "git+https://github.com/joaopeixoto13/vhost?branch=vhost-user-frontend#cf0c49322d8bff5f55591421298c9cb6699279a1" +source = "git+https://github.com/joaopeixoto13/vhost?branch=vhost-user-frontend#30a1e665079b8e4ca9c76219de2e2c6b5b28f568" dependencies = [ "epoll", "libc", diff --git a/README.md b/README.md index 2df09ad..da09b88 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/virtio/src/vsock/vhost_user/README.md b/src/virtio/src/vsock/vhost_user/README.md new file mode 100644 index 0000000..3989fda --- /dev/null +++ b/src/virtio/src/vsock/vhost_user/README.md @@ -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 & +``` \ No newline at end of file diff --git a/src/virtio/src/vsock/vhost_user/device.rs b/src/virtio/src/vsock/vhost_user/device.rs index 0ee719d..6dbc363 100644 --- a/src/virtio/src/vsock/vhost_user/device.rs +++ b/src/virtio/src/vsock/vhost_user/device.rs @@ -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(), }; @@ -116,9 +116,10 @@ impl VirtioDeviceT for VhostUserVsock { Ok(0) } - fn config_space(config: &DeviceConfig) -> Result> { - // 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> { + // Here we can leave empty since the vhost-user backend device is responsible for managing the configuration space. + // VhostUserProtocolFeatures::CONFIG + Ok(Vec::new()) } } @@ -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::>();