• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Vhost-user devices
2
3Crosvm supports [vhost-user] devices for most virtio devices (block, net, etc ) so that device
4emulation can be done outside of the main vmm process.
5
6Here is a diagram showing how vhost-user block device back-end and a vhost-user block front-end in
7crosvm VMM work together.
8
9<!-- Image from https://docs.google.com/presentation/d/1s6wH5L_F8NNiXls5UgWbD34jtBmijoZuiyLu76Fc2NM/edit#slide=id.ge5067b4ec2_0_55 -->
10
11![vhost-user diagram](images/vhost_user.png)
12
13## How to run
14
15Let's take a block device as an example and see how to start vhost-user devices.
16
17First, start vhost-user block backend with `crosvm devices` command, which waits for a vmm process
18connecting to the socket.
19
20```sh
21# One-time commands to create a disk image.
22fallocate -l 1G disk.img
23mkfs.ext4 disk.img
24
25VHOST_USER_SOCK=/tmp/vhost-user.socket
26
27# Start vhost-user block backend listening on $VHOST_USER_SOCK
28crosvm devices --block vhost=${VHOST_USER_SOCK},path=disk.img
29```
30
31Then, open another terminal and start a vmm process with `--vhost-user-blk` flag.
32
33```sh
34crosvm run \
35  --vhost-user-blk "${VHOST_USER_SOCK}" \
36  <usual crosvm arguments>
37  /path/to/bzImage
38```
39
40As a result, `disk.img` should be exposed as `/dev/vda` just like with `--block disk.img`.
41
42[vhost-user]: https://qemu.readthedocs.io/en/latest/interop/vhost-user.html
43