docs: book: add caveats section to VVU docs

The current documentation of VVU page did not include some important
information to reproduce the example such as the configuration of the
device guest kernel, or the requirement of setting the memory size of
sibling VM smaller than the device VM.

Add these information in the caveats section.

BUG=b:240398088
TEST=mdbook build

Change-Id: Ic391cd8099412b46acb52f49683cd702bfd54197
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3790664
Tested-by: Keita Suzuki <suzukikeita@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Morg <morg@chromium.org>
Commit-Queue: Keita Suzuki <suzukikeita@google.com>
This commit is contained in:
Keita Suzuki 2022-07-28 10:32:15 +00:00 committed by crosvm LUCI
parent 4fec994d63
commit fa2efe4233

View file

@ -17,7 +17,8 @@ Let's take a block device as an example and see how to start VVU devices.
First, start a device VM with a usual `crosvm run` command. At this time, put a crosvm binary in the
guest in some way. (e.g. putting it in a disk, sharing the host's crosvm with virtiofs, building
crosvm in the guest, etc)
crosvm in the guest, etc). Also, make sure that the guest kernel is configured properly with virtio
and vfio features enabled (see [caveat](#Caveats)).
```sh
# On the host.
@ -29,9 +30,11 @@ VHOST_USER_SOCK=/tmp/vhost-user.socket
# allocate it to the first available address.
VVU_PCI_ADDR="0000:00:10.0"
# Start the device VM.
# Start the device VM with '-p "vfio_iommu_type1.allow_unsafe_interrupts=1"'.
crosvm run \
--vvu-proxy "${VHOST_USER_SOCK},addr=${VVU_PCI_ADDR}" \
-p "vfio_iommu_type1.allow_unsafe_interrupts=1" \
-m 4096 \ # Make sure that the device kernel has enough memory to be used
... # usual crosvm args
vmlinux
```
@ -75,13 +78,16 @@ crosvm device block \
--file disk.img
```
Finally, open another terminal and start a vmm process with `--vhost-user-blk` flag on the host.
Finally, open another terminal and start a vmm process with `--vhost-user-blk` flag on the host. The
current implementation of crosvm only allows a sibling VM to have a smaller memory size than the
device VM, so make sure to specify the memory size correctly.
```sh
# On the host, start a sibling VM. This can be done in the same way as the vhost-user block front-end.
crosvm run \
--vhost-user-blk ${VHOST_USER_SOCK} \
-m 512 \ # Make sure that the sibling VM does not have same or more memory than the device VM
... # usual crosvm args
vmlinux
```
@ -89,4 +95,20 @@ crosvm run \
As a result, `disk.img` in the device VM should be exposed as `/dev/vda` in the guest of the sibling
VM.
## Caveats
- In order to use the VVU feature, the Device VM kernel is required to be configured with couple of
vfio features. Note that the name of the config may vary depending on the version of the kernel.
We expect that the readers follow the instructions in
[this page](../running_crosvm/custom_kernel_rootfs.md) to create a custom kernel. In addition to
the instruction, the required configurations in the Linux Kernel version 5.10 are:
- CONFIG_ACPI
- CONFIG_VFIO
- CONFIG_VFIO_PCI
- CONFIG_VIRTIO_IOMMU
- Currently, the sibling VM is required to have less memory than the device VM. Make sure that the
memory size is explicitly defined when starting the VM for both device and sibling VMs.
[virtio vhost-user (vvu)]: https://wiki.qemu.org/Features/VirtioVhostUser