From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, dgilbert@redhat.com, berrange@redhat.com
Subject: [PATCH v2 6/8] hmp: add filtering of statistics by provider
Date: Wed, 11 May 2022 10:48:31 +0200 [thread overview]
Message-ID: <20220511084833.195963-7-pbonzini@redhat.com> (raw)
In-Reply-To: <20220511084833.195963-1-pbonzini@redhat.com>
Allow the user to request statistics for a single provider of interest.
Extracted from a patch by Mark Kanda.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
monitor/hmp-cmds.c | 39 +++++++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 26c5d2498b..4f4ecbfbfb 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -2291,6 +2291,7 @@ static StatsSchemaValueList *find_schema_value_list(
}
static void print_stats_results(Monitor *mon, StatsTarget target,
+ bool show_provider,
StatsResult *result,
StatsSchemaList *schema)
{
@@ -2305,8 +2306,10 @@ static void print_stats_results(Monitor *mon, StatsTarget target,
return;
}
- monitor_printf(mon, "provider: %s\n",
- StatsProvider_str(result->provider));
+ if (show_provider) {
+ monitor_printf(mon, "provider: %s\n",
+ StatsProvider_str(result->provider));
+ }
for (stats_list = result->stats; stats_list;
stats_list = stats_list->next,
@@ -2347,7 +2350,8 @@ 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)
+static StatsFilter *stats_filter(StatsTarget target, int cpu_index,
+ StatsProvider provider)
{
StatsFilter *filter = g_malloc0(sizeof(*filter));
@@ -2369,12 +2373,27 @@ static StatsFilter *stats_filter(StatsTarget target, int cpu_index)
default:
break;
}
+
+ if (provider == STATS_PROVIDER__MAX) {
+ return filter;
+ }
+
+ /* "info stats" can only query either one or all the providers. */
+ StatsRequest *request = g_new0(StatsRequest, 1);
+ request->provider = provider;
+ StatsRequestList *request_list = g_new0(StatsRequestList, 1);
+ QAPI_LIST_PREPEND(request_list, request);
+ filter->has_providers = true;
+ filter->providers = request_list;
return filter;
}
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");
+
+ StatsProvider provider = STATS_PROVIDER__MAX;
StatsTarget target;
Error *err = NULL;
g_autoptr(StatsFilter) filter = NULL;
@@ -2387,19 +2406,27 @@ void hmp_info_stats(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "invalid stats target %s\n", target_str);
goto exit_no_print;
}
+ if (provider_str) {
+ provider = qapi_enum_parse(&StatsProvider_lookup, provider_str, -1, &err);
+ if (err) {
+ monitor_printf(mon, "invalid stats provider %s\n", provider_str);
+ goto exit_no_print;
+ }
+ }
- schema = qmp_query_stats_schemas(false, 0, &err);
+ schema = qmp_query_stats_schemas(provider_str ? true : false,
+ provider, &err);
if (err) {
goto exit;
}
switch (target) {
case STATS_TARGET_VM:
- filter = stats_filter(target, -1);
+ filter = stats_filter(target, -1, provider);
break;
case STATS_TARGET_VCPU: {}
int cpu_index = monitor_get_cpu_index(mon);
- filter = stats_filter(target, cpu_index);
+ filter = stats_filter(target, cpu_index, provider);
break;
default:
abort();
--
2.36.0
next prev parent reply other threads:[~2022-05-11 9:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-11 8:48 [PATCH v2 0/8] qmp, hmp: statistics subsystem and KVM suport Paolo Bonzini
2022-05-11 8:48 ` [PATCH v2 1/8] qmp: Support for querying stats Paolo Bonzini
2022-05-13 12:52 ` Markus Armbruster
2022-05-13 14:06 ` Paolo Bonzini
2022-05-13 14:39 ` Markus Armbruster
2022-05-11 8:48 ` [PATCH v2 2/8] kvm: Support for querying fd-based stats Paolo Bonzini
2022-05-11 8:48 ` [PATCH v2 3/8] qmp: add filtering of statistics by target vCPU Paolo Bonzini
2022-05-13 12:53 ` Markus Armbruster
2022-05-11 8:48 ` [PATCH v2 4/8] hmp: add basic "info stats" implementation Paolo Bonzini
2022-05-11 8:48 ` [PATCH v2 5/8] qmp: add filtering of statistics by provider Paolo Bonzini
2022-05-11 8:48 ` Paolo Bonzini [this message]
2022-05-11 8:48 ` [PATCH v2 7/8] qmp: add filtering of statistics by name Paolo Bonzini
2022-05-11 8:48 ` [PATCH v2 8/8] hmp: " Paolo Bonzini
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=20220511084833.195963-7-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@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).