From cf7405bc0228c795557e19bacbaa3b145bb17370 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 24 May 2022 19:13:16 +0200 Subject: qmp: add filtering of statistics by name Allow retrieving only a subset of statistics. This can be useful for example in order to plot a subset of the statistics many times a second: KVM publishes ~40 statistics for each vCPU on x86; retrieving and serializing all of them would be useless. Another use will be in HMP in the following patch; implementing the filter in the backend is easy enough that it was deemed okay to make this a public interface. Example: { "execute": "query-stats", "arguments": { "target": "vcpu", "vcpus": [ "/machine/unattached/device[2]", "/machine/unattached/device[4]" ], "providers": [ { "provider": "kvm", "names": [ "l1d_flush", "exits" ] } } } { "return": { "vcpus": [ { "path": "/machine/unattached/device[2]" "providers": [ { "provider": "kvm", "stats": [ { "name": "l1d_flush", "value": 41213 }, { "name": "exits", "value": 74291 } ] } ] }, { "path": "/machine/unattached/device[4]" "providers": [ { "provider": "kvm", "stats": [ { "name": "l1d_flush", "value": 16132 }, { "name": "exits", "value": 57922 } ] } ] } ] } } Extracted from a patch by Mark Kanda. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Paolo Bonzini --- qapi/stats.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'qapi/stats.json') diff --git a/qapi/stats.json b/qapi/stats.json index 503918e..2f8bfe8 100644 --- a/qapi/stats.json +++ b/qapi/stats.json @@ -75,11 +75,14 @@ # Indicates a set of statistics that should be returned by query-stats. # # @provider: provider for which to return statistics. + +# @names: statistics to be returned (all if omitted). # # Since: 7.1 ## { 'struct': 'StatsRequest', - 'data': { 'provider': 'StatsProvider' } } + 'data': { 'provider': 'StatsProvider', + '*names': [ 'str' ] } } ## # @StatsVCPUFilter: @@ -99,6 +102,7 @@ # that target: # - which vCPUs to request statistics for # - which providers to request statistics from +# - which named values to return within each provider # # Since: 7.1 ## -- cgit v1.1