On 09/12/14 13:48, Francesco Romani wrote:
> This patch implements the VIR_DOMAIN_STATS_VCPU
> group of statistics.
> To do so, this patch also extracts a helper to gather the
> VCpu information.
> 
> Signed-off-by: Francesco Romani <from...@redhat.com>
> ---
>  include/libvirt/libvirt.h.in |   1 +
>  src/libvirt.c                |  12 +++
>  src/qemu/qemu_driver.c       | 200 
> +++++++++++++++++++++++++++++--------------
>  3 files changed, 149 insertions(+), 64 deletions(-)
> 

> @@ -17388,6 +17395,70 @@ qemuDomainGetStatsBalloon(virQEMUDriverPtr driver,
>      return 0;
>  }
>  
> +
> +static int
> +qemuDomainGetStatsVcpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
> +                       virDomainObjPtr dom,
> +                       virDomainStatsRecordPtr record,
> +                       int *maxparams,
> +                       unsigned int privflags ATTRIBUTE_UNUSED)
> +{
> +    size_t i;
> +    int ret = -1;
> +    char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
> +    virVcpuInfoPtr cpuinfo = NULL;
> +
> +    if (virTypedParamsAddUInt(&record->params,
> +                              &record->nparams,
> +                              maxparams,
> +                              "vcpu.current",
> +                              (unsigned) dom->def->vcpus) < 0)
> +        return -1;
> +
> +    if (virTypedParamsAddUInt(&record->params,
> +                              &record->nparams,
> +                              maxparams,
> +                              "vcpu.maximum",
> +                              (unsigned) dom->def->maxvcpus) < 0)
> +        return -1;
> +
> +    if (VIR_ALLOC_N(cpuinfo, dom->def->vcpus) < 0)
> +        return -1;
> +
> +    if (qemuDomainHelperGetVcpus(dom, cpuinfo, dom->def->vcpus,
> +                                 NULL, 0) < 0) {
> +        ret = 0; /* it's ok to be silent and go ahead */

virResetLastError() as the function would report one.

> +        goto cleanup;
> +    }
> +
> +    for (i = 0; i < dom->def->vcpus; i++) {
> +        snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
> +                 "vcpu.%u.state", cpuinfo[i].number);
> +        if (virTypedParamsAddInt(&record->params,
> +                                 &record->nparams,
> +                                 maxparams,
> +                                 param_name,
> +                                 cpuinfo[i].state) < 0)
> +            goto cleanup;
> +

ACK otherwise.

Peter


Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to