[libvirt] [PATCHv4 4/8] qemu: bulk stats: implement VCPU group

Peter Krempa pkrempa at redhat.com
Fri Sep 12 13:15:01 UTC 2014


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 <fromani at 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140912/b2656ea5/attachment-0001.sig>


More information about the libvir-list mailing list