qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 0/8] qmp, hmp: statistics subsystem and KVM suport.


From: Paolo Bonzini
Subject: [PATCH v2 0/8] qmp, hmp: statistics subsystem and KVM suport.
Date: Wed, 11 May 2022 10:48:25 +0200

This patchset adds QEMU support for querying fd-based KVM statistics.
This allows the user to analyze the behavior of the VM without access
to debugfs.

However, instead of adding an ad hoc command, the new QMP entry point
can be extended in the future to more statistics provider than KVM
(for example TCG, tap, or the block layer) and to more objects than
the VM and vCPUS (for example network interfaces or block devices).

Because the statistics exposed by KVM are not known at compile time,
the kernel interface also comes with an introspectable schema.  This
schema is exposed by the query-stats-schemas QMP command.

Patches 1 and 2 add the basic support, respectively the QMP command
and the KVM producer.

Patches 3 and 4 add a basic HMP implementation.  The first of the two
adds a basic filtering mechanism to the QMP command, which is then used
by HMP (which only shows vCPU statistics for the currently selected
guest CPU; this is consistent with other HMP commands and does not
flood the user with an overwhelming amount of output).

The remaining patches add more filtering, respectively by provider
and by the name of a statistic.

v1->v2:

- changed linear-hist and log-hist to linear-histogram and log2-histogram

- improved documentation (see diff below in this cover letter)

- fixed bisectability of monitor/hmp-cmds.c changes

Mark Kanda (3):
  qmp: Support for querying stats
  kvm: Support for querying fd-based stats
  hmp: add basic "info stats" implementation

Paolo Bonzini (5):
  qmp: add filtering of statistics by target vCPU
  qmp: add filtering of statistics by provider
  hmp: add filtering of statistics by provider
  qmp: add filtering of statistics by name
  hmp: add filtering of statistics by name

 accel/kvm/kvm-all.c     | 414 ++++++++++++++++++++++++++++++++++++++++
 hmp-commands-info.hx    |  14 ++
 include/monitor/hmp.h   |   1 +
 include/monitor/stats.h |  42 ++++
 monitor/hmp-cmds.c      | 229 ++++++++++++++++++++++
 monitor/qmp-cmds.c      | 132 +++++++++++++
 qapi/meson.build        |   1 +
 qapi/qapi-schema.json   |   1 +
 qapi/stats.json         | 232 ++++++++++++++++++++++
 9 files changed, 1066 insertions(+)
 create mode 100644 include/monitor/stats.h
 create mode 100644 qapi/stats.json

-- 
2.36.0

diff --git a/qapi/stats.json b/qapi/stats.json
index 234fbcb7ca..fc763b4aea 100644
--- a/qapi/stats.json
+++ b/qapi/stats.json
@@ -20,13 +20,14 @@
 # @cumulative: stat is cumulative; value can only increase.
 # @instant: stat is instantaneous; value can increase or decrease.
 # @peak: stat is the peak value; value can only increase.
-# @linear-hist: stat is a linear histogram.
-# @log-hist: stat is a logarithmic histogram.
+# @linear-histogram: stat is a linear histogram.
+# @log2-histogram: stat is a logarithmic histogram, with one bucket
+#                  for each power of two.
 #
 # Since: 7.1
 ##
 { 'enum' : 'StatsType',
-  'data' : [ 'cumulative', 'instant', 'peak', 'linear-hist', 'log-hist' ] }
+  'data' : [ 'cumulative', 'instant', 'peak', 'linear-histogram', 
'log2-histogram' ] }
 
 ##
 # @StatsUnit:
@@ -57,8 +58,10 @@
 #
 # The kinds of objects on which one can request statistics.
 #
-# @vm: the entire virtual machine.
-# @vcpu: a virtual CPU.
+# @vm: statistics that apply to the entire virtual machine or
+#      the entire QEMU process.
+#
+# @vcpu: statistics that apply to a single virtual CPU.
 #
 # Since: 7.1
 ##
@@ -68,10 +71,11 @@
 ##
 # @StatsRequest:
 #
-# Indicates a set of statistics that are required from a statistics provider.
+# Indicates a set of statistics that should be returned by query-stats.
 #
-# @provider: stat provider for which to limit the returned stats.
-# @names: list of stat names.
+# @provider: provider for which to return statistics.
+
+# @names: statistics to be returned (all if omitted).
 #
 # Since: 7.1
 ##
@@ -93,7 +97,11 @@
 # @StatsFilter:
 #
 # The arguments to the query-stats command; specifies a target for which to
-# request statistics, and which statistics are requested from each provider.
+# request statistics and optionally the required subset of information for
+# that target:
+# - which vCPUs to request statistics for
+# - which provider to request statistics from
+# - which values to return within each provider
 #
 # Since: 7.1
 ##
@@ -105,8 +113,8 @@
 ##
 # @StatsValue:
 #
-# @scalar: single uint64.
-# @list: list of uint64.
+# @scalar: single unsigned 64-bit integers.
+# @list: list of unsigned 64-bit integers (used for histograms).
 #
 # Since: 7.1
 ##
@@ -164,19 +172,25 @@
 #
 # Schema for a single statistic.
 #
-# @name: stat name.
+# @name: name of the statistic; each element of the schema is uniquely
+#        identified by a target, a provider (both available in @StatsSchema)
+#        and the name.
 #
-# @type: kind of statistic, a @StatType.
+# @type: kind of statistic.
 #
-# @unit: base unit of measurement for the statistics @StatUnit.
+# @unit: basic unit of measure for the statistic; if missing, the statistic
+#        is a simple number or counter.
 #
-# @base: base for the multiple of @unit that the statistic uses, either 2 or 
10.
-#        Only present if @exponent is non-zero.
+# @base: base for the multiple of @unit in which the statistic is measured.
+#        Only present if @exponent is non-zero; @base and @exponent together
+#        form a SI prefix (e.g., _nano-_ for ``base=10`` and ``exponent=-9``)
+#        or IEC binary prefix (e.g. _kibi-_ for ``base=2`` and ``exponent=10``)
 #
-# @exponent: exponent for the multiple of @unit that the statistic uses
+# @exponent: exponent for the multiple of @unit in which the statistic is
+#            expressed, or 0 for the basic unit
 #
-# @bucket-size: Used with linear-hist to report the width of each bucket
-#               of the histogram.
+# @bucket-size: Used with the @linear-histogram @StatsType, contains the width
+#               of each bucket of the histogram.
 #
 # Since: 7.1
 ##
@@ -195,7 +209,7 @@
 #
 # @provider: provider for this set of statistics.
 #
-# @target: kind of object that can be queried through this provider.
+# @target: the kind of object that can be queried through the provider.
 #
 # @stats: list of statistics.
 #




reply via email to

[Prev in Thread] Current Thread [Next in Thread]