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
18 # Enumeration of statistics types
20 # @cumulative: stat is cumulative; value can only increase.
21 # @instant: stat is instantaneous; value can increase or decrease.
22 # @peak: stat is the peak value; value can only increase.
23 # @linear-histogram: stat is a linear histogram.
24 # @log2-histogram: stat is a logarithmic histogram, with one bucket
25 # for each power of two.
29 { 'enum' : 'StatsType',
30 'data' : [ 'cumulative', 'instant', 'peak', 'linear-histogram',
36 # Enumeration of unit of measurement for statistics
38 # @bytes: stat reported in bytes.
39 # @seconds: stat reported in seconds.
40 # @cycles: stat reported in clock cycles.
41 # @boolean: stat is a boolean value.
45 { 'enum' : 'StatsUnit',
46 'data' : [ 'bytes', 'seconds', 'cycles', 'boolean' ] }
51 # Enumeration of statistics providers.
55 { 'enum': 'StatsProvider',
61 # The kinds of objects on which one can request statistics.
63 # @vm: statistics that apply to the entire virtual machine or
64 # the entire QEMU process.
66 # @vcpu: statistics that apply to a single virtual CPU.
70 { 'enum': 'StatsTarget',
71 'data': [ 'vm', 'vcpu' ] }
76 # Indicates a set of statistics that should be returned by query-stats.
78 # @provider: provider for which to return statistics.
80 # @names: statistics to be returned (all if omitted).
84 { 'struct': 'StatsRequest',
85 'data': { 'provider': 'StatsProvider',
86 '*names': [ 'str' ] } }
91 # @vcpus: list of QOM paths for the desired vCPU objects.
95 { 'struct': 'StatsVCPUFilter',
96 'data': { '*vcpus': [ 'str' ] } }
101 # The arguments to the query-stats command; specifies a target for which to
102 # request statistics and optionally the required subset of information for
104 # - which vCPUs to request statistics for
105 # - which providers to request statistics from
106 # - which named values to return within each provider
110 { 'union': 'StatsFilter',
112 'target': 'StatsTarget',
113 '*providers': [ 'StatsRequest' ] },
114 'discriminator': 'target',
115 'data': { 'vcpu': 'StatsVCPUFilter' } }
120 # @scalar: single unsigned 64-bit integers.
121 # @list: list of unsigned 64-bit integers (used for histograms).
125 { 'alternate': 'StatsValue',
126 'data': { 'scalar': 'uint64',
128 'list': [ 'uint64' ] } }
133 # @name: name of stat.
134 # @value: stat value.
139 'data': { 'name': 'str',
140 'value' : 'StatsValue' } }
145 # @provider: provider for this set of statistics.
147 # @qom-path: Path to the object for which the statistics are returned,
148 # if the object is exposed in the QOM tree
150 # @stats: list of statistics.
154 { 'struct': 'StatsResult',
155 'data': { 'provider': 'StatsProvider',
157 'stats': [ 'Stats' ] } }
162 # Return runtime-collected statistics for objects such as the
165 # The arguments are a StatsFilter and specify the provider and objects
166 # to return statistics about.
168 # Returns: a list of StatsResult, one for each provider and object
169 # (e.g., for each vCPU).
173 { 'command': 'query-stats',
174 'data': 'StatsFilter',
176 'returns': [ 'StatsResult' ] }
181 # Schema for a single statistic.
183 # @name: name of the statistic; each element of the schema is uniquely
184 # identified by a target, a provider (both available in @StatsSchema)
187 # @type: kind of statistic.
189 # @unit: basic unit of measure for the statistic; if missing, the statistic
190 # is a simple number or counter.
192 # @base: base for the multiple of @unit in which the statistic is measured.
193 # Only present if @exponent is non-zero; @base and @exponent together
194 # form a SI prefix (e.g., _nano-_ for ``base=10`` and ``exponent=-9``)
195 # or IEC binary prefix (e.g. _kibi-_ for ``base=2`` and ``exponent=10``)
197 # @exponent: exponent for the multiple of @unit in which the statistic is
198 # expressed, or 0 for the basic unit
200 # @bucket-size: Present when @type is "linear-histogram", contains the width
201 # of each bucket of the histogram.
205 { 'struct': 'StatsSchemaValue',
206 'data': { 'name': 'str',
208 '*unit': 'StatsUnit',
211 '*bucket-size': 'uint32' } }
216 # Schema for all available statistics for a provider and target.
218 # @provider: provider for this set of statistics.
220 # @target: the kind of object that can be queried through the provider.
222 # @stats: list of statistics.
226 { 'struct': 'StatsSchema',
227 'data': { 'provider': 'StatsProvider',
228 'target': 'StatsTarget',
229 'stats': [ 'StatsSchemaValue' ] } }
232 # @query-stats-schemas:
234 # Return the schema for all available runtime-collected statistics.
236 # Note: runtime-collected statistics and their names fall outside QEMU's usual
237 # deprecation policies. QEMU will try to keep the set of available data
238 # stable, together with their names, but will not guarantee stability
239 # at all costs; the same is true of providers that source statistics
240 # externally, e.g. from Linux. For example, if the same value is being
241 # tracked with different names on different architectures or by different
242 # providers, one of them might be renamed. A statistic might go away if
243 # an algorithm is changed or some code is removed; changing a default
244 # might cause previously useful statistics to always report 0. Such
245 # changes, however, are expected to be rare.
249 { 'command': 'query-stats-schemas',
250 'data': { '*provider': 'StatsProvider' },
251 'returns': [ 'StatsSchema' ] }