guest_get_network_stats can silently fail in a couple of ways. Add debug messages to these cases, so we're never completely silent on failure.
Signed-off-by: Andrew Deason <adea...@sinenomine.net> Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- Changes since v1: - new in v2 qga/commands-posix.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index b91fdba2c1..cc565e0dfd 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -2764,20 +2764,22 @@ static int guest_get_network_stats(const char *name, GuestNetworkInterfaceStat *stats) { #ifdef CONFIG_LINUX int name_len; char const *devinfo = "/proc/net/dev"; FILE *fp; char *line = NULL, *colon; size_t n = 0; fp = fopen(devinfo, "r"); if (!fp) { + g_debug("failed to open network stats %s: %s", devinfo, + g_strerror(errno)); return -1; } name_len = strlen(name); while (getline(&line, &n, fp) != -1) { long long dummy; long long rx_bytes; long long rx_packets; long long rx_errs; long long rx_dropped; long long tx_bytes; @@ -2812,21 +2814,23 @@ static int guest_get_network_stats(const char *name, stats->tx_errs = tx_errs; stats->tx_dropped = tx_dropped; fclose(fp); g_free(line); return 0; } } fclose(fp); g_free(line); g_debug("/proc/net/dev: Interface '%s' not found", name); -#endif /* CONFIG_LINUX */ +#else /* !CONFIG_LINUX */ + g_debug("Network stats reporting available only for Linux"); +#endif /* !CONFIG_LINUX */ return -1; } /* * Build information about guest interfaces */ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp) { GuestNetworkInterfaceList *head = NULL, **tail = &head; struct ifaddrs *ifap, *ifa; -- 2.11.0