xref: /openbmc/qemu/qapi/net.json (revision ab938ae4)
1# -*- Mode: Python -*-
2#
3
4##
5# = Net devices
6##
7
8{ 'include': 'common.json' }
9
10##
11# @set_link:
12#
13# Sets the link status of a virtual network adapter.
14#
15# @name: the device name of the virtual network adapter
16#
17# @up: true to set the link status to be up
18#
19# Returns: Nothing on success
20#          If @name is not a valid network device, DeviceNotFound
21#
22# Since: 0.14.0
23#
24# Notes: Not all network adapters support setting link status.  This command
25#        will succeed even if the network adapter does not support link status
26#        notification.
27#
28# Example:
29#
30# -> { "execute": "set_link",
31#      "arguments": { "name": "e1000.0", "up": false } }
32# <- { "return": {} }
33#
34##
35{ 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
36
37##
38# @netdev_add:
39#
40# Add a network backend.
41#
42# @type: the type of network backend.  Current valid values are 'user', 'tap',
43#        'vde', 'socket', 'dump' and 'bridge'
44#
45# @id: the name of the new network backend
46#
47# Additional arguments depend on the type.
48#
49# TODO: This command effectively bypasses QAPI completely due to its
50# "additional arguments" business.  It shouldn't have been added to
51# the schema in this form.  It should be qapified properly, or
52# replaced by a properly qapified command.
53#
54# Since: 0.14.0
55#
56# Returns: Nothing on success
57#          If @type is not a valid network backend, DeviceNotFound
58#
59# Example:
60#
61# -> { "execute": "netdev_add",
62#      "arguments": { "type": "user", "id": "netdev1",
63#                     "dnssearch": "example.org" } }
64# <- { "return": {} }
65#
66##
67{ 'command': 'netdev_add',
68  'data': {'type': 'str', 'id': 'str'},
69  'gen': false }                # so we can get the additional arguments
70
71##
72# @netdev_del:
73#
74# Remove a network backend.
75#
76# @id: the name of the network backend to remove
77#
78# Returns: Nothing on success
79#          If @id is not a valid network backend, DeviceNotFound
80#
81# Since: 0.14.0
82#
83# Example:
84#
85# -> { "execute": "netdev_del", "arguments": { "id": "netdev1" } }
86# <- { "return": {} }
87#
88##
89{ 'command': 'netdev_del', 'data': {'id': 'str'} }
90
91##
92# @NetdevNoneOptions:
93#
94# Use it alone to have zero network devices.
95#
96# Since: 1.2
97##
98{ 'struct': 'NetdevNoneOptions',
99  'data': { } }
100
101##
102# @NetLegacyNicOptions:
103#
104# Create a new Network Interface Card.
105#
106# @netdev: id of -netdev to connect to
107#
108# @macaddr: MAC address
109#
110# @model: device model (e1000, rtl8139, virtio etc.)
111#
112# @addr: PCI device address
113#
114# @vectors: number of MSI-x vectors, 0 to disable MSI-X
115#
116# Since: 1.2
117##
118{ 'struct': 'NetLegacyNicOptions',
119  'data': {
120    '*netdev':  'str',
121    '*macaddr': 'str',
122    '*model':   'str',
123    '*addr':    'str',
124    '*vectors': 'uint32' } }
125
126##
127# @NetdevUserOptions:
128#
129# Use the user mode network stack which requires no administrator privilege to
130# run.
131#
132# @hostname: client hostname reported by the builtin DHCP server
133#
134# @restrict: isolate the guest from the host
135#
136# @ipv4: whether to support IPv4, default true for enabled
137#        (since 2.6)
138#
139# @ipv6: whether to support IPv6, default true for enabled
140#        (since 2.6)
141#
142# @ip: legacy parameter, use net= instead
143#
144# @net: IP network address that the guest will see, in the
145#       form addr[/netmask] The netmask is optional, and can be
146#       either in the form a.b.c.d or as a number of valid top-most
147#       bits. Default is 10.0.2.0/24.
148#
149# @host: guest-visible address of the host
150#
151# @tftp: root directory of the built-in TFTP server
152#
153# @bootfile: BOOTP filename, for use with tftp=
154#
155# @dhcpstart: the first of the 16 IPs the built-in DHCP server can
156#             assign
157#
158# @dns: guest-visible address of the virtual nameserver
159#
160# @dnssearch: list of DNS suffixes to search, passed as DHCP option
161#             to the guest
162#
163# @ipv6-prefix: IPv6 network prefix (default is fec0::) (since
164#               2.6). The network prefix is given in the usual
165#               hexadecimal IPv6 address notation.
166#
167# @ipv6-prefixlen: IPv6 network prefix length (default is 64)
168#                  (since 2.6)
169#
170# @ipv6-host: guest-visible IPv6 address of the host (since 2.6)
171#
172# @ipv6-dns: guest-visible IPv6 address of the virtual
173#            nameserver (since 2.6)
174#
175# @smb: root directory of the built-in SMB server
176#
177# @smbserver: IP address of the built-in SMB server
178#
179# @hostfwd: redirect incoming TCP or UDP host connections to guest
180#           endpoints
181#
182# @guestfwd: forward guest TCP connections
183#
184# Since: 1.2
185##
186{ 'struct': 'NetdevUserOptions',
187  'data': {
188    '*hostname':  'str',
189    '*restrict':  'bool',
190    '*ipv4':      'bool',
191    '*ipv6':      'bool',
192    '*ip':        'str',
193    '*net':       'str',
194    '*host':      'str',
195    '*tftp':      'str',
196    '*bootfile':  'str',
197    '*dhcpstart': 'str',
198    '*dns':       'str',
199    '*dnssearch': ['String'],
200    '*ipv6-prefix':      'str',
201    '*ipv6-prefixlen':   'int',
202    '*ipv6-host':        'str',
203    '*ipv6-dns':         'str',
204    '*smb':       'str',
205    '*smbserver': 'str',
206    '*hostfwd':   ['String'],
207    '*guestfwd':  ['String'] } }
208
209##
210# @NetdevTapOptions:
211#
212# Connect the host TAP network interface name to the VLAN.
213#
214# @ifname: interface name
215#
216# @fd: file descriptor of an already opened tap
217#
218# @fds: multiple file descriptors of already opened multiqueue capable
219# tap
220#
221# @script: script to initialize the interface
222#
223# @downscript: script to shut down the interface
224#
225# @br: bridge name (since 2.8)
226#
227# @helper: command to execute to configure bridge
228#
229# @sndbuf: send buffer limit. Understands [TGMKkb] suffixes.
230#
231# @vnet_hdr: enable the IFF_VNET_HDR flag on the tap interface
232#
233# @vhost: enable vhost-net network accelerator
234#
235# @vhostfd: file descriptor of an already opened vhost net device
236#
237# @vhostfds: file descriptors of multiple already opened vhost net
238# devices
239#
240# @vhostforce: vhost on for non-MSIX virtio guests
241#
242# @queues: number of queues to be created for multiqueue capable tap
243#
244# @poll-us: maximum number of microseconds that could
245# be spent on busy polling for tap (since 2.7)
246#
247# Since: 1.2
248##
249{ 'struct': 'NetdevTapOptions',
250  'data': {
251    '*ifname':     'str',
252    '*fd':         'str',
253    '*fds':        'str',
254    '*script':     'str',
255    '*downscript': 'str',
256    '*br':         'str',
257    '*helper':     'str',
258    '*sndbuf':     'size',
259    '*vnet_hdr':   'bool',
260    '*vhost':      'bool',
261    '*vhostfd':    'str',
262    '*vhostfds':   'str',
263    '*vhostforce': 'bool',
264    '*queues':     'uint32',
265    '*poll-us':    'uint32'} }
266
267##
268# @NetdevSocketOptions:
269#
270# Connect the VLAN to a remote VLAN in another QEMU virtual machine using a TCP
271# socket connection.
272#
273# @fd: file descriptor of an already opened socket
274#
275# @listen: port number, and optional hostname, to listen on
276#
277# @connect: port number, and optional hostname, to connect to
278#
279# @mcast: UDP multicast address and port number
280#
281# @localaddr: source address and port for multicast and udp packets
282#
283# @udp: UDP unicast address and port number
284#
285# Since: 1.2
286##
287{ 'struct': 'NetdevSocketOptions',
288  'data': {
289    '*fd':        'str',
290    '*listen':    'str',
291    '*connect':   'str',
292    '*mcast':     'str',
293    '*localaddr': 'str',
294    '*udp':       'str' } }
295
296##
297# @NetdevL2TPv3Options:
298#
299# Connect the VLAN to Ethernet over L2TPv3 Static tunnel
300#
301# @src: source address
302#
303# @dst: destination address
304#
305# @srcport: source port - mandatory for udp, optional for ip
306#
307# @dstport: destination port - mandatory for udp, optional for ip
308#
309# @ipv6: force the use of ipv6
310#
311# @udp: use the udp version of l2tpv3 encapsulation
312#
313# @cookie64: use 64 bit coookies
314#
315# @counter: have sequence counter
316#
317# @pincounter: pin sequence counter to zero -
318#              workaround for buggy implementations or
319#              networks with packet reorder
320#
321# @txcookie: 32 or 64 bit transmit cookie
322#
323# @rxcookie: 32 or 64 bit receive cookie
324#
325# @txsession: 32 bit transmit session
326#
327# @rxsession: 32 bit receive session - if not specified
328#             set to the same value as transmit
329#
330# @offset: additional offset - allows the insertion of
331#          additional application-specific data before the packet payload
332#
333# Since: 2.1
334##
335{ 'struct': 'NetdevL2TPv3Options',
336  'data': {
337    'src':          'str',
338    'dst':          'str',
339    '*srcport':     'str',
340    '*dstport':     'str',
341    '*ipv6':        'bool',
342    '*udp':         'bool',
343    '*cookie64':    'bool',
344    '*counter':     'bool',
345    '*pincounter':  'bool',
346    '*txcookie':    'uint64',
347    '*rxcookie':    'uint64',
348    'txsession':    'uint32',
349    '*rxsession':   'uint32',
350    '*offset':      'uint32' } }
351
352##
353# @NetdevVdeOptions:
354#
355# Connect the VLAN to a vde switch running on the host.
356#
357# @sock: socket path
358#
359# @port: port number
360#
361# @group: group owner of socket
362#
363# @mode: permissions for socket
364#
365# Since: 1.2
366##
367{ 'struct': 'NetdevVdeOptions',
368  'data': {
369    '*sock':  'str',
370    '*port':  'uint16',
371    '*group': 'str',
372    '*mode':  'uint16' } }
373
374##
375# @NetdevDumpOptions:
376#
377# Dump VLAN network traffic to a file.
378#
379# @len: per-packet size limit (64k default). Understands [TGMKkb]
380# suffixes.
381#
382# @file: dump file path (default is qemu-vlan0.pcap)
383#
384# Since: 1.2
385##
386{ 'struct': 'NetdevDumpOptions',
387  'data': {
388    '*len':  'size',
389    '*file': 'str' } }
390
391##
392# @NetdevBridgeOptions:
393#
394# Connect a host TAP network interface to a host bridge device.
395#
396# @br: bridge name
397#
398# @helper: command to execute to configure bridge
399#
400# Since: 1.2
401##
402{ 'struct': 'NetdevBridgeOptions',
403  'data': {
404    '*br':     'str',
405    '*helper': 'str' } }
406
407##
408# @NetdevHubPortOptions:
409#
410# Connect two or more net clients through a software hub.
411#
412# @hubid: hub identifier number
413#
414# Since: 1.2
415##
416{ 'struct': 'NetdevHubPortOptions',
417  'data': {
418    'hubid':     'int32' } }
419
420##
421# @NetdevNetmapOptions:
422#
423# Connect a client to a netmap-enabled NIC or to a VALE switch port
424#
425# @ifname: Either the name of an existing network interface supported by
426#          netmap, or the name of a VALE port (created on the fly).
427#          A VALE port name is in the form 'valeXXX:YYY', where XXX and
428#          YYY are non-negative integers. XXX identifies a switch and
429#          YYY identifies a port of the switch. VALE ports having the
430#          same XXX are therefore connected to the same switch.
431#
432# @devname: path of the netmap device (default: '/dev/netmap').
433#
434# Since: 2.0
435##
436{ 'struct': 'NetdevNetmapOptions',
437  'data': {
438    'ifname':     'str',
439    '*devname':    'str' } }
440
441##
442# @NetdevVhostUserOptions:
443#
444# Vhost-user network backend
445#
446# @chardev: name of a unix socket chardev
447#
448# @vhostforce: vhost on for non-MSIX virtio guests (default: false).
449#
450# @queues: number of queues to be created for multiqueue vhost-user
451#          (default: 1) (Since 2.5)
452#
453# Since: 2.1
454##
455{ 'struct': 'NetdevVhostUserOptions',
456  'data': {
457    'chardev':        'str',
458    '*vhostforce':    'bool',
459    '*queues':        'int' } }
460
461##
462# @NetClientDriver:
463#
464# Available netdev drivers.
465#
466# Since: 2.7
467##
468{ 'enum': 'NetClientDriver',
469  'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde', 'dump',
470            'bridge', 'hubport', 'netmap', 'vhost-user' ] }
471
472##
473# @Netdev:
474#
475# Captures the configuration of a network device.
476#
477# @id: identifier for monitor commands.
478#
479# @type: Specify the driver used for interpreting remaining arguments.
480#
481# Since: 1.2
482#
483# 'l2tpv3' - since 2.1
484##
485{ 'union': 'Netdev',
486  'base': { 'id': 'str', 'type': 'NetClientDriver' },
487  'discriminator': 'type',
488  'data': {
489    'none':     'NetdevNoneOptions',
490    'nic':      'NetLegacyNicOptions',
491    'user':     'NetdevUserOptions',
492    'tap':      'NetdevTapOptions',
493    'l2tpv3':   'NetdevL2TPv3Options',
494    'socket':   'NetdevSocketOptions',
495    'vde':      'NetdevVdeOptions',
496    'dump':     'NetdevDumpOptions',
497    'bridge':   'NetdevBridgeOptions',
498    'hubport':  'NetdevHubPortOptions',
499    'netmap':   'NetdevNetmapOptions',
500    'vhost-user': 'NetdevVhostUserOptions' } }
501
502##
503# @NetLegacy:
504#
505# Captures the configuration of a network device; legacy.
506#
507# @vlan: vlan number
508#
509# @id: identifier for monitor commands
510#
511# @name: identifier for monitor commands, ignored if @id is present
512#
513# @opts: device type specific properties (legacy)
514#
515# Since: 1.2
516##
517{ 'struct': 'NetLegacy',
518  'data': {
519    '*vlan': 'int32',
520    '*id':   'str',
521    '*name': 'str',
522    'opts':  'NetLegacyOptions' } }
523
524##
525# @NetLegacyOptionsType:
526#
527# Since: 1.2
528##
529{ 'enum': 'NetLegacyOptionsType',
530  'data': ['none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
531           'dump', 'bridge', 'netmap', 'vhost-user'] }
532
533##
534# @NetLegacyOptions:
535#
536# Like Netdev, but for use only by the legacy command line options
537#
538# Since: 1.2
539##
540{ 'union': 'NetLegacyOptions',
541  'base': { 'type': 'NetLegacyOptionsType' },
542  'discriminator': 'type',
543  'data': {
544    'none':     'NetdevNoneOptions',
545    'nic':      'NetLegacyNicOptions',
546    'user':     'NetdevUserOptions',
547    'tap':      'NetdevTapOptions',
548    'l2tpv3':   'NetdevL2TPv3Options',
549    'socket':   'NetdevSocketOptions',
550    'vde':      'NetdevVdeOptions',
551    'dump':     'NetdevDumpOptions',
552    'bridge':   'NetdevBridgeOptions',
553    'netmap':   'NetdevNetmapOptions',
554    'vhost-user': 'NetdevVhostUserOptions' } }
555
556##
557# @NetFilterDirection:
558#
559# Indicates whether a netfilter is attached to a netdev's transmit queue or
560# receive queue or both.
561#
562# @all: the filter is attached both to the receive and the transmit
563#       queue of the netdev (default).
564#
565# @rx: the filter is attached to the receive queue of the netdev,
566#      where it will receive packets sent to the netdev.
567#
568# @tx: the filter is attached to the transmit queue of the netdev,
569#      where it will receive packets sent by the netdev.
570#
571# Since: 2.5
572##
573{ 'enum': 'NetFilterDirection',
574  'data': [ 'all', 'rx', 'tx' ] }
575
576##
577# @RxState:
578#
579# Packets receiving state
580#
581# @normal: filter assigned packets according to the mac-table
582#
583# @none: don't receive any assigned packet
584#
585# @all: receive all assigned packets
586#
587# Since: 1.6
588##
589{ 'enum': 'RxState', 'data': [ 'normal', 'none', 'all' ] }
590
591##
592# @RxFilterInfo:
593#
594# Rx-filter information for a NIC.
595#
596# @name: net client name
597#
598# @promiscuous: whether promiscuous mode is enabled
599#
600# @multicast: multicast receive state
601#
602# @unicast: unicast receive state
603#
604# @vlan: vlan receive state (Since 2.0)
605#
606# @broadcast-allowed: whether to receive broadcast
607#
608# @multicast-overflow: multicast table is overflowed or not
609#
610# @unicast-overflow: unicast table is overflowed or not
611#
612# @main-mac: the main macaddr string
613#
614# @vlan-table: a list of active vlan id
615#
616# @unicast-table: a list of unicast macaddr string
617#
618# @multicast-table: a list of multicast macaddr string
619#
620# Since: 1.6
621##
622{ 'struct': 'RxFilterInfo',
623  'data': {
624    'name':               'str',
625    'promiscuous':        'bool',
626    'multicast':          'RxState',
627    'unicast':            'RxState',
628    'vlan':               'RxState',
629    'broadcast-allowed':  'bool',
630    'multicast-overflow': 'bool',
631    'unicast-overflow':   'bool',
632    'main-mac':           'str',
633    'vlan-table':         ['int'],
634    'unicast-table':      ['str'],
635    'multicast-table':    ['str'] }}
636
637##
638# @query-rx-filter:
639#
640# Return rx-filter information for all NICs (or for the given NIC).
641#
642# @name: net client name
643#
644# Returns: list of @RxFilterInfo for all NICs (or for the given NIC).
645#          Returns an error if the given @name doesn't exist, or given
646#          NIC doesn't support rx-filter querying, or given net client
647#          isn't a NIC.
648#
649# Since: 1.6
650#
651# Example:
652#
653# -> { "execute": "query-rx-filter", "arguments": { "name": "vnet0" } }
654# <- { "return": [
655#         {
656#             "promiscuous": true,
657#             "name": "vnet0",
658#             "main-mac": "52:54:00:12:34:56",
659#             "unicast": "normal",
660#             "vlan": "normal",
661#             "vlan-table": [
662#                 4,
663#                 0
664#             ],
665#             "unicast-table": [
666#             ],
667#             "multicast": "normal",
668#             "multicast-overflow": false,
669#             "unicast-overflow": false,
670#             "multicast-table": [
671#                 "01:00:5e:00:00:01",
672#                 "33:33:00:00:00:01",
673#                 "33:33:ff:12:34:56"
674#             ],
675#             "broadcast-allowed": false
676#         }
677#       ]
678#    }
679#
680##
681{ 'command': 'query-rx-filter', 'data': { '*name': 'str' },
682  'returns': ['RxFilterInfo'] }
683
684##
685# @NIC_RX_FILTER_CHANGED:
686#
687# Emitted once until the 'query-rx-filter' command is executed, the first event
688# will always be emitted
689#
690# @name: net client name
691#
692# @path: device path
693#
694# Since: 1.6
695#
696# Example:
697#
698# <- { "event": "NIC_RX_FILTER_CHANGED",
699#      "data": { "name": "vnet0",
700#                "path": "/machine/peripheral/vnet0/virtio-backend" },
701#      "timestamp": { "seconds": 1368697518, "microseconds": 326866 } }
702#    }
703#
704##
705{ 'event': 'NIC_RX_FILTER_CHANGED',
706  'data': { '*name': 'str', 'path': 'str' } }
707