From: Mehdi Abaakouk <sileht@xxxxxxxxxx> In preparation to the code move to virnetdevtap.c, this change: * renames virNetInterfaceStats to virNetDevTapInterfaceStats * changes 'path' to 'ifname', to use the same vocable as other method in virnetdevtap.c. * Add the attributes checker --- src/libvirt_private.syms | 2 +- src/libxl/libxl_driver.c | 2 +- src/lxc/lxc_driver.c | 2 +- src/openvz/openvz_driver.c | 2 +- src/qemu/qemu_driver.c | 4 ++-- src/util/virstats.c | 22 +++++++++++----------- src/util/virstats.h | 5 +++-- src/xen/xen_hypervisor.c | 2 +- 8 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index aa27f78..0036cbd 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2367,7 +2367,7 @@ virSocketAddrSetIPv6AddrNetOrder; virSocketAddrSetPort; # util/virstats.h -virNetInterfaceStats; +virNetDevTapInterfaceStats; # util/virstorageencryption.h virStorageEncryptionFormat; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index b2f3b16..67f0e58 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -4982,7 +4982,7 @@ libxlDomainInterfaceStats(virDomainPtr dom, } if (ret == 0) - ret = virNetInterfaceStats(path, stats); + ret = virNetDevTapInterfaceStats(path, stats); else virReportError(VIR_ERR_INVALID_ARG, _("'%s' is not a known interface"), path); diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 4a0165a..526d40d 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2893,7 +2893,7 @@ lxcDomainInterfaceStats(virDomainPtr dom, } if (ret == 0) - ret = virNetInterfaceStats(path, stats); + ret = virNetDevTapInterfaceStats(path, stats); else virReportError(VIR_ERR_INVALID_ARG, _("Invalid path, '%s' is not a known interface"), path); diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 38a562e..7bd3acf 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -2024,7 +2024,7 @@ openvzDomainInterfaceStats(virDomainPtr dom, } if (ret == 0) - ret = virNetInterfaceStats(path, stats); + ret = virNetDevTapInterfaceStats(path, stats); else virReportError(VIR_ERR_INVALID_ARG, _("invalid path, '%s' is not a known interface"), path); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 87ca09d..38208b1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11005,7 +11005,7 @@ qemuDomainInterfaceStats(virDomainPtr dom, if (net->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER) { ret = virNetDevOpenvswitchInterfaceStats(path, stats); } else { - ret = virNetInterfaceStats(path, stats); + ret = virNetDevTapInterfaceStats(path, stats); } } else { virReportError(VIR_ERR_INVALID_ARG, @@ -19154,7 +19154,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, continue; } } else { - if (virNetInterfaceStats(dom->def->nets[i]->ifname, &tmp) < 0) { + if (virNetDevTapInterfaceStats(dom->def->nets[i]->ifname, &tmp) < 0) { virResetLastError(); continue; } diff --git a/src/util/virstats.c b/src/util/virstats.c index c4725ed..95b4c38 100644 --- a/src/util/virstats.c +++ b/src/util/virstats.c @@ -50,10 +50,10 @@ */ #ifdef __linux__ int -virNetInterfaceStats(const char *path, - virDomainInterfaceStatsPtr stats) +virNetDevTapInterfaceStats(const char *ifname, + virDomainInterfaceStatsPtr stats) { - int path_len; + int ifname_len; FILE *fp; char line[256], *colon; @@ -64,7 +64,7 @@ virNetInterfaceStats(const char *path, return -1; } - path_len = strlen(path); + ifname_len = strlen(ifname); while (fgets(line, sizeof(line), fp)) { long long dummy; @@ -84,8 +84,8 @@ virNetInterfaceStats(const char *path, colon = strchr(line, ':'); if (!colon) continue; *colon = '\0'; - if (colon-path_len >= line && - STREQ(colon-path_len, path)) { + if (colon-ifname_len >= line && + STREQ(colon-ifname_len, ifname)) { /* IMPORTANT NOTE! * /proc/net/dev vif<domid>.nn sees the network from the point * of view of dom0 / hypervisor. So bytes TRANSMITTED by dom0 @@ -121,8 +121,8 @@ virNetInterfaceStats(const char *path, } #elif defined(HAVE_GETIFADDRS) && defined(AF_LINK) int -virNetInterfaceStats(const char *path, - virDomainInterfaceStatsPtr stats) +virNetDevTapInterfaceStats(const char *ifname, + virDomainInterfaceStatsPtr stats) { struct ifaddrs *ifap, *ifa; struct if_data *ifd; @@ -138,7 +138,7 @@ virNetInterfaceStats(const char *path, if (ifa->ifa_addr->sa_family != AF_LINK) continue; - if (STREQ(ifa->ifa_name, path)) { + if (STREQ(ifa->ifa_name, ifname)) { ifd = (struct if_data *)ifa->ifa_data; stats->tx_bytes = ifd->ifi_ibytes; stats->tx_packets = ifd->ifi_ipackets; @@ -167,8 +167,8 @@ virNetInterfaceStats(const char *path, } #else int -virNetInterfaceStats(const char *path ATTRIBUTE_UNUSED, - virDomainInterfaceStatsPtr stats ATTRIBUTE_UNUSED) +virNetDevTapInterfaceStats(const char *ifname ATTRIBUTE_UNUSED, + virDomainInterfaceStatsPtr stats ATTRIBUTE_UNUSED) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("interface stats not implemented on this platform")); diff --git a/src/util/virstats.h b/src/util/virstats.h index 69f4cf1..5b77197 100644 --- a/src/util/virstats.h +++ b/src/util/virstats.h @@ -25,7 +25,8 @@ # include "internal.h" -int virNetInterfaceStats(const char *path, - virDomainInterfaceStatsPtr stats); +int virNetDevTapInterfaceStats(const char *ifname, + virDomainInterfaceStatsPtr stats) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; #endif /* __STATS_LINUX_H__ */ diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index 0177f83..efe5a8f 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -1466,7 +1466,7 @@ xenHypervisorDomainInterfaceStats(virDomainDefPtr def, return -1; } - return virNetInterfaceStats(path, stats); + return virNetDevTapInterfaceStats(path, stats); #else virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("/proc/net/dev: Interface not found")); -- 2.10.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list