qga/qapi-schema: Move error documentation to new "Errors" sections
[qemu/kevin.git] / qapi / stats.json
blobce9d8161ecbd1d567f11901e3c78b8a77ba7ea52
1 # -*- Mode: Python -*-
2 # vim: filetype=python
4 # Copyright (c) 2022 Oracle and/or its affiliates.
6 # This work is licensed under the terms of the GNU GPL, version 2 or later.
7 # See the COPYING file in the top-level directory.
9 # SPDX-License-Identifier: GPL-2.0-or-later
12 # = Statistics
16 # @StatsType:
18 # Enumeration of statistics types
20 # @cumulative: stat is cumulative; value can only increase.
22 # @instant: stat is instantaneous; value can increase or decrease.
24 # @peak: stat is the peak value; value can only increase.
26 # @linear-histogram: stat is a linear histogram.
28 # @log2-histogram: stat is a logarithmic histogram, with one bucket
29 #     for each power of two.
31 # Since: 7.1
33 { 'enum' : 'StatsType',
34   'data' : [ 'cumulative', 'instant', 'peak', 'linear-histogram',
35              'log2-histogram' ] }
38 # @StatsUnit:
40 # Enumeration of unit of measurement for statistics
42 # @bytes: stat reported in bytes.
44 # @seconds: stat reported in seconds.
46 # @cycles: stat reported in clock cycles.
48 # @boolean: stat is a boolean value.
50 # Since: 7.1
52 { 'enum' : 'StatsUnit',
53   'data' : [ 'bytes', 'seconds', 'cycles', 'boolean' ] }
56 # @StatsProvider:
58 # Enumeration of statistics providers.
60 # @kvm: since 7.1
62 # @cryptodev: since 8.0
64 # Since: 7.1
66 { 'enum': 'StatsProvider',
67   'data': [ 'kvm', 'cryptodev' ] }
70 # @StatsTarget:
72 # The kinds of objects on which one can request statistics.
74 # @vm: statistics that apply to the entire virtual machine or the
75 #     entire QEMU process.
77 # @vcpu: statistics that apply to a single virtual CPU.
79 # @cryptodev: statistics that apply to a crypto device (since 8.0)
81 # Since: 7.1
83 { 'enum': 'StatsTarget',
84   'data': [ 'vm', 'vcpu', 'cryptodev' ] }
87 # @StatsRequest:
89 # Indicates a set of statistics that should be returned by
90 # query-stats.
92 # @provider: provider for which to return statistics.
94 # @names: statistics to be returned (all if omitted).
96 # Since: 7.1
98 { 'struct': 'StatsRequest',
99   'data': { 'provider': 'StatsProvider',
100             '*names': [ 'str' ] } }
103 # @StatsVCPUFilter:
105 # @vcpus: list of QOM paths for the desired vCPU objects.
107 # Since: 7.1
109 { 'struct': 'StatsVCPUFilter',
110   'data': { '*vcpus': [ 'str' ] } }
113 # @StatsFilter:
115 # The arguments to the query-stats command; specifies a target for
116 # which to request statistics and optionally the required subset of
117 # information for that target:
119 # - which vCPUs to request statistics for
120 # - which providers to request statistics from
121 # - which named values to return within each provider
123 # @target: the kind of objects to query
125 # Since: 7.1
127 { 'union': 'StatsFilter',
128   'base': {
129       'target': 'StatsTarget',
130       '*providers': [ 'StatsRequest' ] },
131   'discriminator': 'target',
132   'data': { 'vcpu': 'StatsVCPUFilter' } }
135 # @StatsValue:
137 # @scalar: single unsigned 64-bit integers.
139 # @list: list of unsigned 64-bit integers (used for histograms).
141 # Since: 7.1
143 { 'alternate': 'StatsValue',
144   'data': { 'scalar': 'uint64',
145             'boolean': 'bool',
146             'list': [ 'uint64' ] } }
149 # @Stats:
151 # @name: name of stat.
153 # @value: stat value.
155 # Since: 7.1
157 { 'struct': 'Stats',
158   'data': { 'name': 'str',
159             'value' : 'StatsValue' } }
162 # @StatsResult:
164 # @provider: provider for this set of statistics.
166 # @qom-path: Path to the object for which the statistics are returned,
167 #     if the object is exposed in the QOM tree
169 # @stats: list of statistics.
171 # Since: 7.1
173 { 'struct': 'StatsResult',
174   'data': { 'provider': 'StatsProvider',
175             '*qom-path': 'str',
176             'stats': [ 'Stats' ] } }
179 # @query-stats:
181 # Return runtime-collected statistics for objects such as the VM or
182 # its vCPUs.
184 # The arguments are a StatsFilter and specify the provider and objects
185 # to return statistics about.
187 # Returns: a list of StatsResult, one for each provider and object
188 #     (e.g., for each vCPU).
190 # Since: 7.1
192 { 'command': 'query-stats',
193   'data': 'StatsFilter',
194   'boxed': true,
195   'returns': [ 'StatsResult' ] }
198 # @StatsSchemaValue:
200 # Schema for a single statistic.
202 # @name: name of the statistic; each element of the schema is uniquely
203 #     identified by a target, a provider (both available in
204 #     @StatsSchema) and the name.
206 # @type: kind of statistic.
208 # @unit: basic unit of measure for the statistic; if missing, the
209 #     statistic is a simple number or counter.
211 # @base: base for the multiple of @unit in which the statistic is
212 #     measured.  Only present if @exponent is non-zero; @base and
213 #     @exponent together form a SI prefix (e.g., _nano-_ for
214 #     ``base=10`` and ``exponent=-9``) or IEC binary prefix (e.g.
215 #     _kibi-_ for ``base=2`` and ``exponent=10``)
217 # @exponent: exponent for the multiple of @unit in which the statistic
218 #     is expressed, or 0 for the basic unit
220 # @bucket-size: Present when @type is "linear-histogram", contains the
221 #     width of each bucket of the histogram.
223 # Since: 7.1
225 { 'struct': 'StatsSchemaValue',
226   'data': { 'name': 'str',
227             'type': 'StatsType',
228             '*unit': 'StatsUnit',
229             '*base': 'int8',
230             'exponent': 'int16',
231             '*bucket-size': 'uint32' } }
234 # @StatsSchema:
236 # Schema for all available statistics for a provider and target.
238 # @provider: provider for this set of statistics.
240 # @target: the kind of object that can be queried through the
241 #     provider.
243 # @stats: list of statistics.
245 # Since: 7.1
247 { 'struct': 'StatsSchema',
248   'data': { 'provider': 'StatsProvider',
249             'target': 'StatsTarget',
250             'stats': [ 'StatsSchemaValue' ] } }
253 # @query-stats-schemas:
255 # Return the schema for all available runtime-collected statistics.
257 # Note: runtime-collected statistics and their names fall outside
258 #     QEMU's usual deprecation policies.  QEMU will try to keep the
259 #     set of available data stable, together with their names, but
260 #     will not guarantee stability at all costs; the same is true of
261 #     providers that source statistics externally, e.g. from Linux.
262 #     For example, if the same value is being tracked with different
263 #     names on different architectures or by different providers, one
264 #     of them might be renamed.  A statistic might go away if an
265 #     algorithm is changed or some code is removed; changing a default
266 #     might cause previously useful statistics to always report 0.
267 #     Such changes, however, are expected to be rare.
269 # Since: 7.1
271 { 'command': 'query-stats-schemas',
272   'data': { '*provider': 'StatsProvider' },
273   'returns': [ 'StatsSchema' ] }