xref: /openbmc/qemu/qapi/char.json (revision 04e3aabd)
1# -*- Mode: Python -*-
2#
3
4##
5# = Character devices
6##
7
8{ 'include': 'sockets.json' }
9
10##
11# @ChardevInfo:
12#
13# Information about a character device.
14#
15# @label: the label of the character device
16#
17# @filename: the filename of the character device
18#
19# @frontend-open: shows whether the frontend device attached to this backend
20#                 (eg. with the chardev=... option) is in open or closed state
21#                 (since 2.1)
22#
23# Notes: @filename is encoded using the QEMU command line character device
24#        encoding.  See the QEMU man page for details.
25#
26# Since: 0.14.0
27##
28{ 'struct': 'ChardevInfo', 'data': {'label': 'str',
29                                  'filename': 'str',
30                                  'frontend-open': 'bool'} }
31
32##
33# @query-chardev:
34#
35# Returns information about current character devices.
36#
37# Returns: a list of @ChardevInfo
38#
39# Since: 0.14.0
40#
41# Example:
42#
43# -> { "execute": "query-chardev" }
44# <- {
45#       "return": [
46#          {
47#             "label": "charchannel0",
48#             "filename": "unix:/var/lib/libvirt/qemu/seabios.rhel6.agent,server",
49#             "frontend-open": false
50#          },
51#          {
52#             "label": "charmonitor",
53#             "filename": "unix:/var/lib/libvirt/qemu/seabios.rhel6.monitor,server",
54#             "frontend-open": true
55#          },
56#          {
57#             "label": "charserial0",
58#             "filename": "pty:/dev/pts/2",
59#             "frontend-open": true
60#          }
61#       ]
62#    }
63#
64##
65{ 'command': 'query-chardev', 'returns': ['ChardevInfo'] }
66
67##
68# @ChardevBackendInfo:
69#
70# Information about a character device backend
71#
72# @name: The backend name
73#
74# Since: 2.0
75##
76{ 'struct': 'ChardevBackendInfo', 'data': {'name': 'str'} }
77
78##
79# @query-chardev-backends:
80#
81# Returns information about character device backends.
82#
83# Returns: a list of @ChardevBackendInfo
84#
85# Since: 2.0
86#
87# Example:
88#
89# -> { "execute": "query-chardev-backends" }
90# <- {
91#       "return":[
92#          {
93#             "name":"udp"
94#          },
95#          {
96#             "name":"tcp"
97#          },
98#          {
99#             "name":"unix"
100#          },
101#          {
102#             "name":"spiceport"
103#          }
104#       ]
105#    }
106#
107##
108{ 'command': 'query-chardev-backends', 'returns': ['ChardevBackendInfo'] }
109
110##
111# @DataFormat:
112#
113# An enumeration of data format.
114#
115# @utf8: Data is a UTF-8 string (RFC 3629)
116#
117# @base64: Data is Base64 encoded binary (RFC 3548)
118#
119# Since: 1.4
120##
121{ 'enum': 'DataFormat',
122  'data': [ 'utf8', 'base64' ] }
123
124##
125# @ringbuf-write:
126#
127# Write to a ring buffer character device.
128#
129# @device: the ring buffer character device name
130#
131# @data: data to write
132#
133# @format: data encoding (default 'utf8').
134#          - base64: data must be base64 encoded text.  Its binary
135#            decoding gets written.
136#          - utf8: data's UTF-8 encoding is written
137#          - data itself is always Unicode regardless of format, like
138#            any other string.
139#
140# Returns: Nothing on success
141#
142# Since: 1.4
143#
144# Example:
145#
146# -> { "execute": "ringbuf-write",
147#      "arguments": { "device": "foo",
148#                     "data": "abcdefgh",
149#                     "format": "utf8" } }
150# <- { "return": {} }
151#
152##
153{ 'command': 'ringbuf-write',
154  'data': {'device': 'str', 'data': 'str',
155           '*format': 'DataFormat'} }
156
157##
158# @ringbuf-read:
159#
160# Read from a ring buffer character device.
161#
162# @device: the ring buffer character device name
163#
164# @size: how many bytes to read at most
165#
166# @format: data encoding (default 'utf8').
167#          - base64: the data read is returned in base64 encoding.
168#          - utf8: the data read is interpreted as UTF-8.
169#            Bug: can screw up when the buffer contains invalid UTF-8
170#            sequences, NUL characters, after the ring buffer lost
171#            data, and when reading stops because the size limit is
172#            reached.
173#          - The return value is always Unicode regardless of format,
174#            like any other string.
175#
176# Returns: data read from the device
177#
178# Since: 1.4
179#
180# Example:
181#
182# -> { "execute": "ringbuf-read",
183#      "arguments": { "device": "foo",
184#                     "size": 1000,
185#                     "format": "utf8" } }
186# <- { "return": "abcdefgh" }
187#
188##
189{ 'command': 'ringbuf-read',
190  'data': {'device': 'str', 'size': 'int', '*format': 'DataFormat'},
191  'returns': 'str' }
192
193##
194# @ChardevCommon:
195#
196# Configuration shared across all chardev backends
197#
198# @logfile: The name of a logfile to save output
199# @logappend: true to append instead of truncate
200#             (default to false to truncate)
201#
202# Since: 2.6
203##
204{ 'struct': 'ChardevCommon', 'data': { '*logfile': 'str',
205                                       '*logappend': 'bool' } }
206
207##
208# @ChardevFile:
209#
210# Configuration info for file chardevs.
211#
212# @in:  The name of the input file
213# @out: The name of the output file
214# @append: Open the file in append mode (default false to
215#          truncate) (Since 2.6)
216#
217# Since: 1.4
218##
219{ 'struct': 'ChardevFile', 'data': { '*in' : 'str',
220                                   'out' : 'str',
221                                   '*append': 'bool' },
222  'base': 'ChardevCommon' }
223
224##
225# @ChardevHostdev:
226#
227# Configuration info for device and pipe chardevs.
228#
229# @device: The name of the special file for the device,
230#          i.e. /dev/ttyS0 on Unix or COM1: on Windows
231#
232# Since: 1.4
233##
234{ 'struct': 'ChardevHostdev', 'data': { 'device' : 'str' },
235  'base': 'ChardevCommon' }
236
237##
238# @ChardevSocket:
239#
240# Configuration info for (stream) socket chardevs.
241#
242# @addr: socket address to listen on (server=true)
243#        or connect to (server=false)
244# @tls-creds: the ID of the TLS credentials object (since 2.6)
245# @server: create server socket (default: true)
246# @wait: wait for incoming connection on server
247#        sockets (default: false).
248# @nodelay: set TCP_NODELAY socket option (default: false)
249# @telnet: enable telnet protocol on server
250#          sockets (default: false)
251# @tn3270: enable tn3270 protocol on server
252#          sockets (default: false) (Since: 2.10)
253# @reconnect: For a client socket, if a socket is disconnected,
254#          then attempt a reconnect after the given number of seconds.
255#          Setting this to zero disables this function. (default: 0)
256#          (Since: 2.2)
257#
258# Since: 1.4
259##
260{ 'struct': 'ChardevSocket', 'data': { 'addr'       : 'SocketAddressLegacy',
261                                     '*tls-creds'  : 'str',
262                                     '*server'    : 'bool',
263                                     '*wait'      : 'bool',
264                                     '*nodelay'   : 'bool',
265                                     '*telnet'    : 'bool',
266                                     '*tn3270'    : 'bool',
267                                     '*reconnect' : 'int' },
268  'base': 'ChardevCommon' }
269
270##
271# @ChardevUdp:
272#
273# Configuration info for datagram socket chardevs.
274#
275# @remote: remote address
276# @local: local address
277#
278# Since: 1.5
279##
280{ 'struct': 'ChardevUdp', 'data': { 'remote' : 'SocketAddressLegacy',
281                                  '*local' : 'SocketAddressLegacy' },
282  'base': 'ChardevCommon' }
283
284##
285# @ChardevMux:
286#
287# Configuration info for mux chardevs.
288#
289# @chardev: name of the base chardev.
290#
291# Since: 1.5
292##
293{ 'struct': 'ChardevMux', 'data': { 'chardev' : 'str' },
294  'base': 'ChardevCommon' }
295
296##
297# @ChardevStdio:
298#
299# Configuration info for stdio chardevs.
300#
301# @signal: Allow signals (such as SIGINT triggered by ^C)
302#          be delivered to qemu.  Default: true in -nographic mode,
303#          false otherwise.
304#
305# Since: 1.5
306##
307{ 'struct': 'ChardevStdio', 'data': { '*signal' : 'bool' },
308  'base': 'ChardevCommon' }
309
310
311##
312# @ChardevSpiceChannel:
313#
314# Configuration info for spice vm channel chardevs.
315#
316# @type: kind of channel (for example vdagent).
317#
318# Since: 1.5
319##
320{ 'struct': 'ChardevSpiceChannel', 'data': { 'type'  : 'str' },
321  'base': 'ChardevCommon' }
322
323##
324# @ChardevSpicePort:
325#
326# Configuration info for spice port chardevs.
327#
328# @fqdn: name of the channel (see docs/spice-port-fqdn.txt)
329#
330# Since: 1.5
331##
332{ 'struct': 'ChardevSpicePort', 'data': { 'fqdn'  : 'str' },
333  'base': 'ChardevCommon' }
334
335##
336# @ChardevVC:
337#
338# Configuration info for virtual console chardevs.
339#
340# @width:  console width,  in pixels
341# @height: console height, in pixels
342# @cols:   console width,  in chars
343# @rows:   console height, in chars
344#
345# Since: 1.5
346##
347{ 'struct': 'ChardevVC', 'data': { '*width'  : 'int',
348                                 '*height' : 'int',
349                                 '*cols'   : 'int',
350                                 '*rows'   : 'int' },
351  'base': 'ChardevCommon' }
352
353##
354# @ChardevRingbuf:
355#
356# Configuration info for ring buffer chardevs.
357#
358# @size: ring buffer size, must be power of two, default is 65536
359#
360# Since: 1.5
361##
362{ 'struct': 'ChardevRingbuf', 'data': { '*size'  : 'int' },
363  'base': 'ChardevCommon' }
364
365##
366# @ChardevBackend:
367#
368# Configuration info for the new chardev backend.
369#
370# Since: 1.4 (testdev since 2.2, wctablet since 2.9)
371##
372{ 'union': 'ChardevBackend', 'data': { 'file'   : 'ChardevFile',
373                                       'serial' : 'ChardevHostdev',
374                                       'parallel': 'ChardevHostdev',
375                                       'pipe'   : 'ChardevHostdev',
376                                       'socket' : 'ChardevSocket',
377                                       'udp'    : 'ChardevUdp',
378                                       'pty'    : 'ChardevCommon',
379                                       'null'   : 'ChardevCommon',
380                                       'mux'    : 'ChardevMux',
381                                       'msmouse': 'ChardevCommon',
382                                       'wctablet' : 'ChardevCommon',
383                                       'braille': 'ChardevCommon',
384                                       'testdev': 'ChardevCommon',
385                                       'stdio'  : 'ChardevStdio',
386                                       'console': 'ChardevCommon',
387                                       'spicevmc' : 'ChardevSpiceChannel',
388                                       'spiceport' : 'ChardevSpicePort',
389                                       'vc'     : 'ChardevVC',
390                                       'ringbuf': 'ChardevRingbuf',
391                                       # next one is just for compatibility
392                                       'memory' : 'ChardevRingbuf' } }
393
394##
395# @ChardevReturn:
396#
397# Return info about the chardev backend just created.
398#
399# @pty: name of the slave pseudoterminal device, present if
400#       and only if a chardev of type 'pty' was created
401#
402# Since: 1.4
403##
404{ 'struct' : 'ChardevReturn', 'data': { '*pty' : 'str' } }
405
406##
407# @chardev-add:
408#
409# Add a character device backend
410#
411# @id: the chardev's ID, must be unique
412# @backend: backend type and parameters
413#
414# Returns: ChardevReturn.
415#
416# Since: 1.4
417#
418# Example:
419#
420# -> { "execute" : "chardev-add",
421#      "arguments" : { "id" : "foo",
422#                      "backend" : { "type" : "null", "data" : {} } } }
423# <- { "return": {} }
424#
425# -> { "execute" : "chardev-add",
426#      "arguments" : { "id" : "bar",
427#                      "backend" : { "type" : "file",
428#                                    "data" : { "out" : "/tmp/bar.log" } } } }
429# <- { "return": {} }
430#
431# -> { "execute" : "chardev-add",
432#      "arguments" : { "id" : "baz",
433#                      "backend" : { "type" : "pty", "data" : {} } } }
434# <- { "return": { "pty" : "/dev/pty/42" } }
435#
436##
437{ 'command': 'chardev-add', 'data': {'id'      : 'str',
438                                     'backend' : 'ChardevBackend' },
439  'returns': 'ChardevReturn' }
440
441##
442# @chardev-change:
443#
444# Change a character device backend
445#
446# @id: the chardev's ID, must exist
447# @backend: new backend type and parameters
448#
449# Returns: ChardevReturn.
450#
451# Since: 2.10
452#
453# Example:
454#
455# -> { "execute" : "chardev-change",
456#      "arguments" : { "id" : "baz",
457#                      "backend" : { "type" : "pty", "data" : {} } } }
458# <- { "return": { "pty" : "/dev/pty/42" } }
459#
460# -> {"execute" : "chardev-change",
461#     "arguments" : {
462#         "id" : "charchannel2",
463#         "backend" : {
464#             "type" : "socket",
465#             "data" : {
466#                 "addr" : {
467#                     "type" : "unix" ,
468#                     "data" : {
469#                         "path" : "/tmp/charchannel2.socket"
470#                     }
471#                  },
472#                  "server" : true,
473#                  "wait" : false }}}}
474# <- {"return": {}}
475#
476##
477{ 'command': 'chardev-change', 'data': {'id'      : 'str',
478                                        'backend' : 'ChardevBackend' },
479  'returns': 'ChardevReturn' }
480
481##
482# @chardev-remove:
483#
484# Remove a character device backend
485#
486# @id: the chardev's ID, must exist and not be in use
487#
488# Returns: Nothing on success
489#
490# Since: 1.4
491#
492# Example:
493#
494# -> { "execute": "chardev-remove", "arguments": { "id" : "foo" } }
495# <- { "return": {} }
496#
497##
498{ 'command': 'chardev-remove', 'data': {'id': 'str'} }
499
500##
501# @chardev-send-break:
502#
503# Send a break to a character device
504#
505# @id: the chardev's ID, must exist
506#
507# Returns: Nothing on success
508#
509# Since: 2.10
510#
511# Example:
512#
513# -> { "execute": "chardev-send-break", "arguments": { "id" : "foo" } }
514# <- { "return": {} }
515#
516##
517{ 'command': 'chardev-send-break', 'data': {'id': 'str'} }
518
519##
520# @VSERPORT_CHANGE:
521#
522# Emitted when the guest opens or closes a virtio-serial port.
523#
524# @id: device identifier of the virtio-serial port
525#
526# @open: true if the guest has opened the virtio-serial port
527#
528# Since: 2.1
529#
530# Example:
531#
532# <- { "event": "VSERPORT_CHANGE",
533#      "data": { "id": "channel0", "open": true },
534#      "timestamp": { "seconds": 1401385907, "microseconds": 422329 } }
535#
536##
537{ 'event': 'VSERPORT_CHANGE',
538  'data': { 'id': 'str', 'open': 'bool' } }
539