1 =======================
2 Vhost-user-gpu Protocol
3 =======================
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
9 .. contents:: Table of Contents
14 The vhost-user-gpu protocol is aiming at sharing the rendering result
15 of a virtio-gpu, done from a vhost-user slave process to a vhost-user
16 master process (such as QEMU). It bears a resemblance to a display
17 server protocol, if you consider QEMU as the display server and the
18 slave as the client, but in a very limited way. Typically, it will
19 work by setting a scanout/display configuration, before sending flush
20 events for the display updates. It will also update the cursor shape
23 The protocol is sent over a UNIX domain stream socket, since it uses
24 socket ancillary data to share opened file descriptors (DMABUF fds or
25 shared memory). The socket is usually obtained via
26 ``VHOST_USER_GPU_SET_SOCKET``.
28 Requests are sent by the *slave*, and the optional replies by the
34 Unless specified differently, numbers are in the machine native byte
37 A vhost-user-gpu message (request and reply) consists of 3 header
40 +---------+-------+------+---------+
41 | request | flags | size | payload |
42 +---------+-------+------+---------+
47 :request: ``u32``, type of the request
49 :flags: ``u32``, 32-bit bit field:
51 - Bit 2 is the reply flag - needs to be set on each reply
53 :size: ``u32``, size of the payload
58 Depending on the request type, **payload** can be:
63 +------------+---+---+
64 | scanout-id | x | y |
65 +------------+---+---+
67 :scanout-id: ``u32``, the scanout where the cursor is located
69 :x/y: ``u32``, the cursor postion
71 VhostUserGpuCursorUpdate
72 ^^^^^^^^^^^^^^^^^^^^^^^^
74 +-----+-------+-------+--------+
75 | pos | hot_x | hot_y | cursor |
76 +-----+-------+-------+--------+
78 :pos: a ``VhostUserGpuCursorPos``, the cursor location
80 :hot_x/hot_y: ``u32``, the cursor hot location
82 :cursor: ``[u32; 64 * 64]``, 64x64 RGBA cursor data (PIXMAN_a8r8g8b8 format)
87 +------------+---+---+
88 | scanout-id | w | h |
89 +------------+---+---+
91 :scanout-id: ``u32``, the scanout configuration to set
93 :w/h: ``u32``, the scanout width/height size
98 +------------+---+---+---+---+------+
99 | scanout-id | x | y | w | h | data |
100 +------------+---+---+---+---+------+
102 :scanout-id: ``u32``, the scanout content to update
104 :x/y/w/h: ``u32``, region of the update
106 :data: RGB data (PIXMAN_x8r8g8b8 format)
108 VhostUserGpuDMABUFScanout
109 ^^^^^^^^^^^^^^^^^^^^^^^^^
111 +------------+---+---+---+---+-----+-----+--------+-------+--------+
112 | scanout-id | x | y | w | h | fdw | fwh | stride | flags | fourcc |
113 +------------+---+---+---+---+-----+-----+--------+-------+--------+
115 :scanout-id: ``u32``, the scanout configuration to set
117 :x/y: ``u32``, the location of the scanout within the DMABUF
119 :w/h: ``u32``, the scanout width/height size
121 :fdw/fdh/stride/flags: ``u32``, the DMABUF width/height/stride/flags
123 :fourcc: ``i32``, the DMABUF fourcc
129 In QEMU the vhost-user-gpu message is implemented with the following struct:
133 typedef struct VhostUserGpuMsg {
134 uint32_t request; /* VhostUserGpuRequest */
136 uint32_t size; /* the following payload size */
138 VhostUserGpuCursorPos cursor_pos;
139 VhostUserGpuCursorUpdate cursor_update;
140 VhostUserGpuScanout scanout;
141 VhostUserGpuUpdate update;
142 VhostUserGpuDMABUFScanout dmabuf_scanout;
143 struct virtio_gpu_resp_display_info display_info;
146 } QEMU_PACKED VhostUserGpuMsg;
153 As the protocol may need to evolve, new messages and communication
154 changes are negotiated thanks to preliminary
155 ``VHOST_USER_GPU_GET_PROTOCOL_FEATURES`` and
156 ``VHOST_USER_GPU_SET_PROTOCOL_FEATURES`` requests.
164 ``VHOST_USER_GPU_GET_PROTOCOL_FEATURES``
166 :request payload: N/A
167 :reply payload: ``u64``
169 Get the supported protocol features bitmask.
171 ``VHOST_USER_GPU_SET_PROTOCOL_FEATURES``
173 :request payload: ``u64``
176 Enable protocol features using a bitmask.
178 ``VHOST_USER_GPU_GET_DISPLAY_INFO``
180 :request payload: N/A
181 :reply payload: ``struct virtio_gpu_resp_display_info`` (from virtio specification)
183 Get the preferred display configuration.
185 ``VHOST_USER_GPU_CURSOR_POS``
187 :request payload: ``VhostUserGpuCursorPos``
190 Set/show the cursor position.
192 ``VHOST_USER_GPU_CURSOR_POS_HIDE``
194 :request payload: ``VhostUserGpuCursorPos``
199 ``VHOST_USER_GPU_CURSOR_UPDATE``
201 :request payload: ``VhostUserGpuCursorUpdate``
204 Update the cursor shape and location.
206 ``VHOST_USER_GPU_SCANOUT``
208 :request payload: ``VhostUserGpuScanout``
211 Set the scanout resolution. To disable a scanout, the dimensions
212 width/height are set to 0.
214 ``VHOST_USER_GPU_UPDATE``
216 :request payload: ``VhostUserGpuUpdate``
219 Update the scanout content. The data payload contains the graphical bits.
220 The display should be flushed and presented.
222 ``VHOST_USER_GPU_DMABUF_SCANOUT``
224 :request payload: ``VhostUserGpuDMABUFScanout``
227 Set the scanout resolution/configuration, and share a DMABUF file
228 descriptor for the scanout content, which is passed as ancillary
229 data. To disable a scanout, the dimensions width/height are set
230 to 0, there is no file descriptor passed.
232 ``VHOST_USER_GPU_DMABUF_UPDATE``
234 :request payload: ``VhostUserGpuUpdate``
235 :reply payload: empty payload
237 The display should be flushed and presented according to updated
238 region from ``VhostUserGpuUpdate``.
240 Note: there is no data payload, since the scanout is shared thanks
241 to DMABUF, that must have been set previously with
242 ``VHOST_USER_GPU_DMABUF_SCANOUT``.