[libvirt] [PATCHv5 5/8] qemu: bulk stats: implement interface group

Peter Krempa pkrempa at redhat.com
Mon Sep 15 13:13:37 UTC 2014


On 09/15/14 10:48, Francesco Romani wrote:
> This patch implements the VIR_DOMAIN_STATS_INTERFACE
> group of statistics.
> 
> Signed-off-by: Francesco Romani <fromani at redhat.com>
> ---
>  include/libvirt/libvirt.h.in |  1 +
>  src/libvirt.c                | 14 +++++++
>  src/qemu/qemu_driver.c       | 89 ++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 104 insertions(+)
> 

> +static int
> +qemuDomainGetStatsInterface(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
> +                            virDomainObjPtr dom,
> +                            virDomainStatsRecordPtr record,
> +                            int *maxparams,
> +                            unsigned int privflags ATTRIBUTE_UNUSED)
> +{
> +    size_t i;
> +    struct _virDomainInterfaceStats tmp;
> +
> +    QEMU_ADD_COUNT_PARAM(record, maxparams, "net", dom->def->nnets);
> +
> +    /* Check the path is one of the domain's network interfaces. */
> +    for (i = 0; i < dom->def->nnets; i++) {
> +        memset(&tmp, 0, sizeof(tmp));
> +
> +        if (virNetInterfaceStats(dom->def->nets[i]->ifname, &tmp) < 0) {

dom->def->nets[i]->ifname is NULL if the VM is inactive. I think we
should skip this complete group if the VM is offline.

I'll add a if (!virDomainObjIsActive(dom)) return 0; to the beginning of
this function. If the vm isn't active, there isn't much to report.


> +            virResetLastError();
> +            continue;
> +        }

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/20140915/01fe99f3/attachment-0001.sig>


More information about the libvir-list mailing list