From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, armbru@redhat.com
Subject: Re: [PATCH v5 10/10] hmp: add filtering of statistics by name
Date: Wed, 8 Jun 2022 14:40:54 +0100 [thread overview]
Message-ID: <YqCm5oEyCIrNxYal@work-vm> (raw)
In-Reply-To: <20220530150714.756954-11-pbonzini@redhat.com>
* Paolo Bonzini (pbonzini@redhat.com) wrote:
> 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.
>
> Extracted from a patch by Mark Kanda.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
I think that's OK, if you repost please fix up the commit message with
examples of the command with and without names.
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Dave
> ---
> hmp-commands-info.hx | 8 ++++----
> monitor/hmp-cmds.c | 35 ++++++++++++++++++++++++++---------
> 2 files changed, 30 insertions(+), 13 deletions(-)
>
> diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
> index a67040443b..3ffa24bd67 100644
> --- a/hmp-commands-info.hx
> +++ b/hmp-commands-info.hx
> @@ -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,
> },
>
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index a71887e54c..8775f69ff1 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -2359,10 +2359,12 @@ static void print_stats_results(Monitor *mon, StatsTarget target,
> }
>
> /* Create the StatsFilter that is needed for an "info stats" invocation. */
> -static StatsFilter *stats_filter(StatsTarget target, int cpu_index,
> - StatsProvider provider)
> +static StatsFilter *stats_filter(StatsTarget target, const char *names,
> + int cpu_index, StatsProvider provider)
> {
> StatsFilter *filter = g_malloc0(sizeof(*filter));
> + StatsProvider provider_idx;
> + StatsRequestList *request_list = NULL;
>
> filter->target = target;
> switch (target) {
> @@ -2383,15 +2385,29 @@ static StatsFilter *stats_filter(StatsTarget target, int cpu_index,
> break;
> }
>
> - if (provider == STATS_PROVIDER__MAX) {
> + if (!names && provider == STATS_PROVIDER__MAX) {
> return filter;
> }
>
> - /* "info stats" can only query either one or all the providers. */
> + /*
> + * "info stats" can only query either one or all the providers. Querying
> + * by name, but not by provider, requires the creation of one filter per
> + * provider.
> + */
> + for (provider_idx = 0; provider_idx < STATS_PROVIDER__MAX; provider_idx++) {
> + if (provider == STATS_PROVIDER__MAX || provider == provider_idx) {
> + StatsRequest *request = g_new0(StatsRequest, 1);
> + request->provider = provider_idx;
> + if (names && !g_str_equal(names, "*")) {
> + request->has_names = true;
> + request->names = strList_from_comma_list(names);
> + }
> + QAPI_LIST_PREPEND(request_list, request);
> + }
> + }
> +
> filter->has_providers = true;
> - filter->providers = g_new0(StatsRequestList, 1);
> - filter->providers->value = g_new0(StatsRequest, 1);
> - filter->providers->value->provider = provider;
> + filter->providers = request_list;
> return filter;
> }
>
> @@ -2399,6 +2415,7 @@ void hmp_info_stats(Monitor *mon, const QDict *qdict)
> {
> const char *target_str = qdict_get_str(qdict, "target");
> const char *provider_str = qdict_get_try_str(qdict, "provider");
> + const char *names = qdict_get_try_str(qdict, "names");
>
> StatsProvider provider = STATS_PROVIDER__MAX;
> StatsTarget target;
> @@ -2429,11 +2446,11 @@ void hmp_info_stats(Monitor *mon, const QDict *qdict)
>
> switch (target) {
> case STATS_TARGET_VM:
> - filter = stats_filter(target, -1, provider);
> + filter = stats_filter(target, names, -1, provider);
> break;
> case STATS_TARGET_VCPU: {}
> int cpu_index = monitor_get_cpu_index(mon);
> - filter = stats_filter(target, cpu_index, provider);
> + filter = stats_filter(target, names, cpu_index, provider);
> break;
> default:
> abort();
> --
> 2.36.1
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
prev parent reply other threads:[~2022-06-08 13:41 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-30 15:07 [PATCH v5 00/10] qmp, hmp: statistics subsystem and KVM suport Paolo Bonzini
2022-05-30 15:07 ` [PATCH v5 01/10] qmp: Support for querying stats Paolo Bonzini
2022-05-30 15:07 ` [PATCH v5 02/10] kvm: Support for querying fd-based stats Paolo Bonzini
2022-06-07 17:44 ` Dr. David Alan Gilbert
2022-06-08 14:13 ` Paolo Bonzini
2022-06-08 14:52 ` Dr. David Alan Gilbert
2022-06-08 15:58 ` Paolo Bonzini
2022-06-08 16:01 ` Dr. David Alan Gilbert
2022-06-08 16:10 ` Paolo Bonzini
2022-06-08 16:17 ` Dr. David Alan Gilbert
2022-05-30 15:07 ` [PATCH v5 03/10] qmp: add filtering of statistics by target vCPU Paolo Bonzini
2022-05-30 15:07 ` [PATCH v5 04/10] cutils: fix case for "kilo" and "kibi" Paolo Bonzini
2022-05-30 21:56 ` Philippe Mathieu-Daudé via
2022-05-30 15:07 ` [PATCH v5 05/10] cutils: add functions for IEC and SI prefixes Paolo Bonzini
2022-05-30 21:59 ` Philippe Mathieu-Daudé via
2022-05-31 10:28 ` Paolo Bonzini
2022-05-30 15:07 ` [PATCH v5 06/10] hmp: add basic "info stats" implementation Paolo Bonzini
2022-06-07 18:35 ` Dr. David Alan Gilbert
2022-06-08 14:27 ` Paolo Bonzini
2022-06-08 15:23 ` Dr. David Alan Gilbert
2022-05-30 15:07 ` [PATCH v5 07/10] qmp: add filtering of statistics by provider Paolo Bonzini
2022-06-08 11:52 ` Dr. David Alan Gilbert
2022-05-30 15:07 ` [PATCH v5 08/10] hmp: " Paolo Bonzini
2022-06-08 12:06 ` Dr. David Alan Gilbert
2022-05-30 15:07 ` [PATCH v5 09/10] qmp: add filtering of statistics by name Paolo Bonzini
2022-06-08 13:36 ` Dr. David Alan Gilbert
2022-05-30 15:07 ` [PATCH v5 10/10] hmp: " Paolo Bonzini
2022-06-08 13:40 ` Dr. David Alan Gilbert [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YqCm5oEyCIrNxYal@work-vm \
--to=dgilbert@redhat.com \
--cc=armbru@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).