xref: /openbmc/qemu/qapi/qdev.json (revision 764ecf77)
1# -*- Mode: Python -*-
2# vim: filetype=python
3#
4# This work is licensed under the terms of the GNU GPL, version 2 or later.
5# See the COPYING file in the top-level directory.
6
7##
8# = Device infrastructure (qdev)
9##
10
11{ 'include': 'qom.json' }
12
13##
14# @device-list-properties:
15#
16# List properties associated with a device.
17#
18# @typename: the type name of a device
19#
20# Returns: a list of ObjectPropertyInfo describing a devices properties
21#
22# Note: objects can create properties at runtime, for example to describe
23#       links between different devices and/or objects. These properties
24#       are not included in the output of this command.
25#
26# Since: 1.2
27##
28{ 'command': 'device-list-properties',
29  'data': { 'typename': 'str'},
30  'returns': [ 'ObjectPropertyInfo' ] }
31
32##
33# @device_add:
34#
35# Add a device.
36#
37# @driver: the name of the new device's driver
38#
39# @bus: the device's parent bus (device tree path)
40#
41# @id: the device's ID, must be unique
42#
43# Features:
44# @json-cli: If present, the "-device" command line option supports JSON
45#            syntax with a structure identical to the arguments of this
46#            command.
47#
48# Notes:
49#
50# Additional arguments depend on the type.
51#
52# 1. For detailed information about this command, please refer to the
53#    'docs/qdev-device-use.txt' file.
54#
55# 2. It's possible to list device properties by running QEMU with the
56#    "-device DEVICE,help" command-line argument, where DEVICE is the
57#    device's name
58#
59# Example:
60#
61# -> { "execute": "device_add",
62#      "arguments": { "driver": "e1000", "id": "net1",
63#                     "bus": "pci.0",
64#                     "mac": "52:54:00:12:34:56" } }
65# <- { "return": {} }
66#
67# TODO: This command effectively bypasses QAPI completely due to its
68#       "additional arguments" business.  It shouldn't have been added to
69#       the schema in this form.  It should be qapified properly, or
70#       replaced by a properly qapified command.
71#
72# Since: 0.13
73##
74{ 'command': 'device_add',
75  'data': {'driver': 'str', '*bus': 'str', '*id': 'str'},
76  'gen': false, # so we can get the additional arguments
77  'features': ['json-cli'] }
78
79##
80# @device_del:
81#
82# Remove a device from a guest
83#
84# @id: the device's ID or QOM path
85#
86# Returns: Nothing on success
87#          If @id is not a valid device, DeviceNotFound
88#
89# Notes: When this command completes, the device may not be removed from the
90#        guest.  Hot removal is an operation that requires guest cooperation.
91#        This command merely requests that the guest begin the hot removal
92#        process.  Completion of the device removal process is signaled with a
93#        DEVICE_DELETED event. Guest reset will automatically complete removal
94#        for all devices.  If a guest-side error in the hot removal process is
95#        detected, the device will not be removed and a DEVICE_UNPLUG_GUEST_ERROR
96#        event is sent.  Some errors cannot be detected.
97#
98# Since: 0.14
99#
100# Example:
101#
102# -> { "execute": "device_del",
103#      "arguments": { "id": "net1" } }
104# <- { "return": {} }
105#
106# -> { "execute": "device_del",
107#      "arguments": { "id": "/machine/peripheral-anon/device[0]" } }
108# <- { "return": {} }
109#
110##
111{ 'command': 'device_del', 'data': {'id': 'str'} }
112
113##
114# @DEVICE_DELETED:
115#
116# Emitted whenever the device removal completion is acknowledged by the guest.
117# At this point, it's safe to reuse the specified device ID. Device removal can
118# be initiated by the guest or by HMP/QMP commands.
119#
120# @device: the device's ID if it has one
121#
122# @path: the device's QOM path
123#
124# Since: 1.5
125#
126# Example:
127#
128# <- { "event": "DEVICE_DELETED",
129#      "data": { "device": "virtio-net-pci-0",
130#                "path": "/machine/peripheral/virtio-net-pci-0" },
131#      "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
132#
133##
134{ 'event': 'DEVICE_DELETED',
135  'data': { '*device': 'str', 'path': 'str' } }
136
137##
138# @DEVICE_UNPLUG_GUEST_ERROR:
139#
140# Emitted when a device hot unplug fails due to a guest reported error.
141#
142# @device: the device's ID if it has one
143#
144# @path: the device's QOM path
145#
146# Since: 6.2
147#
148# Example:
149#
150# <- { "event": "DEVICE_UNPLUG_GUEST_ERROR"
151#      "data": { "device": "core1",
152#                "path": "/machine/peripheral/core1" },
153#      },
154#      "timestamp": { "seconds": 1615570772, "microseconds": 202844 } }
155#
156##
157{ 'event': 'DEVICE_UNPLUG_GUEST_ERROR',
158  'data': { '*device': 'str', 'path': 'str' } }
159