[libvirt] [PATCH 2/3] virnetdev: Message in virNetDevSendEthtoolIoctl rather than caller.

John Ferlan jferlan at redhat.com
Wed Nov 4 00:18:10 UTC 2015


Since virNetDevSetupControl can generate a virReportSystemError, rather
than message in the caller for any errors. Do all the messaging in the
virNetDevSendEthtoolIoctl.

This change partially reverts commit id '6f2a0198' by moving the error
message in the virNetDev[G]FeatureAvailable to where the ioctl fails.
However, the ioctl will report any error rather than filtering some.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/util/virnetdev.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 12faf51..d47859e 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -3157,7 +3157,8 @@ virNetDevSendEthtoolIoctl(const char *ifname, void *cmd)
     if ((fd = virNetDevSetupControl(ifname, &ifr)) < 0)
         return ret;
     ifr.ifr_data = cmd;
-    ret = ioctl(fd, SIOCETHTOOL, &ifr);
+    if ((ret = ioctl(fd, SIOCETHTOOL, &ifr)) < 0)
+        virReportSystemError(errno, "%s", _("ethtool ioctl error"));
 
     VIR_FORCE_CLOSE(fd);
     return ret;
@@ -3176,12 +3177,13 @@ virNetDevSendEthtoolIoctl(const char *ifname, void *cmd)
 static int
 virNetDevFeatureAvailable(const char *ifname, struct ethtool_value *cmd)
 {
+    int ret = -1;
+
     cmd = (void*)cmd;
-    if (virNetDevSendEthtoolIoctl(ifname, cmd) < 0) {
-        virReportSystemError(errno, _("Cannot get device %s flags"), ifname);
-        return -1;
-    }
-    return cmd->data > 0 ? 1 : 0;
+    if (!virNetDevSendEthtoolIoctl(ifname, cmd))
+        ret = cmd->data > 0 ? 1 : 0;
+    return ret;
+
 }
 
 
@@ -3198,12 +3200,12 @@ virNetDevFeatureAvailable(const char *ifname, struct ethtool_value *cmd)
 static int
 virNetDevGFeatureAvailable(const char *ifname, struct ethtool_gfeatures *cmd)
 {
+    int ret = -1;
+
     cmd = (void*)cmd;
-    if (virNetDevSendEthtoolIoctl(ifname, cmd) < 0) {
-        virReportSystemError(errno, _("Cannot get device %s generic features"), ifname);
-        return -1;
-    }
-    return FEATURE_BIT_IS_SET(cmd->features, TX_UDP_TNL, active);
+    if (!virNetDevSendEthtoolIoctl(ifname, cmd))
+        ret = FEATURE_BIT_IS_SET(cmd->features, TX_UDP_TNL, active);
+    return ret;
 }
 # endif
 
-- 
2.1.0




More information about the libvir-list mailing list