提交 6f2a0198 编写于 作者: M Moshe Levi 提交者: John Ferlan

utils: Remove the logging of errors from virNetDevSendEthtoolIoctl

This patch remove the logging of errors of ioctl api and instead
let the caller to choose what errors to log
上级 108d591b
...@@ -3032,39 +3032,15 @@ static int ...@@ -3032,39 +3032,15 @@ static int
virNetDevSendEthtoolIoctl(const char *ifname, void *cmd) virNetDevSendEthtoolIoctl(const char *ifname, void *cmd)
{ {
int ret = -1; int ret = -1;
int sock = -1; int fd;
virIfreq ifr; struct ifreq ifr;
sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
if (sock < 0) {
virReportSystemError(errno, "%s", _("Cannot open control socket"));
goto cleanup;
}
memset(&ifr, 0, sizeof(ifr)); if ((fd = virNetDevSetupControl(ifname, &ifr)) < 0)
strcpy(ifr.ifr_name, ifname); return ret;
ifr.ifr_data = cmd; ifr.ifr_data = cmd;
ret = ioctl(sock, SIOCETHTOOL, &ifr); ret = ioctl(fd, SIOCETHTOOL, &ifr);
if (ret != 0) {
switch (errno) {
case EPERM:
VIR_DEBUG("ethtool ioctl: permission denied");
break;
case EINVAL:
VIR_DEBUG("ethtool ioctl: invalid request");
break;
case EOPNOTSUPP:
VIR_DEBUG("ethtool ioctl: request not supported");
break;
default:
virReportSystemError(errno, "%s", _("ethtool ioctl error"));
goto cleanup;
}
}
cleanup: VIR_FORCE_CLOSE(fd);
if (sock)
VIR_FORCE_CLOSE(sock);
return ret; return ret;
} }
...@@ -3081,12 +3057,12 @@ virNetDevSendEthtoolIoctl(const char *ifname, void *cmd) ...@@ -3081,12 +3057,12 @@ virNetDevSendEthtoolIoctl(const char *ifname, void *cmd)
static int static int
virNetDevFeatureAvailable(const char *ifname, struct ethtool_value *cmd) virNetDevFeatureAvailable(const char *ifname, struct ethtool_value *cmd)
{ {
int ret = -1;
cmd = (void*)cmd; cmd = (void*)cmd;
if (!virNetDevSendEthtoolIoctl(ifname, cmd)) if (virNetDevSendEthtoolIoctl(ifname, cmd) < 0) {
ret = cmd->data > 0 ? 1 : 0; virReportSystemError(errno, _("Cannot get device %s flags"), ifname);
return ret; return -1;
}
return cmd->data > 0 ? 1 : 0;
} }
...@@ -3103,12 +3079,12 @@ virNetDevFeatureAvailable(const char *ifname, struct ethtool_value *cmd) ...@@ -3103,12 +3079,12 @@ virNetDevFeatureAvailable(const char *ifname, struct ethtool_value *cmd)
static int static int
virNetDevGFeatureAvailable(const char *ifname, struct ethtool_gfeatures *cmd) virNetDevGFeatureAvailable(const char *ifname, struct ethtool_gfeatures *cmd)
{ {
int ret = -1;
cmd = (void*)cmd; cmd = (void*)cmd;
if (!virNetDevSendEthtoolIoctl(ifname, cmd)) if (virNetDevSendEthtoolIoctl(ifname, cmd) < 0) {
ret = FEATURE_BIT_IS_SET(cmd->features, TX_UDP_TNL, active); virReportSystemError(errno, _("Cannot get device %s generic features"), ifname);
return ret; return -1;
}
return FEATURE_BIT_IS_SET(cmd->features, TX_UDP_TNL, active);
} }
# endif # endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册