mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
virstat: fix signature of virstat helper
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
This commit is contained in:
parent
013df874db
commit
9b6de7c506
@ -2397,7 +2397,7 @@ virSocketAddrSetIPv6AddrNetOrder;
|
||||
virSocketAddrSetPort;
|
||||
|
||||
# util/virstats.h
|
||||
virNetInterfaceStats;
|
||||
virNetDevTapInterfaceStats;
|
||||
|
||||
# util/virstorageencryption.h
|
||||
virStorageEncryptionFormat;
|
||||
|
@ -4985,7 +4985,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);
|
||||
|
@ -2896,7 +2896,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);
|
||||
|
@ -2027,7 +2027,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);
|
||||
|
@ -11009,7 +11009,7 @@ qemuDomainInterfaceStats(virDomainPtr dom,
|
||||
if (virNetDevOpenvswitchInterfaceStats(path, stats) < 0)
|
||||
goto cleanup;
|
||||
} else {
|
||||
if (virNetInterfaceStats(path, stats) < 0)
|
||||
if (virNetDevTapInterfaceStats(path, stats) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -19204,7 +19204,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;
|
||||
}
|
||||
|
@ -50,10 +50,10 @@
|
||||
*/
|
||||
#ifdef __linux__
|
||||
int
|
||||
virNetInterfaceStats(const char *path,
|
||||
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,7 +121,7 @@ virNetInterfaceStats(const char *path,
|
||||
}
|
||||
#elif defined(HAVE_GETIFADDRS) && defined(AF_LINK)
|
||||
int
|
||||
virNetInterfaceStats(const char *path,
|
||||
virNetDevTapInterfaceStats(const char *ifname,
|
||||
virDomainInterfaceStatsPtr stats)
|
||||
{
|
||||
struct ifaddrs *ifap, *ifa;
|
||||
@ -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,7 +167,7 @@ virNetInterfaceStats(const char *path,
|
||||
}
|
||||
#else
|
||||
int
|
||||
virNetInterfaceStats(const char *path ATTRIBUTE_UNUSED,
|
||||
virNetDevTapInterfaceStats(const char *ifname ATTRIBUTE_UNUSED,
|
||||
virDomainInterfaceStatsPtr stats ATTRIBUTE_UNUSED)
|
||||
{
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
|
@ -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__ */
|
||||
|
@ -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"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user