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. Paolo v3->v4: - correctly handle errors from the callbacks (patch 1) - renamed str_in_list to apply_str_list_filter (patch 3) - handle empty filter early by avoiding the query altogether (patch 3, 7) (patches 2/4/6/8 are identical to v3; patch 5 only has context 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 | 45 +++++ monitor/hmp-cmds.c | 229 ++++++++++++++++++++++ monitor/qmp-cmds.c | 149 +++++++++++++++ qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + qapi/stats.json | 246 ++++++++++++++++++++++++ 9 files changed, 1100 insertions(+) create mode 100644 include/monitor/stats.h create mode 100644 qapi/stats.json -- 2.36.0