xref: /openbmc/qemu/include/sysemu/stats.h (revision d27532e4)
1 /*
2  * Copyright (c) 2022 Oracle and/or its affiliates.
3  *
4  * This work is licensed under the terms of the GNU GPL, version 2.
5  * See the COPYING file in the top-level directory.
6  */
7 
8 #ifndef STATS_H
9 #define STATS_H
10 
11 #include "qapi/qapi-types-stats.h"
12 
13 typedef void StatRetrieveFunc(StatsResultList **result, StatsTarget target,
14                               strList *names, strList *targets, Error **errp);
15 typedef void SchemaRetrieveFunc(StatsSchemaList **result, Error **errp);
16 
17 /*
18  * Register callbacks for the QMP query-stats command.
19  *
20  * @provider: stats provider checked against QMP command arguments
21  * @stats_fn: routine to query stats:
22  * @schema_fn: routine to query stat schemas:
23  */
24 void add_stats_callbacks(StatsProvider provider,
25                          StatRetrieveFunc *stats_fn,
26                          SchemaRetrieveFunc *schemas_fn);
27 
28 /*
29  * Helper routines for adding stats entries to the results lists.
30  */
31 void add_stats_entry(StatsResultList **, StatsProvider, const char *id,
32                      StatsList *stats_list);
33 void add_stats_schema(StatsSchemaList **, StatsProvider, StatsTarget,
34                       StatsSchemaValueList *);
35 
36 /*
37  * True if a string matches the filter passed to the stats_fn callabck,
38  * false otherwise.
39  *
40  * Note that an empty list means no filtering, i.e. all strings will
41  * return true.
42  */
43 bool apply_str_list_filter(const char *string, strList *list);
44 
45 #endif /* STATS_H */
46