[PATCH v2 6/6] qemu_driver: Add calc_mode for dirtyrate statistics

Peter Krempa pkrempa at redhat.com
Thu Jan 27 08:58:02 UTC 2022


On Thu, Jan 27, 2022 at 15:25:22 +0800, huangy81 at chinatelecom.cn wrote:
> From: Hyman Huang(黄勇) <huangy81 at chinatelecom.cn>
> 
> Add calc_mode for dirtyrate statistics retured by
> virsh domstats --dirtyrate api, also add vcpu dirtyrate
> if dirty-ring mode was used in last measurement.
> 
> Signed-off-by: Hyman Huang(黄勇) <huangy81 at chinatelecom.cn>
> ---
>  src/libvirt-domain.c         |  5 +++++
>  src/qemu/qemu_driver.c       | 14 ++++++++++++
>  src/qemu/qemu_monitor.h      | 10 +++++++++
>  src/qemu/qemu_monitor_json.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 81 insertions(+)
> 
> diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
> index 4caa740..b1b6707 100644
> --- a/src/libvirt-domain.c
> +++ b/src/libvirt-domain.c
> @@ -11941,6 +11941,11 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
>   *     "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 as int,
> + *                             which is one of qemuMonitorDirtyRateCalcMode enum.

'qemuMonitorDirtyRateCalcMode' is an internal qemu-private enum. You
can't use it in the public API as the appropriate constants are not
exported and also we are free to change meanings of internal constants.

> + *     "dirtyrate.vcpu.<num>.megabytes_per_second" - the calculated memory dirty
> + *                                                   rate for a virtual cpu as
> + *                                                   long long.

A signed value doesn't really seem make too much sense to a value which
can't be negative.

>   *
>   * Note that entire stats groups or individual stat fields may be missing from
>   * the output in case they are not supported by the given hypervisor, are not
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index feebfc4..09eda6b 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -18537,6 +18537,20 @@ qemuDomainGetStatsDirtyRate(virQEMUDriver *driver,
>                                    "dirtyrate.megabytes_per_second") < 0)
>          return -1;
>  
> +    if (virTypedParamListAddInt(params, info.mode,
> +                                "dirtyrate.calc_mode") < 0)
> +        return -1;
> +
> +    if (info.mode == VIR_DOMAIN_DIRTYRATE_CALC_MODE_DIRTY_RING) {
> +        int i;
> +        for (i = 0; i < info.nvcpus; i++) {
> +            if (virTypedParamListAddLLong(params, info.rates[i].value,
> +                                "dirtyrate.vcpu.%d.megabytes_per_second",
> +                                info.rates[i].index) < 0)

Please align it properly even if it exceeds 80 colums.

> +            return -1;
> +        }
> +    }
> +
>      return 0;
>  }

[...]




More information about the libvir-list mailing list