6 Barrier is a KVM (Keyboard-Video-Mouse) software forked from Symless's
9 See https://github.com/debauchee/barrier
13 Generally, mouse and keyboard are grabbed through the QEMU video
16 But when we want to use a video graphic adapter via a PCI passthrough
17 there is no way to provide the keyboard and mouse inputs to the VM
18 except by plugging a second set of mouse and keyboard to the host
19 or by installing a KVM software in the guest OS.
21 The QEMU Barrier client avoids this by implementing directly the Barrier
24 This protocol is enabled by adding an input-barrier object to QEMU.
26 Syntax: input-barrier,id=<object-id>,name=<guest display name>
27 [,server=<barrier server address>][,port=<barrier server port>]
28 [,x-origin=<x-origin>][,y-origin=<y-origin>]
29 [,width=<width>][,height=<height>]
31 The object can be added on the QEMU command line, for instance with:
33 ... -object input-barrier,id=barrier0,name=VM-1 ...
35 where VM-1 is the name the display configured int the Barrier server
36 on the host providing the mouse and the keyboard events.
38 by default <barrier server address> is "localhost", port is 24800,
39 <x-origin> and <y-origin> are set to 0, <width> and <height> to
42 If Barrier server is stopped QEMU needs to be reconnected manually,
43 by removing and re-adding the input-barrier object, for instance
44 with the help of the HMP monitor:
46 (qemu) object_del barrier0
47 (qemu) object_add input-barrier,id=barrier0,name=VM-1
51 Message format between the server and client is in two parts:
53 1- the payload length is a 32bit integer in network endianness,
56 The payload starts with a 4byte string (without NUL) which is the
57 command. The first command between the server and the client
58 is the only command not encoded on 4 bytes ("Barrier").
59 The remaining part of the payload is decoded according to the command.
61 * Protocol Description (from barrier/src/lib/barrier/protocol_types.h)
63 - barrierCmdHello "Barrier"
65 Direction: server -> client
66 Parameters: { int16_t minor, int16_t major }
70 minor = protocol major version number supported by server
71 major = protocol minor version number supported by server
73 - barrierCmdHelloBack "Barrier"
75 Direction: client ->server
76 Parameters: { int16_t minor, int16_t major, char *name}
79 Respond to hello from server
80 minor = protocol major version number supported by client
81 major = protocol minor version number supported by client
84 - barrierCmdDInfo "DINF"
86 Direction: client ->server
87 Parameters: { int16_t x_origin, int16_t y_origin, int16_t width, int16_t height, int16_t x, int16_t y}
90 The client screen must send this message in response to the
91 barrierCmdQInfo message. It must also send this message when the
92 screen's resolution changes. In this case, the client screen should
93 ignore any barrierCmdDMouseMove messages until it receives a
94 barrierCmdCInfoAck in order to prevent attempts to move the mouse off
97 - barrierCmdCNoop "CNOP"
99 Direction: client -> server
105 - barrierCmdCClose "CBYE"
107 Direction: server -> client
113 - barrierCmdCEnter "CINN"
115 Direction: server -> client
116 Parameters: { int16_t x, int16_t y, int32_t seq, int16_t modifier }
120 x,y = entering screen absolute coordinates
121 seq = sequence number, which is used to order messages between
122 screens. the secondary screen must return this number
124 modifier = modifier key mask. this will have bits set for each
125 toggle modifier key that is activated on entry to the
126 screen. the secondary screen should adjust its toggle
127 modifiers to reflect that state.
129 - barrierCmdCLeave "COUT"
131 Direction: server -> client
135 Leaving screen. the secondary screen should send clipboard data in
136 response to this message for those clipboards that it has grabbed
137 (i.e. has sent a barrierCmdCClipboard for and has not received a
138 barrierCmdCClipboard for with a greater sequence number) and that
139 were grabbed or have changed since the last leave.
141 - barrierCmdCClipboard "CCLP"
143 Direction: server -> client
144 Parameters: { int8_t id, int32_t seq }
147 Grab clipboard. Sent by screen when some other app on that screen
149 id = the clipboard identifier
150 seq = sequence number. Client must use the sequence number passed in
151 the most recent barrierCmdCEnter. the server always sends 0.
153 - barrierCmdCScreenSaver "CSEC"
155 Direction: server -> client
156 Parameters: { int8_t started }
160 started = Screensaver on primary has started (1) or closed (0)
162 - barrierCmdCResetOptions "CROP"
164 Direction: server -> client
168 Reset options. Client should reset all of its options to their
171 - barrierCmdCInfoAck "CIAK"
173 Direction: server -> client
177 Resolution change acknowledgment. Sent by server in response to a
178 client screen's barrierCmdDInfo. This is sent for every
179 barrierCmdDInfo, whether or not the server had sent a barrierCmdQInfo.
181 - barrierCmdCKeepAlive "CALV"
183 Direction: server -> client
187 Keep connection alive. Sent by the server periodically to verify
188 that connections are still up and running. clients must reply in
189 kind on receipt. if the server gets an error sending the message or
190 does not receive a reply within a reasonable time then the server
191 disconnects the client. if the client doesn't receive these (or any
192 message) periodically then it should disconnect from the server. the
193 appropriate interval is defined by an option.
195 - barrierCmdDKeyDown "DKDN"
197 Direction: server -> client
198 Parameters: { int16_t keyid, int16_t modifier [,int16_t button] }
203 modified = modified mask
204 button = X11 Xkb keycode (optional)
206 - barrierCmdDKeyRepeat "DKRP"
208 Direction: server -> client
209 Parameters: { int16_t keyid, int16_t modifier, int16_t repeat [,int16_t button] }
214 modified = modified mask
215 repeat = number of repeats
216 button = X11 Xkb keycode (optional)
218 - barrierCmdDKeyUp "DKUP"
220 Direction: server -> client
221 Parameters: { int16_t keyid, int16_t modifier [,int16_t button] }
226 modified = modified mask
227 button = X11 Xkb keycode (optional)
229 - barrierCmdDMouseDown "DMDN"
231 Direction: server -> client
232 Parameters: { int8_t button }
235 Mouse button pressed.
238 - barrierCmdDMouseUp "DMUP"
240 Direction: server -> client
241 Parameters: { int8_t button }
244 Mouse button release.
247 - barrierCmdDMouseMove "DMMV"
249 Direction: server -> client
250 Parameters: { int16_t x, int16_t y }
253 Absolute mouse moved.
254 x,y = absolute screen coordinates
256 - barrierCmdDMouseRelMove "DMRM"
258 Direction: server -> client
259 Parameters: { int16_t x, int16_t y }
262 Relative mouse moved.
263 x,y = r relative screen coordinates
265 - barrierCmdDMouseWheel "DMWM"
267 Direction: server -> client
268 Parameters: { int16_t x , int16_t y } or { int16_t y }
271 Mouse scroll. The delta should be +120 for one tick forward (away
272 from the user) or right and -120 for one tick backward (toward the
277 - barrierCmdDClipboard "DCLP"
279 Direction: server -> client
280 Parameters: { int8_t id, int32_t seq, int8_t mark, char *data }
285 seq = sequence number. The sequence number is 0 when sent by the
286 server. Client screens should use the/ sequence number from
287 the most recent barrierCmdCEnter.
289 - barrierCmdDSetOptions "DSOP"
291 Direction: server -> client
292 Parameters: { int32 t nb, { int32_t id, int32_t val }[] }
295 Set options. Client should set the given option/value pairs.
296 nb = numbers of { id, val } entries
298 val = option new value
300 - barrierCmdDFileTransfer "DFTR"
302 Direction: server -> client
303 Parameters: { int8_t mark, char *content }
307 mark = 0 means the content followed is the file size
308 1 means the content followed is the chunk data
309 2 means the file transfer is finished
311 - barrierCmdDDragInfo "DDRG" int16_t char *
313 Direction: server -> client
314 Parameters: { int16_t nb, char *content }
318 nb = number of dragging objects
319 content = object's directory
321 - barrierCmdQInfo "QINF"
323 Direction: server -> client
328 Client should reply with a barrierCmdDInfo
330 - barrierCmdEIncompatible "EICV"
332 Direction: server -> client
333 Parameters: { int16_t nb, major *minor }
336 Incompatible version.
337 major = major version
338 minor = minor version
340 - barrierCmdEBusy "EBSY"
342 Direction: server -> client
346 Name provided when connecting is already in use.
348 - barrierCmdEUnknown "EUNK"
350 Direction: server -> client
354 Unknown client. Name provided when connecting is not in primary's
355 screen configuration map.
357 - barrierCmdEBad "EBAD"
359 Direction: server -> client
363 Protocol violation. Server should disconnect after sending this
369 - Manage SetOptions/ResetOptions commands