On Tue, Mar 04, 2025 at 14:04:14 +0000, Daniel P. Berrangé wrote:
Contrary to most APIs returning typed parameters, there are no
constants
defined for the domain stats data keys. This is was because many of the
keys needs to be dynamically constructed using one or more array index
values.
It is possible to define constants while still supporting dynamic
array indexes by simply defining the prefixes and suffixes as constants.
The consuming code can then combine the constants with array index
value.
With this approach, it is practical to add constants for the domain stats
API keys.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
include/libvirt/libvirt-domain.h | 12 ++++++++++++
src/libvirt-domain.c | 12 +++++-------
2 files changed, 17 insertions(+), 7 deletions(-)
[...]
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index aaa44ed3ef..2015aedf34 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -12332,14 +12332,12 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
*
* "vm.$NAME.$TYPE"
*
- * $NAME - name of the statistics field provided by the hypervisor
- *
- * $TYPE - Type of the value. The following types are returned:
- * 'cur' - current instant value
- * 'sum' - aggregate value
- * 'max' - peak value
+ * Where $NAME is an arbitrary choice of the hypervisor driver, for
+ * which no API constants are defined.
+ * The $TYPE values are defined by VIR_DOMAIN_STATS_CUSTOM_TYPE_*
+ * constants.
*
- * The returned value may be either an unsigned long long or a boolean.
+* The returned value may be either an unsigned long long or a boolean.
*
Please don't disturb the star culmination ;)
* WARNING:
* The stats reported in this group are runtime-collected and
Reviewed-by: Peter Krempa <pkrempa(a)redhat.com>