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