hmp: add filtering of statistics by name

Allow the user to request only a specific subset of statistics.
This can be useful when working on a feature or optimization that is
known to affect that statistic.

Example:

   (qemu) info stats vcpu halt_poll_fail_ns
   provider: kvm
       halt_poll_fail_ns (cumulative, ns): 0

In case multiple providers have the same statistic, the provider can be
specified too:

   (qemu) info stats vcpu halt_poll_fail_ns kvm
   provider: kvm
       halt_poll_fail_ns (cumulative, ns): 0

Extracted from a patch by Mark Kanda.

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2022-04-26 14:09:31 +02:00
parent cf7405bc02
commit 39cd0c7f12
2 changed files with 30 additions and 13 deletions

View file

@ -897,10 +897,10 @@ ERST
{
.name = "stats",
.args_type = "target:s,provider:s?",
.params = "target [provider]",
.help = "show statistics for the given target (vm or vcpu); optionally filter by "
"provider",
.args_type = "target:s,names:s?,provider:s?",
.params = "target [names] [provider]",
.help = "show statistics for the given target (vm or vcpu); optionally filter by"
"name (comma-separated list, or * for all) and provider",
.cmd = hmp_info_stats,
},