[libvirt] [PATCHv6 05/11] qemu: bulk stats: implement interface group
Eric Blake
eblake at redhat.com
Tue Sep 16 22:04:27 UTC 2014
On 09/15/2014 09:42 AM, Peter Krempa wrote:
> From: Francesco Romani <fromani at redhat.com>
>
> This patch implements the VIR_DOMAIN_STATS_INTERFACE group of
> statistics.
>
> Signed-off-by: Francesco Romani <fromani at redhat.com>
> Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> ---
>
> Notes:
> Version 6:
> - this stats group is now skipped if the guest is offline as the interface names are not available
> - also an additional check checks if the interface has a name to avoid crashing
>
> include/libvirt/libvirt.h.in | 1 +
> src/libvirt.c | 14 +++++++
> src/qemu/qemu_driver.c | 95 ++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 110 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;
Depending on whether this gets in first, or James' patches, the other
will want to rebase:
https://www.redhat.com/archives/libvir-list/2014-September/msg01025.html
> +
> + if (!virDomainObjIsActive(dom))
> + return 0;
> +
> + 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 (!dom->def->nets[i]->ifname)
> + continue;
Micro-optimization: swap these two statements to avoid the memset() if
you are going to skip the loop iteration.
> +
> + QEMU_ADD_NAME_PARAM(record, maxparams,
> + "net", i, dom->def->nets[i]->ifname);
> +
> + if (virNetInterfaceStats(dom->def->nets[i]->ifname, &tmp) < 0) {
> + virResetLastError();
> + continue;
Again, this will pollute the log, so we may need to make
virNetInterfaceStats gain a quiet mode.
ACK
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 539 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140916/22364434/attachment-0001.sig>
More information about the libvir-list
mailing list