On Tue, Mar 04, 2025 at 14:04:12 +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@xxxxxxxxxx> > --- > include/libvirt/libvirt-domain.h | 70 ++++++++++++++++++++++++++++++++ > src/libvirt-domain.c | 5 ++- > src/qemu/qemu_driver.c | 22 ++++++---- > 3 files changed, 87 insertions(+), 10 deletions(-) [...] > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > index d48e79d5c6..4747308d01 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c > @@ -17743,21 +17743,27 @@ qemuDomainGetStatsDirtyRate(virQEMUDriver *driver G_GNUC_UNUSED, [...] > if (info.mode == QEMU_MONITOR_DIRTYRATE_CALC_MODE_DIRTY_RING) { > size_t i; > for (i = 0; i < info.nvcpus; i++) { > - virTypedParamListAddULLong(params, info.rates[i].value, > - "dirtyrate.vcpu.%d.megabytes_per_second", > - info.rates[i].idx); > + virTypedParamListAddULLong( > + params, info.rates[i].value, > + VIR_DOMAIN_STATS_DIRTYRATE_VCPU_PREFIX "%d" > + VIR_DOMAIN_STATS_DIRTYRATE_VCPU_SUFFIX_MEGABYTES_PER_SECOND, > + info.rates[i].idx); formatting > } > } Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>