On 09/15/2014 09:42 AM, Peter Krempa wrote: > From: Francesco Romani <fromani@xxxxxxxxxx> > > This patch implements the VIR_DOMAIN_STATS_INTERFACE group of > statistics. > > Signed-off-by: Francesco Romani <fromani@xxxxxxxxxx> > Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> > --- > > 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
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list