[PATCH 18/19] src: add constants for domain stats 'dirtyrate.' parameters

Daniel P. Berrangé posted 19 patches 1 week ago
There is a newer version of this series
[PATCH 18/19] src: add constants for domain stats 'dirtyrate.' parameters
Posted by Daniel P. Berrangé 1 week ago
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@redhat.com>
---
 src/libvirt-domain.c | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 02fee7b5b9..aaa44ed3ef 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -12324,23 +12324,6 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
  *     The VIR_DOMAIN_STATS_DIRTYRATE_* constants define the known typed
  *     parameter keys.
  *
- *     "dirtyrate.calc_status" - the status of last memory dirty rate calculation,
- *                               returned as int from virDomainDirtyRateStatus
- *                               enum.
- *     "dirtyrate.calc_start_time" - the start time of last memory dirty rate
- *                                   calculation as long long.
- *     "dirtyrate.calc_period" - the period of last memory dirty rate calculation
- *                               as int.
- *     "dirtyrate.megabytes_per_second" - the calculated memory dirty rate in
- *                                        MiB/s as long long. It is produced
- *                                        only if the calc_status is measured.
- *     "dirtyrate.calc_mode" - the calculation mode used last measurement, either
- *                             of these 3 'page-sampling,dirty-bitmap,dirty-ring'
- *                             values returned.
- *     "dirtyrate.vcpu.<num>.megabytes_per_second" - the calculated memory dirty
- *                                                   rate for a virtual cpu as
- *                                                   unsigned long long.
- *
  * VIR_DOMAIN_STATS_VM:
  *     Return hypervisor-specific statistics. Note that the naming and meaning
  *     of the fields is entirely hypervisor dependent.
-- 
2.48.1
Re: [PATCH 18/19] src: add constants for domain stats 'dirtyrate.' parameters
Posted by Peter Krempa 5 days, 21 hours ago
On Tue, Mar 04, 2025 at 14:04:13 +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@redhat.com>
> ---
>  src/libvirt-domain.c | 17 -----------------
>  1 file changed, 17 deletions(-)
> 
> diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
> index 02fee7b5b9..aaa44ed3ef 100644
> --- a/src/libvirt-domain.c
> +++ b/src/libvirt-domain.c
> @@ -12324,23 +12324,6 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
>   *     The VIR_DOMAIN_STATS_DIRTYRATE_* constants define the known typed
>   *     parameter keys.
>   *
> - *     "dirtyrate.calc_status" - the status of last memory dirty rate calculation,
> - *                               returned as int from virDomainDirtyRateStatus
> - *                               enum.
> - *     "dirtyrate.calc_start_time" - the start time of last memory dirty rate
> - *                                   calculation as long long.
> - *     "dirtyrate.calc_period" - the period of last memory dirty rate calculation
> - *                               as int.
> - *     "dirtyrate.megabytes_per_second" - the calculated memory dirty rate in
> - *                                        MiB/s as long long. It is produced
> - *                                        only if the calc_status is measured.
> - *     "dirtyrate.calc_mode" - the calculation mode used last measurement, either
> - *                             of these 3 'page-sampling,dirty-bitmap,dirty-ring'
> - *                             values returned.
> - *     "dirtyrate.vcpu.<num>.megabytes_per_second" - the calculated memory dirty
> - *                                                   rate for a virtual cpu as
> - *                                                   unsigned long long.
> - *

This ought to be squashed into 17/19.