xref: /openbmc/qemu/docs/interop/vhost-user.rst (revision 5cc8767d)
1===================
2Vhost-user Protocol
3===================
4:Copyright: 2014 Virtual Open Systems Sarl.
5:Licence: This work is licensed under the terms of the GNU GPL,
6          version 2 or later. See the COPYING file in the top-level
7          directory.
8
9.. contents:: Table of Contents
10
11Introduction
12============
13
14This protocol is aiming to complement the ``ioctl`` interface used to
15control the vhost implementation in the Linux kernel. It implements
16the control plane needed to establish virtqueue sharing with a user
17space process on the same host. It uses communication over a Unix
18domain socket to share file descriptors in the ancillary data of the
19message.
20
21The protocol defines 2 sides of the communication, *master* and
22*slave*. *Master* is the application that shares its virtqueues, in
23our case QEMU. *Slave* is the consumer of the virtqueues.
24
25In the current implementation QEMU is the *master*, and the *slave* is
26the external process consuming the virtio queues, for example a
27software Ethernet switch running in user space, such as Snabbswitch,
28or a block device backend processing read & write to a virtual
29disk. In order to facilitate interoperability between various backend
30implementations, it is recommended to follow the :ref:`Backend program
31conventions <backend_conventions>`.
32
33*Master* and *slave* can be either a client (i.e. connecting) or
34server (listening) in the socket communication.
35
36Message Specification
37=====================
38
39.. Note:: All numbers are in the machine native byte order.
40
41A vhost-user message consists of 3 header fields and a payload.
42
43+---------+-------+------+---------+
44| request | flags | size | payload |
45+---------+-------+------+---------+
46
47Header
48------
49
50:request: 32-bit type of the request
51
52:flags: 32-bit bit field
53
54- Lower 2 bits are the version (currently 0x01)
55- Bit 2 is the reply flag - needs to be sent on each reply from the slave
56- Bit 3 is the need_reply flag - see :ref:`REPLY_ACK <reply_ack>` for
57  details.
58
59:size: 32-bit size of the payload
60
61Payload
62-------
63
64Depending on the request type, **payload** can be:
65
66A single 64-bit integer
67^^^^^^^^^^^^^^^^^^^^^^^
68
69+-----+
70| u64 |
71+-----+
72
73:u64: a 64-bit unsigned integer
74
75A vring state description
76^^^^^^^^^^^^^^^^^^^^^^^^^
77
78+-------+-----+
79| index | num |
80+-------+-----+
81
82:index: a 32-bit index
83
84:num: a 32-bit number
85
86A vring address description
87^^^^^^^^^^^^^^^^^^^^^^^^^^^
88
89+-------+-------+------+------------+------+-----------+-----+
90| index | flags | size | descriptor | used | available | log |
91+-------+-------+------+------------+------+-----------+-----+
92
93:index: a 32-bit vring index
94
95:flags: a 32-bit vring flags
96
97:descriptor: a 64-bit ring address of the vring descriptor table
98
99:used: a 64-bit ring address of the vring used ring
100
101:available: a 64-bit ring address of the vring available ring
102
103:log: a 64-bit guest address for logging
104
105Note that a ring address is an IOVA if ``VIRTIO_F_IOMMU_PLATFORM`` has
106been negotiated. Otherwise it is a user address.
107
108Memory regions description
109^^^^^^^^^^^^^^^^^^^^^^^^^^
110
111+-------------+---------+---------+-----+---------+
112| num regions | padding | region0 | ... | region7 |
113+-------------+---------+---------+-----+---------+
114
115:num regions: a 32-bit number of regions
116
117:padding: 32-bit
118
119A region is:
120
121+---------------+------+--------------+-------------+
122| guest address | size | user address | mmap offset |
123+---------------+------+--------------+-------------+
124
125:guest address: a 64-bit guest address of the region
126
127:size: a 64-bit size
128
129:user address: a 64-bit user address
130
131:mmap offset: 64-bit offset where region starts in the mapped memory
132
133Log description
134^^^^^^^^^^^^^^^
135
136+----------+------------+
137| log size | log offset |
138+----------+------------+
139
140:log size: size of area used for logging
141
142:log offset: offset from start of supplied file descriptor where
143             logging starts (i.e. where guest address 0 would be
144             logged)
145
146An IOTLB message
147^^^^^^^^^^^^^^^^
148
149+------+------+--------------+-------------------+------+
150| iova | size | user address | permissions flags | type |
151+------+------+--------------+-------------------+------+
152
153:iova: a 64-bit I/O virtual address programmed by the guest
154
155:size: a 64-bit size
156
157:user address: a 64-bit user address
158
159:permissions flags: an 8-bit value:
160  - 0: No access
161  - 1: Read access
162  - 2: Write access
163  - 3: Read/Write access
164
165:type: an 8-bit IOTLB message type:
166  - 1: IOTLB miss
167  - 2: IOTLB update
168  - 3: IOTLB invalidate
169  - 4: IOTLB access fail
170
171Virtio device config space
172^^^^^^^^^^^^^^^^^^^^^^^^^^
173
174+--------+------+-------+---------+
175| offset | size | flags | payload |
176+--------+------+-------+---------+
177
178:offset: a 32-bit offset of virtio device's configuration space
179
180:size: a 32-bit configuration space access size in bytes
181
182:flags: a 32-bit value:
183  - 0: Vhost master messages used for writeable fields
184  - 1: Vhost master messages used for live migration
185
186:payload: Size bytes array holding the contents of the virtio
187          device's configuration space
188
189Vring area description
190^^^^^^^^^^^^^^^^^^^^^^
191
192+-----+------+--------+
193| u64 | size | offset |
194+-----+------+--------+
195
196:u64: a 64-bit integer contains vring index and flags
197
198:size: a 64-bit size of this area
199
200:offset: a 64-bit offset of this area from the start of the
201         supplied file descriptor
202
203Inflight description
204^^^^^^^^^^^^^^^^^^^^
205
206+-----------+-------------+------------+------------+
207| mmap size | mmap offset | num queues | queue size |
208+-----------+-------------+------------+------------+
209
210:mmap size: a 64-bit size of area to track inflight I/O
211
212:mmap offset: a 64-bit offset of this area from the start
213              of the supplied file descriptor
214
215:num queues: a 16-bit number of virtqueues
216
217:queue size: a 16-bit size of virtqueues
218
219C structure
220-----------
221
222In QEMU the vhost-user message is implemented with the following struct:
223
224.. code:: c
225
226  typedef struct VhostUserMsg {
227      VhostUserRequest request;
228      uint32_t flags;
229      uint32_t size;
230      union {
231          uint64_t u64;
232          struct vhost_vring_state state;
233          struct vhost_vring_addr addr;
234          VhostUserMemory memory;
235          VhostUserLog log;
236          struct vhost_iotlb_msg iotlb;
237          VhostUserConfig config;
238          VhostUserVringArea area;
239          VhostUserInflight inflight;
240      };
241  } QEMU_PACKED VhostUserMsg;
242
243Communication
244=============
245
246The protocol for vhost-user is based on the existing implementation of
247vhost for the Linux Kernel. Most messages that can be sent via the
248Unix domain socket implementing vhost-user have an equivalent ioctl to
249the kernel implementation.
250
251The communication consists of *master* sending message requests and
252*slave* sending message replies. Most of the requests don't require
253replies. Here is a list of the ones that do:
254
255* ``VHOST_USER_GET_FEATURES``
256* ``VHOST_USER_GET_PROTOCOL_FEATURES``
257* ``VHOST_USER_GET_VRING_BASE``
258* ``VHOST_USER_SET_LOG_BASE`` (if ``VHOST_USER_PROTOCOL_F_LOG_SHMFD``)
259* ``VHOST_USER_GET_INFLIGHT_FD`` (if ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD``)
260
261.. seealso::
262
263   :ref:`REPLY_ACK <reply_ack>`
264       The section on ``REPLY_ACK`` protocol extension.
265
266There are several messages that the master sends with file descriptors passed
267in the ancillary data:
268
269* ``VHOST_USER_SET_MEM_TABLE``
270* ``VHOST_USER_SET_LOG_BASE`` (if ``VHOST_USER_PROTOCOL_F_LOG_SHMFD``)
271* ``VHOST_USER_SET_LOG_FD``
272* ``VHOST_USER_SET_VRING_KICK``
273* ``VHOST_USER_SET_VRING_CALL``
274* ``VHOST_USER_SET_VRING_ERR``
275* ``VHOST_USER_SET_SLAVE_REQ_FD``
276* ``VHOST_USER_SET_INFLIGHT_FD`` (if ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD``)
277
278If *master* is unable to send the full message or receives a wrong
279reply it will close the connection. An optional reconnection mechanism
280can be implemented.
281
282Any protocol extensions are gated by protocol feature bits, which
283allows full backwards compatibility on both master and slave.  As
284older slaves don't support negotiating protocol features, a feature
285bit was dedicated for this purpose::
286
287  #define VHOST_USER_F_PROTOCOL_FEATURES 30
288
289Starting and stopping rings
290---------------------------
291
292Client must only process each ring when it is started.
293
294Client must only pass data between the ring and the backend, when the
295ring is enabled.
296
297If ring is started but disabled, client must process the ring without
298talking to the backend.
299
300For example, for a networking device, in the disabled state client
301must not supply any new RX packets, but must process and discard any
302TX packets.
303
304If ``VHOST_USER_F_PROTOCOL_FEATURES`` has not been negotiated, the
305ring is initialized in an enabled state.
306
307If ``VHOST_USER_F_PROTOCOL_FEATURES`` has been negotiated, the ring is
308initialized in a disabled state. Client must not pass data to/from the
309backend until ring is enabled by ``VHOST_USER_SET_VRING_ENABLE`` with
310parameter 1, or after it has been disabled by
311``VHOST_USER_SET_VRING_ENABLE`` with parameter 0.
312
313Each ring is initialized in a stopped state, client must not process
314it until ring is started, or after it has been stopped.
315
316Client must start ring upon receiving a kick (that is, detecting that
317file descriptor is readable) on the descriptor specified by
318``VHOST_USER_SET_VRING_KICK``, and stop ring upon receiving
319``VHOST_USER_GET_VRING_BASE``.
320
321While processing the rings (whether they are enabled or not), client
322must support changing some configuration aspects on the fly.
323
324Multiple queue support
325----------------------
326
327Multiple queue support allows the slave to advertise the maximum number of
328queues.  This is treated as a protocol extension, hence the slave has to
329implement protocol features first. The multiple queues feature is supported
330only when the protocol feature ``VHOST_USER_PROTOCOL_F_MQ`` (bit 0) is set.
331
332The max number of queues the slave supports can be queried with message
333``VHOST_USER_GET_QUEUE_NUM``. Master should stop when the number of requested
334queues is bigger than that.
335
336As all queues share one connection, the master uses a unique index for each
337queue in the sent message to identify a specified queue.
338
339The master enables queues by sending message ``VHOST_USER_SET_VRING_ENABLE``.
340vhost-user-net has historically automatically enabled the first queue pair.
341
342Migration
343---------
344
345During live migration, the master may need to track the modifications
346the slave makes to the memory mapped regions. The client should mark
347the dirty pages in a log. Once it complies to this logging, it may
348declare the ``VHOST_F_LOG_ALL`` vhost feature.
349
350To start/stop logging of data/used ring writes, server may send
351messages ``VHOST_USER_SET_FEATURES`` with ``VHOST_F_LOG_ALL`` and
352``VHOST_USER_SET_VRING_ADDR`` with ``VHOST_VRING_F_LOG`` in ring's
353flags set to 1/0, respectively.
354
355All the modifications to memory pointed by vring "descriptor" should
356be marked. Modifications to "used" vring should be marked if
357``VHOST_VRING_F_LOG`` is part of ring's flags.
358
359Dirty pages are of size::
360
361  #define VHOST_LOG_PAGE 0x1000
362
363The log memory fd is provided in the ancillary data of
364``VHOST_USER_SET_LOG_BASE`` message when the slave has
365``VHOST_USER_PROTOCOL_F_LOG_SHMFD`` protocol feature.
366
367The size of the log is supplied as part of ``VhostUserMsg`` which
368should be large enough to cover all known guest addresses. Log starts
369at the supplied offset in the supplied file descriptor.  The log
370covers from address 0 to the maximum of guest regions. In pseudo-code,
371to mark page at ``addr`` as dirty::
372
373  page = addr / VHOST_LOG_PAGE
374  log[page / 8] |= 1 << page % 8
375
376Where ``addr`` is the guest physical address.
377
378Use atomic operations, as the log may be concurrently manipulated.
379
380Note that when logging modifications to the used ring (when
381``VHOST_VRING_F_LOG`` is set for this ring), ``log_guest_addr`` should
382be used to calculate the log offset: the write to first byte of the
383used ring is logged at this offset from log start. Also note that this
384value might be outside the legal guest physical address range
385(i.e. does not have to be covered by the ``VhostUserMemory`` table), but
386the bit offset of the last byte of the ring must fall within the size
387supplied by ``VhostUserLog``.
388
389``VHOST_USER_SET_LOG_FD`` is an optional message with an eventfd in
390ancillary data, it may be used to inform the master that the log has
391been modified.
392
393Once the source has finished migration, rings will be stopped by the
394source. No further update must be done before rings are restarted.
395
396In postcopy migration the slave is started before all the memory has
397been received from the source host, and care must be taken to avoid
398accessing pages that have yet to be received.  The slave opens a
399'userfault'-fd and registers the memory with it; this fd is then
400passed back over to the master.  The master services requests on the
401userfaultfd for pages that are accessed and when the page is available
402it performs WAKE ioctl's on the userfaultfd to wake the stalled
403slave.  The client indicates support for this via the
404``VHOST_USER_PROTOCOL_F_PAGEFAULT`` feature.
405
406Memory access
407-------------
408
409The master sends a list of vhost memory regions to the slave using the
410``VHOST_USER_SET_MEM_TABLE`` message.  Each region has two base
411addresses: a guest address and a user address.
412
413Messages contain guest addresses and/or user addresses to reference locations
414within the shared memory.  The mapping of these addresses works as follows.
415
416User addresses map to the vhost memory region containing that user address.
417
418When the ``VIRTIO_F_IOMMU_PLATFORM`` feature has not been negotiated:
419
420* Guest addresses map to the vhost memory region containing that guest
421  address.
422
423When the ``VIRTIO_F_IOMMU_PLATFORM`` feature has been negotiated:
424
425* Guest addresses are also called I/O virtual addresses (IOVAs).  They are
426  translated to user addresses via the IOTLB.
427
428* The vhost memory region guest address is not used.
429
430IOMMU support
431-------------
432
433When the ``VIRTIO_F_IOMMU_PLATFORM`` feature has been negotiated, the
434master sends IOTLB entries update & invalidation by sending
435``VHOST_USER_IOTLB_MSG`` requests to the slave with a ``struct
436vhost_iotlb_msg`` as payload. For update events, the ``iotlb`` payload
437has to be filled with the update message type (2), the I/O virtual
438address, the size, the user virtual address, and the permissions
439flags. Addresses and size must be within vhost memory regions set via
440the ``VHOST_USER_SET_MEM_TABLE`` request. For invalidation events, the
441``iotlb`` payload has to be filled with the invalidation message type
442(3), the I/O virtual address and the size. On success, the slave is
443expected to reply with a zero payload, non-zero otherwise.
444
445The slave relies on the slave communcation channel (see :ref:`Slave
446communication <slave_communication>` section below) to send IOTLB miss
447and access failure events, by sending ``VHOST_USER_SLAVE_IOTLB_MSG``
448requests to the master with a ``struct vhost_iotlb_msg`` as
449payload. For miss events, the iotlb payload has to be filled with the
450miss message type (1), the I/O virtual address and the permissions
451flags. For access failure event, the iotlb payload has to be filled
452with the access failure message type (4), the I/O virtual address and
453the permissions flags.  For synchronization purpose, the slave may
454rely on the reply-ack feature, so the master may send a reply when
455operation is completed if the reply-ack feature is negotiated and
456slaves requests a reply. For miss events, completed operation means
457either master sent an update message containing the IOTLB entry
458containing requested address and permission, or master sent nothing if
459the IOTLB miss message is invalid (invalid IOVA or permission).
460
461The master isn't expected to take the initiative to send IOTLB update
462messages, as the slave sends IOTLB miss messages for the guest virtual
463memory areas it needs to access.
464
465.. _slave_communication:
466
467Slave communication
468-------------------
469
470An optional communication channel is provided if the slave declares
471``VHOST_USER_PROTOCOL_F_SLAVE_REQ`` protocol feature, to allow the
472slave to make requests to the master.
473
474The fd is provided via ``VHOST_USER_SET_SLAVE_REQ_FD`` ancillary data.
475
476A slave may then send ``VHOST_USER_SLAVE_*`` messages to the master
477using this fd communication channel.
478
479If ``VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD`` protocol feature is
480negotiated, slave can send file descriptors (at most 8 descriptors in
481each message) to master via ancillary data using this fd communication
482channel.
483
484Inflight I/O tracking
485---------------------
486
487To support reconnecting after restart or crash, slave may need to
488resubmit inflight I/Os. If virtqueue is processed in order, we can
489easily achieve that by getting the inflight descriptors from
490descriptor table (split virtqueue) or descriptor ring (packed
491virtqueue). However, it can't work when we process descriptors
492out-of-order because some entries which store the information of
493inflight descriptors in available ring (split virtqueue) or descriptor
494ring (packed virtqueue) might be overrided by new entries. To solve
495this problem, slave need to allocate an extra buffer to store this
496information of inflight descriptors and share it with master for
497persistent. ``VHOST_USER_GET_INFLIGHT_FD`` and
498``VHOST_USER_SET_INFLIGHT_FD`` are used to transfer this buffer
499between master and slave. And the format of this buffer is described
500below:
501
502+---------------+---------------+-----+---------------+
503| queue0 region | queue1 region | ... | queueN region |
504+---------------+---------------+-----+---------------+
505
506N is the number of available virtqueues. Slave could get it from num
507queues field of ``VhostUserInflight``.
508
509For split virtqueue, queue region can be implemented as:
510
511.. code:: c
512
513  typedef struct DescStateSplit {
514      /* Indicate whether this descriptor is inflight or not.
515       * Only available for head-descriptor. */
516      uint8_t inflight;
517
518      /* Padding */
519      uint8_t padding[5];
520
521      /* Maintain a list for the last batch of used descriptors.
522       * Only available when batching is used for submitting */
523      uint16_t next;
524
525      /* Used to preserve the order of fetching available descriptors.
526       * Only available for head-descriptor. */
527      uint64_t counter;
528  } DescStateSplit;
529
530  typedef struct QueueRegionSplit {
531      /* The feature flags of this region. Now it's initialized to 0. */
532      uint64_t features;
533
534      /* The version of this region. It's 1 currently.
535       * Zero value indicates an uninitialized buffer */
536      uint16_t version;
537
538      /* The size of DescStateSplit array. It's equal to the virtqueue
539       * size. Slave could get it from queue size field of VhostUserInflight. */
540      uint16_t desc_num;
541
542      /* The head of list that track the last batch of used descriptors. */
543      uint16_t last_batch_head;
544
545      /* Store the idx value of used ring */
546      uint16_t used_idx;
547
548      /* Used to track the state of each descriptor in descriptor table */
549      DescStateSplit desc[0];
550  } QueueRegionSplit;
551
552To track inflight I/O, the queue region should be processed as follows:
553
554When receiving available buffers from the driver:
555
556#. Get the next available head-descriptor index from available ring, ``i``
557
558#. Set ``desc[i].counter`` to the value of global counter
559
560#. Increase global counter by 1
561
562#. Set ``desc[i].inflight`` to 1
563
564When supplying used buffers to the driver:
565
5661. Get corresponding used head-descriptor index, i
567
5682. Set ``desc[i].next`` to ``last_batch_head``
569
5703. Set ``last_batch_head`` to ``i``
571
572#. Steps 1,2,3 may be performed repeatedly if batching is possible
573
574#. Increase the ``idx`` value of used ring by the size of the batch
575
576#. Set the ``inflight`` field of each ``DescStateSplit`` entry in the batch to 0
577
578#. Set ``used_idx`` to the ``idx`` value of used ring
579
580When reconnecting:
581
582#. If the value of ``used_idx`` does not match the ``idx`` value of
583   used ring (means the inflight field of ``DescStateSplit`` entries in
584   last batch may be incorrect),
585
586   a. Subtract the value of ``used_idx`` from the ``idx`` value of
587      used ring to get last batch size of ``DescStateSplit`` entries
588
589   #. Set the ``inflight`` field of each ``DescStateSplit`` entry to 0 in last batch
590      list which starts from ``last_batch_head``
591
592   #. Set ``used_idx`` to the ``idx`` value of used ring
593
594#. Resubmit inflight ``DescStateSplit`` entries in order of their
595   counter value
596
597For packed virtqueue, queue region can be implemented as:
598
599.. code:: c
600
601  typedef struct DescStatePacked {
602      /* Indicate whether this descriptor is inflight or not.
603       * Only available for head-descriptor. */
604      uint8_t inflight;
605
606      /* Padding */
607      uint8_t padding;
608
609      /* Link to the next free entry */
610      uint16_t next;
611
612      /* Link to the last entry of descriptor list.
613       * Only available for head-descriptor. */
614      uint16_t last;
615
616      /* The length of descriptor list.
617       * Only available for head-descriptor. */
618      uint16_t num;
619
620      /* Used to preserve the order of fetching available descriptors.
621       * Only available for head-descriptor. */
622      uint64_t counter;
623
624      /* The buffer id */
625      uint16_t id;
626
627      /* The descriptor flags */
628      uint16_t flags;
629
630      /* The buffer length */
631      uint32_t len;
632
633      /* The buffer address */
634      uint64_t addr;
635  } DescStatePacked;
636
637  typedef struct QueueRegionPacked {
638      /* The feature flags of this region. Now it's initialized to 0. */
639      uint64_t features;
640
641      /* The version of this region. It's 1 currently.
642       * Zero value indicates an uninitialized buffer */
643      uint16_t version;
644
645      /* The size of DescStatePacked array. It's equal to the virtqueue
646       * size. Slave could get it from queue size field of VhostUserInflight. */
647      uint16_t desc_num;
648
649      /* The head of free DescStatePacked entry list */
650      uint16_t free_head;
651
652      /* The old head of free DescStatePacked entry list */
653      uint16_t old_free_head;
654
655      /* The used index of descriptor ring */
656      uint16_t used_idx;
657
658      /* The old used index of descriptor ring */
659      uint16_t old_used_idx;
660
661      /* Device ring wrap counter */
662      uint8_t used_wrap_counter;
663
664      /* The old device ring wrap counter */
665      uint8_t old_used_wrap_counter;
666
667      /* Padding */
668      uint8_t padding[7];
669
670      /* Used to track the state of each descriptor fetched from descriptor ring */
671      DescStatePacked desc[0];
672  } QueueRegionPacked;
673
674To track inflight I/O, the queue region should be processed as follows:
675
676When receiving available buffers from the driver:
677
678#. Get the next available descriptor entry from descriptor ring, ``d``
679
680#. If ``d`` is head descriptor,
681
682   a. Set ``desc[old_free_head].num`` to 0
683
684   #. Set ``desc[old_free_head].counter`` to the value of global counter
685
686   #. Increase global counter by 1
687
688   #. Set ``desc[old_free_head].inflight`` to 1
689
690#. If ``d`` is last descriptor, set ``desc[old_free_head].last`` to
691   ``free_head``
692
693#. Increase ``desc[old_free_head].num`` by 1
694
695#. Set ``desc[free_head].addr``, ``desc[free_head].len``,
696   ``desc[free_head].flags``, ``desc[free_head].id`` to ``d.addr``,
697   ``d.len``, ``d.flags``, ``d.id``
698
699#. Set ``free_head`` to ``desc[free_head].next``
700
701#. If ``d`` is last descriptor, set ``old_free_head`` to ``free_head``
702
703When supplying used buffers to the driver:
704
7051. Get corresponding used head-descriptor entry from descriptor ring,
706   ``d``
707
7082. Get corresponding ``DescStatePacked`` entry, ``e``
709
7103. Set ``desc[e.last].next`` to ``free_head``
711
7124. Set ``free_head`` to the index of ``e``
713
714#. Steps 1,2,3,4 may be performed repeatedly if batching is possible
715
716#. Increase ``used_idx`` by the size of the batch and update
717   ``used_wrap_counter`` if needed
718
719#. Update ``d.flags``
720
721#. Set the ``inflight`` field of each head ``DescStatePacked`` entry
722   in the batch to 0
723
724#. Set ``old_free_head``,  ``old_used_idx``, ``old_used_wrap_counter``
725   to ``free_head``, ``used_idx``, ``used_wrap_counter``
726
727When reconnecting:
728
729#. If ``used_idx`` does not match ``old_used_idx`` (means the
730   ``inflight`` field of ``DescStatePacked`` entries in last batch may
731   be incorrect),
732
733   a. Get the next descriptor ring entry through ``old_used_idx``, ``d``
734
735   #. Use ``old_used_wrap_counter`` to calculate the available flags
736
737   #. If ``d.flags`` is not equal to the calculated flags value (means
738      slave has submitted the buffer to guest driver before crash, so
739      it has to commit the in-progres update), set ``old_free_head``,
740      ``old_used_idx``, ``old_used_wrap_counter`` to ``free_head``,
741      ``used_idx``, ``used_wrap_counter``
742
743#. Set ``free_head``, ``used_idx``, ``used_wrap_counter`` to
744   ``old_free_head``, ``old_used_idx``, ``old_used_wrap_counter``
745   (roll back any in-progress update)
746
747#. Set the ``inflight`` field of each ``DescStatePacked`` entry in
748   free list to 0
749
750#. Resubmit inflight ``DescStatePacked`` entries in order of their
751   counter value
752
753Protocol features
754-----------------
755
756.. code:: c
757
758  #define VHOST_USER_PROTOCOL_F_MQ             0
759  #define VHOST_USER_PROTOCOL_F_LOG_SHMFD      1
760  #define VHOST_USER_PROTOCOL_F_RARP           2
761  #define VHOST_USER_PROTOCOL_F_REPLY_ACK      3
762  #define VHOST_USER_PROTOCOL_F_MTU            4
763  #define VHOST_USER_PROTOCOL_F_SLAVE_REQ      5
764  #define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN   6
765  #define VHOST_USER_PROTOCOL_F_CRYPTO_SESSION 7
766  #define VHOST_USER_PROTOCOL_F_PAGEFAULT      8
767  #define VHOST_USER_PROTOCOL_F_CONFIG         9
768  #define VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD  10
769  #define VHOST_USER_PROTOCOL_F_HOST_NOTIFIER  11
770  #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12
771
772Master message types
773--------------------
774
775``VHOST_USER_GET_FEATURES``
776  :id: 1
777  :equivalent ioctl: ``VHOST_GET_FEATURES``
778  :master payload: N/A
779  :slave payload: ``u64``
780
781  Get from the underlying vhost implementation the features bitmask.
782  Feature bit ``VHOST_USER_F_PROTOCOL_FEATURES`` signals slave support
783  for ``VHOST_USER_GET_PROTOCOL_FEATURES`` and
784  ``VHOST_USER_SET_PROTOCOL_FEATURES``.
785
786``VHOST_USER_SET_FEATURES``
787  :id: 2
788  :equivalent ioctl: ``VHOST_SET_FEATURES``
789  :master payload: ``u64``
790
791  Enable features in the underlying vhost implementation using a
792  bitmask.  Feature bit ``VHOST_USER_F_PROTOCOL_FEATURES`` signals
793  slave support for ``VHOST_USER_GET_PROTOCOL_FEATURES`` and
794  ``VHOST_USER_SET_PROTOCOL_FEATURES``.
795
796``VHOST_USER_GET_PROTOCOL_FEATURES``
797  :id: 15
798  :equivalent ioctl: ``VHOST_GET_FEATURES``
799  :master payload: N/A
800  :slave payload: ``u64``
801
802  Get the protocol feature bitmask from the underlying vhost
803  implementation.  Only legal if feature bit
804  ``VHOST_USER_F_PROTOCOL_FEATURES`` is present in
805  ``VHOST_USER_GET_FEATURES``.
806
807.. Note::
808   Slave that reported ``VHOST_USER_F_PROTOCOL_FEATURES`` must
809   support this message even before ``VHOST_USER_SET_FEATURES`` was
810   called.
811
812``VHOST_USER_SET_PROTOCOL_FEATURES``
813  :id: 16
814  :equivalent ioctl: ``VHOST_SET_FEATURES``
815  :master payload: ``u64``
816
817  Enable protocol features in the underlying vhost implementation.
818
819  Only legal if feature bit ``VHOST_USER_F_PROTOCOL_FEATURES`` is present in
820  ``VHOST_USER_GET_FEATURES``.
821
822.. Note::
823   Slave that reported ``VHOST_USER_F_PROTOCOL_FEATURES`` must support
824   this message even before ``VHOST_USER_SET_FEATURES`` was called.
825
826``VHOST_USER_SET_OWNER``
827  :id: 3
828  :equivalent ioctl: ``VHOST_SET_OWNER``
829  :master payload: N/A
830
831  Issued when a new connection is established. It sets the current
832  *master* as an owner of the session. This can be used on the *slave*
833  as a "session start" flag.
834
835``VHOST_USER_RESET_OWNER``
836  :id: 4
837  :master payload: N/A
838
839.. admonition:: Deprecated
840
841   This is no longer used. Used to be sent to request disabling all
842   rings, but some clients interpreted it to also discard connection
843   state (this interpretation would lead to bugs).  It is recommended
844   that clients either ignore this message, or use it to disable all
845   rings.
846
847``VHOST_USER_SET_MEM_TABLE``
848  :id: 5
849  :equivalent ioctl: ``VHOST_SET_MEM_TABLE``
850  :master payload: memory regions description
851  :slave payload: (postcopy only) memory regions description
852
853  Sets the memory map regions on the slave so it can translate the
854  vring addresses. In the ancillary data there is an array of file
855  descriptors for each memory mapped region. The size and ordering of
856  the fds matches the number and ordering of memory regions.
857
858  When ``VHOST_USER_POSTCOPY_LISTEN`` has been received,
859  ``SET_MEM_TABLE`` replies with the bases of the memory mapped
860  regions to the master.  The slave must have mmap'd the regions but
861  not yet accessed them and should not yet generate a userfault
862  event.
863
864.. Note::
865   ``NEED_REPLY_MASK`` is not set in this case.  QEMU will then
866   reply back to the list of mappings with an empty
867   ``VHOST_USER_SET_MEM_TABLE`` as an acknowledgement; only upon
868   reception of this message may the guest start accessing the memory
869   and generating faults.
870
871``VHOST_USER_SET_LOG_BASE``
872  :id: 6
873  :equivalent ioctl: ``VHOST_SET_LOG_BASE``
874  :master payload: u64
875  :slave payload: N/A
876
877  Sets logging shared memory space.
878
879  When slave has ``VHOST_USER_PROTOCOL_F_LOG_SHMFD`` protocol feature,
880  the log memory fd is provided in the ancillary data of
881  ``VHOST_USER_SET_LOG_BASE`` message, the size and offset of shared
882  memory area provided in the message.
883
884``VHOST_USER_SET_LOG_FD``
885  :id: 7
886  :equivalent ioctl: ``VHOST_SET_LOG_FD``
887  :master payload: N/A
888
889  Sets the logging file descriptor, which is passed as ancillary data.
890
891``VHOST_USER_SET_VRING_NUM``
892  :id: 8
893  :equivalent ioctl: ``VHOST_SET_VRING_NUM``
894  :master payload: vring state description
895
896  Set the size of the queue.
897
898``VHOST_USER_SET_VRING_ADDR``
899  :id: 9
900  :equivalent ioctl: ``VHOST_SET_VRING_ADDR``
901  :master payload: vring address description
902  :slave payload: N/A
903
904  Sets the addresses of the different aspects of the vring.
905
906``VHOST_USER_SET_VRING_BASE``
907  :id: 10
908  :equivalent ioctl: ``VHOST_SET_VRING_BASE``
909  :master payload: vring state description
910
911  Sets the base offset in the available vring.
912
913``VHOST_USER_GET_VRING_BASE``
914  :id: 11
915  :equivalent ioctl: ``VHOST_USER_GET_VRING_BASE``
916  :master payload: vring state description
917  :slave payload: vring state description
918
919  Get the available vring base offset.
920
921``VHOST_USER_SET_VRING_KICK``
922  :id: 12
923  :equivalent ioctl: ``VHOST_SET_VRING_KICK``
924  :master payload: ``u64``
925
926  Set the event file descriptor for adding buffers to the vring. It is
927  passed in the ancillary data.
928
929  Bits (0-7) of the payload contain the vring index. Bit 8 is the
930  invalid FD flag. This flag is set when there is no file descriptor
931  in the ancillary data. This signals that polling should be used
932  instead of waiting for a kick.
933
934``VHOST_USER_SET_VRING_CALL``
935  :id: 13
936  :equivalent ioctl: ``VHOST_SET_VRING_CALL``
937  :master payload: ``u64``
938
939  Set the event file descriptor to signal when buffers are used. It is
940  passed in the ancillary data.
941
942  Bits (0-7) of the payload contain the vring index. Bit 8 is the
943  invalid FD flag. This flag is set when there is no file descriptor
944  in the ancillary data. This signals that polling will be used
945  instead of waiting for the call.
946
947``VHOST_USER_SET_VRING_ERR``
948  :id: 14
949  :equivalent ioctl: ``VHOST_SET_VRING_ERR``
950  :master payload: ``u64``
951
952  Set the event file descriptor to signal when error occurs. It is
953  passed in the ancillary data.
954
955  Bits (0-7) of the payload contain the vring index. Bit 8 is the
956  invalid FD flag. This flag is set when there is no file descriptor
957  in the ancillary data.
958
959``VHOST_USER_GET_QUEUE_NUM``
960  :id: 17
961  :equivalent ioctl: N/A
962  :master payload: N/A
963  :slave payload: u64
964
965  Query how many queues the backend supports.
966
967  This request should be sent only when ``VHOST_USER_PROTOCOL_F_MQ``
968  is set in queried protocol features by
969  ``VHOST_USER_GET_PROTOCOL_FEATURES``.
970
971``VHOST_USER_SET_VRING_ENABLE``
972  :id: 18
973  :equivalent ioctl: N/A
974  :master payload: vring state description
975
976  Signal slave to enable or disable corresponding vring.
977
978  This request should be sent only when
979  ``VHOST_USER_F_PROTOCOL_FEATURES`` has been negotiated.
980
981``VHOST_USER_SEND_RARP``
982  :id: 19
983  :equivalent ioctl: N/A
984  :master payload: ``u64``
985
986  Ask vhost user backend to broadcast a fake RARP to notify the migration
987  is terminated for guest that does not support GUEST_ANNOUNCE.
988
989  Only legal if feature bit ``VHOST_USER_F_PROTOCOL_FEATURES`` is
990  present in ``VHOST_USER_GET_FEATURES`` and protocol feature bit
991  ``VHOST_USER_PROTOCOL_F_RARP`` is present in
992  ``VHOST_USER_GET_PROTOCOL_FEATURES``.  The first 6 bytes of the
993  payload contain the mac address of the guest to allow the vhost user
994  backend to construct and broadcast the fake RARP.
995
996``VHOST_USER_NET_SET_MTU``
997  :id: 20
998  :equivalent ioctl: N/A
999  :master payload: ``u64``
1000
1001  Set host MTU value exposed to the guest.
1002
1003  This request should be sent only when ``VIRTIO_NET_F_MTU`` feature
1004  has been successfully negotiated, ``VHOST_USER_F_PROTOCOL_FEATURES``
1005  is present in ``VHOST_USER_GET_FEATURES`` and protocol feature bit
1006  ``VHOST_USER_PROTOCOL_F_NET_MTU`` is present in
1007  ``VHOST_USER_GET_PROTOCOL_FEATURES``.
1008
1009  If ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` is negotiated, slave must
1010  respond with zero in case the specified MTU is valid, or non-zero
1011  otherwise.
1012
1013``VHOST_USER_SET_SLAVE_REQ_FD``
1014  :id: 21
1015  :equivalent ioctl: N/A
1016  :master payload: N/A
1017
1018  Set the socket file descriptor for slave initiated requests. It is passed
1019  in the ancillary data.
1020
1021  This request should be sent only when
1022  ``VHOST_USER_F_PROTOCOL_FEATURES`` has been negotiated, and protocol
1023  feature bit ``VHOST_USER_PROTOCOL_F_SLAVE_REQ`` bit is present in
1024  ``VHOST_USER_GET_PROTOCOL_FEATURES``.  If
1025  ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` is negotiated, slave must
1026  respond with zero for success, non-zero otherwise.
1027
1028``VHOST_USER_IOTLB_MSG``
1029  :id: 22
1030  :equivalent ioctl: N/A (equivalent to ``VHOST_IOTLB_MSG`` message type)
1031  :master payload: ``struct vhost_iotlb_msg``
1032  :slave payload: ``u64``
1033
1034  Send IOTLB messages with ``struct vhost_iotlb_msg`` as payload.
1035
1036  Master sends such requests to update and invalidate entries in the
1037  device IOTLB. The slave has to acknowledge the request with sending
1038  zero as ``u64`` payload for success, non-zero otherwise.
1039
1040  This request should be send only when ``VIRTIO_F_IOMMU_PLATFORM``
1041  feature has been successfully negotiated.
1042
1043``VHOST_USER_SET_VRING_ENDIAN``
1044  :id: 23
1045  :equivalent ioctl: ``VHOST_SET_VRING_ENDIAN``
1046  :master payload: vring state description
1047
1048  Set the endianness of a VQ for legacy devices. Little-endian is
1049  indicated with state.num set to 0 and big-endian is indicated with
1050  state.num set to 1. Other values are invalid.
1051
1052  This request should be sent only when
1053  ``VHOST_USER_PROTOCOL_F_CROSS_ENDIAN`` has been negotiated.
1054  Backends that negotiated this feature should handle both
1055  endiannesses and expect this message once (per VQ) during device
1056  configuration (ie. before the master starts the VQ).
1057
1058``VHOST_USER_GET_CONFIG``
1059  :id: 24
1060  :equivalent ioctl: N/A
1061  :master payload: virtio device config space
1062  :slave payload: virtio device config space
1063
1064  When ``VHOST_USER_PROTOCOL_F_CONFIG`` is negotiated, this message is
1065  submitted by the vhost-user master to fetch the contents of the
1066  virtio device configuration space, vhost-user slave's payload size
1067  MUST match master's request, vhost-user slave uses zero length of
1068  payload to indicate an error to vhost-user master. The vhost-user
1069  master may cache the contents to avoid repeated
1070  ``VHOST_USER_GET_CONFIG`` calls.
1071
1072``VHOST_USER_SET_CONFIG``
1073  :id: 25
1074  :equivalent ioctl: N/A
1075  :master payload: virtio device config space
1076  :slave payload: N/A
1077
1078  When ``VHOST_USER_PROTOCOL_F_CONFIG`` is negotiated, this message is
1079  submitted by the vhost-user master when the Guest changes the virtio
1080  device configuration space and also can be used for live migration
1081  on the destination host. The vhost-user slave must check the flags
1082  field, and slaves MUST NOT accept SET_CONFIG for read-only
1083  configuration space fields unless the live migration bit is set.
1084
1085``VHOST_USER_CREATE_CRYPTO_SESSION``
1086  :id: 26
1087  :equivalent ioctl: N/A
1088  :master payload: crypto session description
1089  :slave payload: crypto session description
1090
1091  Create a session for crypto operation. The server side must return
1092  the session id, 0 or positive for success, negative for failure.
1093  This request should be sent only when
1094  ``VHOST_USER_PROTOCOL_F_CRYPTO_SESSION`` feature has been
1095  successfully negotiated.  It's a required feature for crypto
1096  devices.
1097
1098``VHOST_USER_CLOSE_CRYPTO_SESSION``
1099  :id: 27
1100  :equivalent ioctl: N/A
1101  :master payload: ``u64``
1102
1103  Close a session for crypto operation which was previously
1104  created by ``VHOST_USER_CREATE_CRYPTO_SESSION``.
1105
1106  This request should be sent only when
1107  ``VHOST_USER_PROTOCOL_F_CRYPTO_SESSION`` feature has been
1108  successfully negotiated.  It's a required feature for crypto
1109  devices.
1110
1111``VHOST_USER_POSTCOPY_ADVISE``
1112  :id: 28
1113  :master payload: N/A
1114  :slave payload: userfault fd
1115
1116  When ``VHOST_USER_PROTOCOL_F_PAGEFAULT`` is supported, the master
1117  advises slave that a migration with postcopy enabled is underway,
1118  the slave must open a userfaultfd for later use.  Note that at this
1119  stage the migration is still in precopy mode.
1120
1121``VHOST_USER_POSTCOPY_LISTEN``
1122  :id: 29
1123  :master payload: N/A
1124
1125  Master advises slave that a transition to postcopy mode has
1126  happened.  The slave must ensure that shared memory is registered
1127  with userfaultfd to cause faulting of non-present pages.
1128
1129  This is always sent sometime after a ``VHOST_USER_POSTCOPY_ADVISE``,
1130  and thus only when ``VHOST_USER_PROTOCOL_F_PAGEFAULT`` is supported.
1131
1132``VHOST_USER_POSTCOPY_END``
1133  :id: 30
1134  :slave payload: ``u64``
1135
1136  Master advises that postcopy migration has now completed.  The slave
1137  must disable the userfaultfd. The response is an acknowledgement
1138  only.
1139
1140  When ``VHOST_USER_PROTOCOL_F_PAGEFAULT`` is supported, this message
1141  is sent at the end of the migration, after
1142  ``VHOST_USER_POSTCOPY_LISTEN`` was previously sent.
1143
1144  The value returned is an error indication; 0 is success.
1145
1146``VHOST_USER_GET_INFLIGHT_FD``
1147  :id: 31
1148  :equivalent ioctl: N/A
1149  :master payload: inflight description
1150
1151  When ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD`` protocol feature has
1152  been successfully negotiated, this message is submitted by master to
1153  get a shared buffer from slave. The shared buffer will be used to
1154  track inflight I/O by slave. QEMU should retrieve a new one when vm
1155  reset.
1156
1157``VHOST_USER_SET_INFLIGHT_FD``
1158  :id: 32
1159  :equivalent ioctl: N/A
1160  :master payload: inflight description
1161
1162  When ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD`` protocol feature has
1163  been successfully negotiated, this message is submitted by master to
1164  send the shared inflight buffer back to slave so that slave could
1165  get inflight I/O after a crash or restart.
1166
1167``VHOST_USER_GPU_SET_SOCKET``
1168  :id: 33
1169  :equivalent ioctl: N/A
1170  :master payload: N/A
1171
1172  Sets the GPU protocol socket file descriptor, which is passed as
1173  ancillary data. The GPU protocol is used to inform the master of
1174  rendering state and updates. See vhost-user-gpu.rst for details.
1175
1176Slave message types
1177-------------------
1178
1179``VHOST_USER_SLAVE_IOTLB_MSG``
1180  :id: 1
1181  :equivalent ioctl: N/A (equivalent to ``VHOST_IOTLB_MSG`` message type)
1182  :slave payload: ``struct vhost_iotlb_msg``
1183  :master payload: N/A
1184
1185  Send IOTLB messages with ``struct vhost_iotlb_msg`` as payload.
1186  Slave sends such requests to notify of an IOTLB miss, or an IOTLB
1187  access failure. If ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` is
1188  negotiated, and slave set the ``VHOST_USER_NEED_REPLY`` flag, master
1189  must respond with zero when operation is successfully completed, or
1190  non-zero otherwise.  This request should be send only when
1191  ``VIRTIO_F_IOMMU_PLATFORM`` feature has been successfully
1192  negotiated.
1193
1194``VHOST_USER_SLAVE_CONFIG_CHANGE_MSG``
1195  :id: 2
1196  :equivalent ioctl: N/A
1197  :slave payload: N/A
1198  :master payload: N/A
1199
1200  When ``VHOST_USER_PROTOCOL_F_CONFIG`` is negotiated, vhost-user
1201  slave sends such messages to notify that the virtio device's
1202  configuration space has changed, for those host devices which can
1203  support such feature, host driver can send ``VHOST_USER_GET_CONFIG``
1204  message to slave to get the latest content. If
1205  ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` is negotiated, and slave set the
1206  ``VHOST_USER_NEED_REPLY`` flag, master must respond with zero when
1207  operation is successfully completed, or non-zero otherwise.
1208
1209``VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG``
1210  :id: 3
1211  :equivalent ioctl: N/A
1212  :slave payload: vring area description
1213  :master payload: N/A
1214
1215  Sets host notifier for a specified queue. The queue index is
1216  contained in the ``u64`` field of the vring area description. The
1217  host notifier is described by the file descriptor (typically it's a
1218  VFIO device fd) which is passed as ancillary data and the size
1219  (which is mmap size and should be the same as host page size) and
1220  offset (which is mmap offset) carried in the vring area
1221  description. QEMU can mmap the file descriptor based on the size and
1222  offset to get a memory range. Registering a host notifier means
1223  mapping this memory range to the VM as the specified queue's notify
1224  MMIO region. Slave sends this request to tell QEMU to de-register
1225  the existing notifier if any and register the new notifier if the
1226  request is sent with a file descriptor.
1227
1228  This request should be sent only when
1229  ``VHOST_USER_PROTOCOL_F_HOST_NOTIFIER`` protocol feature has been
1230  successfully negotiated.
1231
1232.. _reply_ack:
1233
1234VHOST_USER_PROTOCOL_F_REPLY_ACK
1235-------------------------------
1236
1237The original vhost-user specification only demands replies for certain
1238commands. This differs from the vhost protocol implementation where
1239commands are sent over an ``ioctl()`` call and block until the client
1240has completed.
1241
1242With this protocol extension negotiated, the sender (QEMU) can set the
1243``need_reply`` [Bit 3] flag to any command. This indicates that the
1244client MUST respond with a Payload ``VhostUserMsg`` indicating success
1245or failure. The payload should be set to zero on success or non-zero
1246on failure, unless the message already has an explicit reply body.
1247
1248The response payload gives QEMU a deterministic indication of the result
1249of the command. Today, QEMU is expected to terminate the main vhost-user
1250loop upon receiving such errors. In future, qemu could be taught to be more
1251resilient for selective requests.
1252
1253For the message types that already solicit a reply from the client,
1254the presence of ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` or need_reply bit
1255being set brings no behavioural change. (See the Communication_
1256section for details.)
1257
1258.. _backend_conventions:
1259
1260Backend program conventions
1261===========================
1262
1263vhost-user backends can provide various devices & services and may
1264need to be configured manually depending on the use case. However, it
1265is a good idea to follow the conventions listed here when
1266possible. Users, QEMU or libvirt, can then rely on some common
1267behaviour to avoid heterogenous configuration and management of the
1268backend programs and facilitate interoperability.
1269
1270Each backend installed on a host system should come with at least one
1271JSON file that conforms to the vhost-user.json schema. Each file
1272informs the management applications about the backend type, and binary
1273location. In addition, it defines rules for management apps for
1274picking the highest priority backend when multiple match the search
1275criteria (see ``@VhostUserBackend`` documentation in the schema file).
1276
1277If the backend is not capable of enabling a requested feature on the
1278host (such as 3D acceleration with virgl), or the initialization
1279failed, the backend should fail to start early and exit with a status
1280!= 0. It may also print a message to stderr for further details.
1281
1282The backend program must not daemonize itself, but it may be
1283daemonized by the management layer. It may also have a restricted
1284access to the system.
1285
1286File descriptors 0, 1 and 2 will exist, and have regular
1287stdin/stdout/stderr usage (they may have been redirected to /dev/null
1288by the management layer, or to a log handler).
1289
1290The backend program must end (as quickly and cleanly as possible) when
1291the SIGTERM signal is received. Eventually, it may receive SIGKILL by
1292the management layer after a few seconds.
1293
1294The following command line options have an expected behaviour. They
1295are mandatory, unless explicitly said differently:
1296
1297--socket-path=PATH
1298
1299  This option specify the location of the vhost-user Unix domain socket.
1300  It is incompatible with --fd.
1301
1302--fd=FDNUM
1303
1304  When this argument is given, the backend program is started with the
1305  vhost-user socket as file descriptor FDNUM. It is incompatible with
1306  --socket-path.
1307
1308--print-capabilities
1309
1310  Output to stdout the backend capabilities in JSON format, and then
1311  exit successfully. Other options and arguments should be ignored, and
1312  the backend program should not perform its normal function.  The
1313  capabilities can be reported dynamically depending on the host
1314  capabilities.
1315
1316The JSON output is described in the ``vhost-user.json`` schema, by
1317```@VHostUserBackendCapabilities``.  Example:
1318
1319.. code:: json
1320
1321  {
1322    "type": "foo",
1323    "features": [
1324      "feature-a",
1325      "feature-b"
1326    ]
1327  }
1328
1329vhost-user-input
1330----------------
1331
1332Command line options:
1333
1334--evdev-path=PATH
1335
1336  Specify the linux input device.
1337
1338  (optional)
1339
1340--no-grab
1341
1342  Do no request exclusive access to the input device.
1343
1344  (optional)
1345
1346vhost-user-gpu
1347--------------
1348
1349Command line options:
1350
1351--render-node=PATH
1352
1353  Specify the GPU DRM render node.
1354
1355  (optional)
1356
1357--virgl
1358
1359  Enable virgl rendering support.
1360
1361  (optional)
1362