xref: /openbmc/qemu/qapi/char.json (revision c76c86fb)
1# -*- Mode: Python -*-
2# vim: filetype=python
3#
4
5##
6# = Character devices
7##
8
9{ 'include': 'sockets.json' }
10
11##
12# @ChardevInfo:
13#
14# Information about a character device.
15#
16# @label: the label of the character device
17#
18# @filename: the filename of the character device
19#
20# @frontend-open: shows whether the frontend device attached to this
21#     backend (e.g. with the chardev=... option) is in open or closed
22#     state (since 2.1)
23#
24# .. note:: @filename is encoded using the QEMU command line character
25#    device encoding.  See the QEMU man page for details.
26#
27# Since: 0.14
28##
29{ 'struct': 'ChardevInfo',
30  'data': { 'label': 'str',
31            'filename': 'str',
32            'frontend-open': 'bool' } }
33
34##
35# @query-chardev:
36#
37# Returns information about current character devices.
38#
39# Returns: a list of @ChardevInfo
40#
41# Since: 0.14
42#
43# .. qmp-example::
44#
45#     -> { "execute": "query-chardev" }
46#     <- {
47#           "return": [
48#              {
49#                 "label": "charchannel0",
50#                 "filename": "unix:/var/lib/libvirt/qemu/seabios.rhel6.agent,server=on",
51#                 "frontend-open": false
52#              },
53#              {
54#                 "label": "charmonitor",
55#                 "filename": "unix:/var/lib/libvirt/qemu/seabios.rhel6.monitor,server=on",
56#                 "frontend-open": true
57#              },
58#              {
59#                 "label": "charserial0",
60#                 "filename": "pty:/dev/pts/2",
61#                 "frontend-open": true
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# .. qmp-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{ 'command': 'query-chardev-backends', 'returns': ['ChardevBackendInfo'] }
110
111##
112# @DataFormat:
113#
114# An enumeration of data format.
115#
116# @utf8: Data is a UTF-8 string (RFC 3629)
117#
118# @base64: Data is Base64 encoded binary (RFC 3548)
119#
120# Since: 1.4
121##
122{ 'enum': 'DataFormat',
123  'data': [ 'utf8', 'base64' ] }
124
125##
126# @ringbuf-write:
127#
128# Write to a ring buffer character device.
129#
130# @device: the ring buffer character device name
131#
132# @data: data to write
133#
134# @format: data encoding (default 'utf8').
135#
136#     - base64: data must be base64 encoded text.  Its binary decoding
137#       gets written.
138#     - utf8: data's UTF-8 encoding is written
139#     - data itself is always Unicode regardless of format, like any
140#       other string.
141#
142# Since: 1.4
143#
144# .. qmp-example::
145#
146#     -> { "execute": "ringbuf-write",
147#          "arguments": { "device": "foo",
148#                         "data": "abcdefgh",
149#                         "format": "utf8" } }
150#     <- { "return": {} }
151##
152{ 'command': 'ringbuf-write',
153  'data': { 'device': 'str',
154            '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#
168#     - base64: the data read is returned in base64 encoding.
169#     - utf8: the data read is interpreted as UTF-8.
170#       Bug: can screw up when the buffer contains invalid UTF-8
171#       sequences, NUL characters, after the ring buffer lost data,
172#       and when reading stops because the size limit is reached.
173#     - The return value is always Unicode regardless of format, like
174#       any other string.
175#
176# Returns: data read from the device
177#
178# Since: 1.4
179#
180# .. qmp-example::
181#
182#     -> { "execute": "ringbuf-read",
183#          "arguments": { "device": "foo",
184#                         "size": 1000,
185#                         "format": "utf8" } }
186#     <- { "return": "abcdefgh" }
187##
188{ 'command': 'ringbuf-read',
189  'data': {'device': 'str', 'size': 'int', '*format': 'DataFormat'},
190  'returns': 'str' }
191
192##
193# @ChardevCommon:
194#
195# Configuration shared across all chardev backends
196#
197# @logfile: The name of a logfile to save output
198#
199# @logappend: true to append instead of truncate (default to false to
200#     truncate)
201#
202# Since: 2.6
203##
204{ 'struct': 'ChardevCommon',
205  'data': { '*logfile': 'str',
206            '*logappend': 'bool' } }
207
208##
209# @ChardevFile:
210#
211# Configuration info for file chardevs.
212#
213# @in: The name of the input file
214#
215# @out: The name of the output file
216#
217# @append: Open the file in append mode (default false to truncate)
218#     (Since 2.6)
219#
220# Since: 1.4
221##
222{ 'struct': 'ChardevFile',
223  'data': { '*in': 'str',
224            'out': 'str',
225            '*append': 'bool' },
226  'base': 'ChardevCommon' }
227
228##
229# @ChardevHostdev:
230#
231# Configuration info for device and pipe chardevs.
232#
233# @device: The name of the special file for the device, i.e.
234#     /dev/ttyS0 on Unix or COM1: on Windows
235#
236# Since: 1.4
237##
238{ 'struct': 'ChardevHostdev',
239  'data': { 'device': 'str' },
240  'base': 'ChardevCommon' }
241
242##
243# @ChardevSocket:
244#
245# Configuration info for (stream) socket chardevs.
246#
247# @addr: socket address to listen on (server=true) or connect to
248#     (server=false)
249#
250# @tls-creds: the ID of the TLS credentials object (since 2.6)
251#
252# @tls-authz: the ID of the QAuthZ authorization object against which
253#     the client's x509 distinguished name will be validated.  This
254#     object is only resolved at time of use, so can be deleted and
255#     recreated on the fly while the chardev server is active.  If
256#     missing, it will default to denying access (since 4.0)
257#
258# @server: create server socket (default: true)
259#
260# @wait: wait for incoming connection on server sockets (default:
261#     false).  Silently ignored with server: false.  This use is
262#     deprecated.
263#
264# @nodelay: set TCP_NODELAY socket option (default: false)
265#
266# @telnet: enable telnet protocol on server sockets (default: false)
267#
268# @tn3270: enable tn3270 protocol on server sockets (default: false)
269#     (Since: 2.10)
270#
271# @websocket: enable websocket protocol on server sockets
272#     (default: false) (Since: 3.1)
273#
274# @reconnect: For a client socket, if a socket is disconnected, then
275#     attempt a reconnect after the given number of seconds.  Setting
276#     this to zero disables this function.  (default: 0) (Since: 2.2)
277#
278# Since: 1.4
279##
280{ 'struct': 'ChardevSocket',
281  'data': { 'addr': 'SocketAddressLegacy',
282            '*tls-creds': 'str',
283            '*tls-authz'  : 'str',
284            '*server': 'bool',
285            '*wait': 'bool',
286            '*nodelay': 'bool',
287            '*telnet': 'bool',
288            '*tn3270': 'bool',
289            '*websocket': 'bool',
290            '*reconnect': 'int' },
291  'base': 'ChardevCommon' }
292
293##
294# @ChardevUdp:
295#
296# Configuration info for datagram socket chardevs.
297#
298# @remote: remote address
299#
300# @local: local address
301#
302# Since: 1.5
303##
304{ 'struct': 'ChardevUdp',
305  'data': { 'remote': 'SocketAddressLegacy',
306            '*local': 'SocketAddressLegacy' },
307  'base': 'ChardevCommon' }
308
309##
310# @ChardevMux:
311#
312# Configuration info for mux chardevs.
313#
314# @chardev: name of the base chardev.
315#
316# Since: 1.5
317##
318{ 'struct': 'ChardevMux',
319  'data': { 'chardev': 'str' },
320  'base': 'ChardevCommon' }
321
322##
323# @ChardevStdio:
324#
325# Configuration info for stdio chardevs.
326#
327# @signal: Allow signals (such as SIGINT triggered by ^C) be delivered
328#     to qemu.  Default: true.
329#
330# Since: 1.5
331##
332{ 'struct': 'ChardevStdio',
333  'data': { '*signal': 'bool' },
334  'base': 'ChardevCommon' }
335
336##
337# @ChardevSpiceChannel:
338#
339# Configuration info for spice vm channel chardevs.
340#
341# @type: kind of channel (for example vdagent).
342#
343# Since: 1.5
344##
345{ 'struct': 'ChardevSpiceChannel',
346  'data': { 'type': 'str' },
347  'base': 'ChardevCommon',
348  'if': 'CONFIG_SPICE' }
349
350##
351# @ChardevSpicePort:
352#
353# Configuration info for spice port chardevs.
354#
355# @fqdn: name of the channel (see docs/spice-port-fqdn.txt)
356#
357# Since: 1.5
358##
359{ 'struct': 'ChardevSpicePort',
360  'data': { 'fqdn': 'str' },
361  'base': 'ChardevCommon',
362  'if': 'CONFIG_SPICE' }
363
364##
365# @ChardevDBus:
366#
367# Configuration info for DBus chardevs.
368#
369# @name: name of the channel (following docs/spice-port-fqdn.txt)
370#
371# Since: 7.0
372##
373{ 'struct': 'ChardevDBus',
374  'data': { 'name': 'str' },
375  'base': 'ChardevCommon',
376  'if': 'CONFIG_DBUS_DISPLAY' }
377
378##
379# @ChardevVC:
380#
381# Configuration info for virtual console chardevs.
382#
383# @width: console width, in pixels
384#
385# @height: console height, in pixels
386#
387# @cols: console width, in chars
388#
389# @rows: console height, in chars
390#
391# .. note:: The options are only effective when the VNC or SDL
392#    graphical display backend is active.  They are ignored with the
393#    GTK, Spice, VNC and D-Bus display backends.
394#
395# Since: 1.5
396##
397{ 'struct': 'ChardevVC',
398  'data': { '*width': 'int',
399            '*height': 'int',
400            '*cols': 'int',
401            '*rows': 'int' },
402  'base': 'ChardevCommon' }
403
404##
405# @ChardevRingbuf:
406#
407# Configuration info for ring buffer chardevs.
408#
409# @size: ring buffer size, must be power of two, default is 65536
410#
411# Since: 1.5
412##
413{ 'struct': 'ChardevRingbuf',
414  'data': { '*size': 'int' },
415  'base': 'ChardevCommon' }
416
417##
418# @ChardevQemuVDAgent:
419#
420# Configuration info for qemu vdagent implementation.
421#
422# @mouse: enable/disable mouse, default is enabled.
423#
424# @clipboard: enable/disable clipboard, default is disabled.
425#
426# Since: 6.1
427##
428{ 'struct': 'ChardevQemuVDAgent',
429  'data': { '*mouse': 'bool',
430            '*clipboard': 'bool' },
431  'base': 'ChardevCommon',
432  'if': 'CONFIG_SPICE_PROTOCOL' }
433
434##
435# @ChardevBackendKind:
436#
437# @file: regular files
438#
439# @serial: serial host device
440#
441# @parallel: parallel host device
442#
443# @pipe: pipes (since 1.5)
444#
445# @socket: stream socket
446#
447# @udp: datagram socket (since 1.5)
448#
449# @pty: pseudo-terminal
450#
451# @null: provides no input, throws away output
452#
453# @mux: (since 1.5)
454#
455# @msmouse: emulated Microsoft serial mouse (since 1.5)
456#
457# @wctablet: emulated Wacom Penpartner serial tablet (since 2.9)
458#
459# @braille: Baum Braille device (since 1.5)
460#
461# @testdev: device for test-suite control (since 2.2)
462#
463# @stdio: standard I/O (since 1.5)
464#
465# @console: Windows console (since 1.5)
466#
467# @spicevmc: spice vm channel (since 1.5)
468#
469# @spiceport: Spice port channel (since 1.5)
470#
471# @qemu-vdagent: Spice vdagent (since 6.1)
472#
473# @dbus: D-Bus channel (since 7.0)
474#
475# @vc: virtual console (since 1.5)
476#
477# @ringbuf: memory ring buffer (since 1.6)
478#
479# @memory: synonym for @ringbuf (since 1.5)
480#
481# Features:
482#
483# @deprecated: Member @memory is deprecated.  Use @ringbuf instead.
484#
485# Since: 1.4
486##
487{ 'enum': 'ChardevBackendKind',
488  'data': [ 'file',
489            { 'name': 'serial', 'if': 'HAVE_CHARDEV_SERIAL' },
490            { 'name': 'parallel', 'if': 'HAVE_CHARDEV_PARALLEL' },
491            'pipe',
492            'socket',
493            'udp',
494            'pty',
495            'null',
496            'mux',
497            'msmouse',
498            'wctablet',
499            { 'name': 'braille', 'if': 'CONFIG_BRLAPI' },
500            'testdev',
501            'stdio',
502            { 'name': 'console', 'if': 'CONFIG_WIN32' },
503            { 'name': 'spicevmc', 'if': 'CONFIG_SPICE' },
504            { 'name': 'spiceport', 'if': 'CONFIG_SPICE' },
505            { 'name': 'qemu-vdagent', 'if': 'CONFIG_SPICE_PROTOCOL' },
506            { 'name': 'dbus', 'if': 'CONFIG_DBUS_DISPLAY' },
507            'vc',
508            'ringbuf',
509            { 'name': 'memory', 'features': [ 'deprecated' ] } ] }
510
511##
512# @ChardevFileWrapper:
513#
514# @data: Configuration info for file chardevs
515#
516# Since: 1.4
517##
518{ 'struct': 'ChardevFileWrapper',
519  'data': { 'data': 'ChardevFile' } }
520
521##
522# @ChardevHostdevWrapper:
523#
524# @data: Configuration info for device and pipe chardevs
525#
526# Since: 1.4
527##
528{ 'struct': 'ChardevHostdevWrapper',
529  'data': { 'data': 'ChardevHostdev' } }
530
531##
532# @ChardevSocketWrapper:
533#
534# @data: Configuration info for (stream) socket chardevs
535#
536# Since: 1.4
537##
538{ 'struct': 'ChardevSocketWrapper',
539  'data': { 'data': 'ChardevSocket' } }
540
541##
542# @ChardevUdpWrapper:
543#
544# @data: Configuration info for datagram socket chardevs
545#
546# Since: 1.5
547##
548{ 'struct': 'ChardevUdpWrapper',
549  'data': { 'data': 'ChardevUdp' } }
550
551##
552# @ChardevCommonWrapper:
553#
554# @data: Configuration shared across all chardev backends
555#
556# Since: 2.6
557##
558{ 'struct': 'ChardevCommonWrapper',
559  'data': { 'data': 'ChardevCommon' } }
560
561##
562# @ChardevMuxWrapper:
563#
564# @data: Configuration info for mux chardevs
565#
566# Since: 1.5
567##
568{ 'struct': 'ChardevMuxWrapper',
569  'data': { 'data': 'ChardevMux' } }
570
571##
572# @ChardevStdioWrapper:
573#
574# @data: Configuration info for stdio chardevs
575#
576# Since: 1.5
577##
578{ 'struct': 'ChardevStdioWrapper',
579  'data': { 'data': 'ChardevStdio' } }
580
581##
582# @ChardevSpiceChannelWrapper:
583#
584# @data: Configuration info for spice vm channel chardevs
585#
586# Since: 1.5
587##
588{ 'struct': 'ChardevSpiceChannelWrapper',
589  'data': { 'data': 'ChardevSpiceChannel' },
590  'if': 'CONFIG_SPICE' }
591
592##
593# @ChardevSpicePortWrapper:
594#
595# @data: Configuration info for spice port chardevs
596#
597# Since: 1.5
598##
599{ 'struct': 'ChardevSpicePortWrapper',
600  'data': { 'data': 'ChardevSpicePort' },
601  'if': 'CONFIG_SPICE' }
602
603##
604# @ChardevQemuVDAgentWrapper:
605#
606# @data: Configuration info for qemu vdagent implementation
607#
608# Since: 6.1
609##
610{ 'struct': 'ChardevQemuVDAgentWrapper',
611  'data': { 'data': 'ChardevQemuVDAgent' },
612  'if': 'CONFIG_SPICE_PROTOCOL' }
613
614##
615# @ChardevDBusWrapper:
616#
617# @data: Configuration info for DBus chardevs
618#
619# Since: 7.0
620##
621{ 'struct': 'ChardevDBusWrapper',
622  'data': { 'data': 'ChardevDBus' },
623  'if': 'CONFIG_DBUS_DISPLAY' }
624
625##
626# @ChardevVCWrapper:
627#
628# @data: Configuration info for virtual console chardevs
629#
630# Since: 1.5
631##
632{ 'struct': 'ChardevVCWrapper',
633  'data': { 'data': 'ChardevVC' } }
634
635##
636# @ChardevRingbufWrapper:
637#
638# @data: Configuration info for ring buffer chardevs
639#
640# Since: 1.5
641##
642{ 'struct': 'ChardevRingbufWrapper',
643  'data': { 'data': 'ChardevRingbuf' } }
644
645##
646# @ChardevBackend:
647#
648# Configuration info for the new chardev backend.
649#
650# @type: backend type
651#
652# Since: 1.4
653##
654{ 'union': 'ChardevBackend',
655  'base': { 'type': 'ChardevBackendKind' },
656  'discriminator': 'type',
657  'data': { 'file': 'ChardevFileWrapper',
658            'serial': { 'type': 'ChardevHostdevWrapper',
659                        'if': 'HAVE_CHARDEV_SERIAL' },
660            'parallel': { 'type': 'ChardevHostdevWrapper',
661                          'if': 'HAVE_CHARDEV_PARALLEL' },
662            'pipe': 'ChardevHostdevWrapper',
663            'socket': 'ChardevSocketWrapper',
664            'udp': 'ChardevUdpWrapper',
665            'pty': 'ChardevCommonWrapper',
666            'null': 'ChardevCommonWrapper',
667            'mux': 'ChardevMuxWrapper',
668            'msmouse': 'ChardevCommonWrapper',
669            'wctablet': 'ChardevCommonWrapper',
670            'braille': { 'type': 'ChardevCommonWrapper',
671                         'if': 'CONFIG_BRLAPI' },
672            'testdev': 'ChardevCommonWrapper',
673            'stdio': 'ChardevStdioWrapper',
674            'console': { 'type': 'ChardevCommonWrapper',
675                         'if': 'CONFIG_WIN32' },
676            'spicevmc': { 'type': 'ChardevSpiceChannelWrapper',
677                          'if': 'CONFIG_SPICE' },
678            'spiceport': { 'type': 'ChardevSpicePortWrapper',
679                           'if': 'CONFIG_SPICE' },
680            'qemu-vdagent': { 'type': 'ChardevQemuVDAgentWrapper',
681                              'if': 'CONFIG_SPICE_PROTOCOL' },
682            'dbus': { 'type': 'ChardevDBusWrapper',
683                      'if': 'CONFIG_DBUS_DISPLAY' },
684            'vc': 'ChardevVCWrapper',
685            'ringbuf': 'ChardevRingbufWrapper',
686            'memory': 'ChardevRingbufWrapper' } }
687
688##
689# @ChardevReturn:
690#
691# Return info about the chardev backend just created.
692#
693# @pty: name of the slave pseudoterminal device, present if and only
694#     if a chardev of type 'pty' was created
695#
696# Since: 1.4
697##
698{ 'struct' : 'ChardevReturn',
699  'data': { '*pty': 'str' } }
700
701##
702# @chardev-add:
703#
704# Add a character device backend
705#
706# @id: the chardev's ID, must be unique
707#
708# @backend: backend type and parameters
709#
710# Returns: ChardevReturn.
711#
712# Since: 1.4
713#
714# .. qmp-example::
715#
716#     -> { "execute" : "chardev-add",
717#          "arguments" : { "id" : "foo",
718#                          "backend" : { "type" : "null", "data" : {} } } }
719#     <- { "return": {} }
720#
721# .. qmp-example::
722#
723#     -> { "execute" : "chardev-add",
724#          "arguments" : { "id" : "bar",
725#                          "backend" : { "type" : "file",
726#                                        "data" : { "out" : "/tmp/bar.log" } } } }
727#     <- { "return": {} }
728#
729# .. qmp-example::
730#
731#     -> { "execute" : "chardev-add",
732#          "arguments" : { "id" : "baz",
733#                          "backend" : { "type" : "pty", "data" : {} } } }
734#     <- { "return": { "pty" : "/dev/pty/42" } }
735##
736{ 'command': 'chardev-add',
737  'data': { 'id': 'str',
738            'backend': 'ChardevBackend' },
739  'returns': 'ChardevReturn' }
740
741##
742# @chardev-change:
743#
744# Change a character device backend
745#
746# @id: the chardev's ID, must exist
747#
748# @backend: new backend type and parameters
749#
750# Returns: ChardevReturn.
751#
752# Since: 2.10
753#
754# .. qmp-example::
755#
756#     -> { "execute" : "chardev-change",
757#          "arguments" : { "id" : "baz",
758#                          "backend" : { "type" : "pty", "data" : {} } } }
759#     <- { "return": { "pty" : "/dev/pty/42" } }
760#
761# .. qmp-example::
762#
763#     -> {"execute" : "chardev-change",
764#         "arguments" : {
765#             "id" : "charchannel2",
766#             "backend" : {
767#                 "type" : "socket",
768#                 "data" : {
769#                     "addr" : {
770#                         "type" : "unix" ,
771#                         "data" : {
772#                             "path" : "/tmp/charchannel2.socket"
773#                         }
774#                      },
775#                      "server" : true,
776#                      "wait" : false }}}}
777#     <- {"return": {}}
778##
779{ 'command': 'chardev-change',
780  'data': { 'id': 'str',
781            'backend': 'ChardevBackend' },
782  'returns': 'ChardevReturn' }
783
784##
785# @chardev-remove:
786#
787# Remove a character device backend
788#
789# @id: the chardev's ID, must exist and not be in use
790#
791# Since: 1.4
792#
793# .. qmp-example::
794#
795#     -> { "execute": "chardev-remove", "arguments": { "id" : "foo" } }
796#     <- { "return": {} }
797##
798{ 'command': 'chardev-remove',
799  'data': { 'id': 'str' } }
800
801##
802# @chardev-send-break:
803#
804# Send a break to a character device
805#
806# @id: the chardev's ID, must exist
807#
808# Since: 2.10
809#
810# .. qmp-example::
811#
812#     -> { "execute": "chardev-send-break", "arguments": { "id" : "foo" } }
813#     <- { "return": {} }
814##
815{ 'command': 'chardev-send-break',
816  'data': { 'id': 'str' } }
817
818##
819# @VSERPORT_CHANGE:
820#
821# Emitted when the guest opens or closes a virtio-serial port.
822#
823# @id: device identifier of the virtio-serial port
824#
825# @open: true if the guest has opened the virtio-serial port
826#
827# .. note:: This event is rate-limited.
828#
829# Since: 2.1
830#
831# .. qmp-example::
832#
833#     <- { "event": "VSERPORT_CHANGE",
834#          "data": { "id": "channel0", "open": true },
835#          "timestamp": { "seconds": 1401385907, "microseconds": 422329 } }
836##
837{ 'event': 'VSERPORT_CHANGE',
838  'data': { 'id': 'str',
839            'open': 'bool' } }
840