mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 19:49:43 +00:00
cf7405bc02
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 <dgilbert@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
46 lines
1.4 KiB
C
46 lines
1.4 KiB
C
/*
|
|
* Copyright (c) 2022 Oracle and/or its affiliates.
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2.
|
|
* See the COPYING file in the top-level directory.
|
|
*/
|
|
|
|
#ifndef STATS_H
|
|
#define STATS_H
|
|
|
|
#include "qapi/qapi-types-stats.h"
|
|
|
|
typedef void StatRetrieveFunc(StatsResultList **result, StatsTarget target,
|
|
strList *names, strList *targets, Error **errp);
|
|
typedef void SchemaRetrieveFunc(StatsSchemaList **result, Error **errp);
|
|
|
|
/*
|
|
* Register callbacks for the QMP query-stats command.
|
|
*
|
|
* @provider: stats provider checked against QMP command arguments
|
|
* @stats_fn: routine to query stats:
|
|
* @schema_fn: routine to query stat schemas:
|
|
*/
|
|
void add_stats_callbacks(StatsProvider provider,
|
|
StatRetrieveFunc *stats_fn,
|
|
SchemaRetrieveFunc *schemas_fn);
|
|
|
|
/*
|
|
* Helper routines for adding stats entries to the results lists.
|
|
*/
|
|
void add_stats_entry(StatsResultList **, StatsProvider, const char *id,
|
|
StatsList *stats_list);
|
|
void add_stats_schema(StatsSchemaList **, StatsProvider, StatsTarget,
|
|
StatsSchemaValueList *);
|
|
|
|
/*
|
|
* True if a string matches the filter passed to the stats_fn callabck,
|
|
* false otherwise.
|
|
*
|
|
* Note that an empty list means no filtering, i.e. all strings will
|
|
* return true.
|
|
*/
|
|
bool apply_str_list_filter(const char *string, strList *list);
|
|
|
|
#endif /* STATS_H */
|