| 1 | .. _vhost_user: |
| 2 | |
| 3 | vhost-user back ends |
| 4 | -------------------- |
| 5 | |
| 6 | vhost-user back ends are way to service the request of VirtIO devices |
| 7 | outside of QEMU itself. To do this there are a number of things |
| 8 | required. |
| 9 | |
| 10 | vhost-user device |
| 11 | ================= |
| 12 | |
| 13 | These are simple stub devices that ensure the VirtIO device is visible |
| 14 | to the guest. The code is mostly boilerplate although each device has |
| 15 | a ``chardev`` option which specifies the ID of the ``--chardev`` |
| 16 | device that connects via a socket to the vhost-user *daemon*. |
| 17 | |
| 18 | Each device will have an virtio-mmio and virtio-pci variant. See your |
| 19 | platform details for what sort of virtio bus to use. |
| 20 | |
| 21 | .. list-table:: vhost-user devices |
| 22 | :widths: 20 20 60 |
| 23 | :header-rows: 1 |
| 24 | |
| 25 | * - Device |
| 26 | - Type |
| 27 | - Notes |
| 28 | * - vhost-user-blk |
| 29 | - Block storage |
| 30 | - :ref:`storage-daemon` |
| 31 | * - vhost-user-fs |
| 32 | - File based storage driver |
| 33 | - `virtiofsd <https://gitlab.com/virtio-fs/virtiofsd>`_ |
| 34 | * - vhost-user-gpio |
| 35 | - Proxy gpio pins to host |
| 36 | - `vhost-device-gpio <https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-gpio>`_ |
| 37 | * - vhost-user-gpu |
| 38 | - GPU driver |
| 39 | - `vhost-device-gpu <https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-gpu>`_ or :ref:`vhost_user_gpu` |
| 40 | * - vhost-user-i2c |
| 41 | - Proxy i2c devices to host |
| 42 | - `vhost-device-i2c <https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-i2c>`_ |
| 43 | * - vhost-user-input |
| 44 | - Generic input driver |
| 45 | - `vhost-device-input <https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-input>`_ or :ref:`vhost_user_input` |
| 46 | * - vhost-user-rng |
| 47 | - Entropy driver |
| 48 | - `vhost-device-rng <https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-rng>`_ |
| 49 | * - vhost-user-scmi |
| 50 | - System Control and Management Interface |
| 51 | - `vhost-device-scmi <https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-scmi>`_ |
| 52 | * - vhost-user-snd |
| 53 | - Audio device |
| 54 | - `vhost-device-sound <https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-sound>`_ |
| 55 | * - vhost-user-scsi |
| 56 | - SCSI based storage |
| 57 | - :ref:`vhost_user_scsi` |
| 58 | * - vhost-user-vsock |
| 59 | - Socket based communication |
| 60 | - `vhost-device-vsock <https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-vsock>`_ |
| 61 | * - vhost-user-spi |
| 62 | - Proxy spi devices to host |
| 63 | - `vhost-device-spi <https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-spi>`_ |
| 64 | * - vhost-user-rtc |
| 65 | - Real time clock |
| 66 | - `vhost-device-rtc <https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-rtc>`_ |
| 67 | |
| 68 | The referenced *daemons* are not exhaustive, any conforming backend |
| 69 | implementing the device and using the vhost-user protocol should work. |
| 70 | |
| 71 | vhost-user-test-device |
| 72 | ^^^^^^^^^^^^^^^^^^^^^^ |
| 73 | |
| 74 | The vhost-user-test-device is a generic development device intended |
| 75 | for expert use while developing new backends. The user needs to |
| 76 | specify all the required parameters including: |
| 77 | |
| 78 | - Device ``virtio-id`` |
| 79 | - The ``num_vqs`` it needs and their ``vq_size`` |
| 80 | - The ``config_size`` if needed |
| 81 | |
| 82 | .. note:: |
| 83 | While this is a useful device for development it is not recommended |
| 84 | for production use. |
| 85 | |
| 86 | vhost-user daemon |
| 87 | ================= |
| 88 | |
| 89 | This is a separate process that is connected to by QEMU via a socket |
| 90 | following the :ref:`vhost_user_proto`. There are a number of daemons |
| 91 | that can be built when enabled by the project although any daemon that |
| 92 | meets the specification for a given device can be used. |
| 93 | |
| 94 | .. _shared_memory_object: |
| 95 | |
| 96 | Shared memory object |
| 97 | ==================== |
| 98 | |
| 99 | In order for the daemon to access the VirtIO queues to process the |
| 100 | requests it needs access to the guest's address space. This is |
| 101 | achieved via the ``memory-backend-file``, ``memory-backend-memfd``, or |
| 102 | ``memory-backend-shm`` objects. |
| 103 | A reference to a file-descriptor which can access this object |
| 104 | will be passed via the socket as part of the protocol negotiation. |
| 105 | |
| 106 | Currently the shared memory object needs to match the size of the main |
| 107 | system memory as defined by the ``-m`` argument. |
| 108 | |
| 109 | Example |
| 110 | ======= |
| 111 | |
| 112 | First start your daemon. |
| 113 | |
| 114 | .. parsed-literal:: |
| 115 | |
| 116 | $ virtio-foo --socket-path=/var/run/foo.sock $OTHER_ARGS |
| 117 | |
| 118 | Then you start your QEMU instance specifying the device, chardev and |
| 119 | memory objects. |
| 120 | |
| 121 | .. parsed-literal:: |
| 122 | |
| 123 | $ |qemu_system| \\ |
| 124 | -m 4096 \\ |
| 125 | -chardev socket,id=ba1,path=/var/run/foo.sock \\ |
| 126 | -device vhost-user-foo,chardev=ba1,$OTHER_ARGS \\ |
| 127 | -object memory-backend-memfd,id=mem,size=4G,share=on \\ |
| 128 | -numa node,memdev=mem \\ |
| 129 | ... |
| 130 |