[PATCH 4/4] Report one error less when getting net dev speed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



virFileReadAll already logs an error. If reading the 'speed' file
fails with EINVAL, we log an error even though we ignore it. If it
fails with other errors, we log two errors.

Use virFileReadAllQuiet - ignore EINVAL and report just one error
in other cases.

Fixes this error on libvirtd startup:
2014-06-30 12:47:14.583+0000: 20971: error : virFileReadAll:1297 :
Failed to read file '/sys/class/net/wlan0/speed': Invalid argument
---
 src/util/virnetdev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index a551f98..c3a7384 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1844,6 +1844,7 @@ virNetDevGetLinkInfo(const char *ifname,
     char *tmp;
     int tmp_state;
     unsigned int tmp_speed;
+    int rc;
 
     if (virNetDevSysfsFile(&path, ifname, "operstate") < 0)
         goto cleanup;
@@ -1891,13 +1892,13 @@ virNetDevGetLinkInfo(const char *ifname,
     if (virNetDevSysfsFile(&path, ifname, "speed") < 0)
         goto cleanup;
 
-    if (virFileReadAll(path, 1024, &buf) < 0) {
+    if ((rc = virFileReadAllQuiet(path, 1024, &buf)) < 0) {
         /* Some devices doesn't report speed, in which case we get EINVAL */
-        if (errno == EINVAL) {
+        if (-rc == EINVAL) {
             ret = 0;
             goto cleanup;
         }
-        virReportSystemError(errno,
+        virReportSystemError(-rc,
                              _("unable to read: %s"),
                              path);
         goto cleanup;
-- 
1.8.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]