mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
util: add device name in errors from ethtool ioctls
Reviewed-by: Laine Stump <laine@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
3791f29b08
commit
090fd6a413
@ -2849,7 +2849,7 @@ virNetDevRDMAFeature(const char *ifname,
|
|||||||
* Returns 0 on success, -1 on failure.
|
* Returns 0 on success, -1 on failure.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
virNetDevSendEthtoolIoctl(int fd, struct ifreq *ifr)
|
virNetDevSendEthtoolIoctl(const char *ifname, int fd, struct ifreq *ifr)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
@ -2857,13 +2857,13 @@ virNetDevSendEthtoolIoctl(int fd, struct ifreq *ifr)
|
|||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
case EINVAL: /* kernel doesn't support SIOCETHTOOL */
|
case EINVAL: /* kernel doesn't support SIOCETHTOOL */
|
||||||
VIR_DEBUG("ethtool ioctl: invalid request");
|
VIR_DEBUG("ethtool ioctl: invalid request on %s", ifname);
|
||||||
break;
|
break;
|
||||||
case EOPNOTSUPP: /* kernel doesn't support specific feature */
|
case EOPNOTSUPP: /* kernel doesn't support specific feature */
|
||||||
VIR_DEBUG("ethtool ioctl: request not supported");
|
VIR_DEBUG("ethtool ioctl: request not supported on %s", ifname);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
virReportSystemError(errno, "%s", _("ethtool ioctl error"));
|
virReportSystemError(errno, _("ethtool ioctl error on %s"), ifname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2888,10 +2888,10 @@ struct virNetDevEthtoolFeatureCmd {
|
|||||||
* Returns true if the feature is available, false otherwise.
|
* Returns true if the feature is available, false otherwise.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
virNetDevFeatureAvailable(int fd, struct ifreq *ifr, struct ethtool_value *cmd)
|
virNetDevFeatureAvailable(const char *ifname, int fd, struct ifreq *ifr, struct ethtool_value *cmd)
|
||||||
{
|
{
|
||||||
ifr->ifr_data = (void*)cmd;
|
ifr->ifr_data = (void*)cmd;
|
||||||
if (virNetDevSendEthtoolIoctl(fd, ifr) == 0 &&
|
if (virNetDevSendEthtoolIoctl(ifname, fd, ifr) == 0 &&
|
||||||
cmd->data > 0)
|
cmd->data > 0)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
@ -2899,7 +2899,8 @@ virNetDevFeatureAvailable(int fd, struct ifreq *ifr, struct ethtool_value *cmd)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
virNetDevGetEthtoolFeatures(virBitmapPtr bitmap,
|
virNetDevGetEthtoolFeatures(const char *ifname,
|
||||||
|
virBitmapPtr bitmap,
|
||||||
int fd,
|
int fd,
|
||||||
struct ifreq *ifr)
|
struct ifreq *ifr)
|
||||||
{
|
{
|
||||||
@ -2941,13 +2942,13 @@ virNetDevGetEthtoolFeatures(virBitmapPtr bitmap,
|
|||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS(ethtool_cmds); i++) {
|
for (i = 0; i < G_N_ELEMENTS(ethtool_cmds); i++) {
|
||||||
cmd.cmd = ethtool_cmds[i].cmd;
|
cmd.cmd = ethtool_cmds[i].cmd;
|
||||||
if (virNetDevFeatureAvailable(fd, ifr, &cmd))
|
if (virNetDevFeatureAvailable(ifname, fd, ifr, &cmd))
|
||||||
ignore_value(virBitmapSetBit(bitmap, ethtool_cmds[i].feat));
|
ignore_value(virBitmapSetBit(bitmap, ethtool_cmds[i].feat));
|
||||||
}
|
}
|
||||||
|
|
||||||
# if WITH_DECL_ETHTOOL_GFLAGS
|
# if WITH_DECL_ETHTOOL_GFLAGS
|
||||||
cmd.cmd = ETHTOOL_GFLAGS;
|
cmd.cmd = ETHTOOL_GFLAGS;
|
||||||
if (virNetDevFeatureAvailable(fd, ifr, &cmd)) {
|
if (virNetDevFeatureAvailable(ifname, fd, ifr, &cmd)) {
|
||||||
for (i = 0; i < G_N_ELEMENTS(flags); i++) {
|
for (i = 0; i < G_N_ELEMENTS(flags); i++) {
|
||||||
if (cmd.data & flags[i].cmd)
|
if (cmd.data & flags[i].cmd)
|
||||||
ignore_value(virBitmapSetBit(bitmap, flags[i].feat));
|
ignore_value(virBitmapSetBit(bitmap, flags[i].feat));
|
||||||
@ -3133,19 +3134,21 @@ virNetDevSwitchdevFeature(const char *ifname G_GNUC_UNUSED,
|
|||||||
* Returns true if the feature is available, false otherwise.
|
* Returns true if the feature is available, false otherwise.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
virNetDevGFeatureAvailable(int fd,
|
virNetDevGFeatureAvailable(const char *ifname,
|
||||||
|
int fd,
|
||||||
struct ifreq *ifr,
|
struct ifreq *ifr,
|
||||||
struct ethtool_gfeatures *cmd)
|
struct ethtool_gfeatures *cmd)
|
||||||
{
|
{
|
||||||
ifr->ifr_data = (void*)cmd;
|
ifr->ifr_data = (void*)cmd;
|
||||||
if (virNetDevSendEthtoolIoctl(fd, ifr) == 0)
|
if (virNetDevSendEthtoolIoctl(ifname, fd, ifr) == 0)
|
||||||
return !!FEATURE_BIT_IS_SET(cmd->features, TX_UDP_TNL, active);
|
return !!FEATURE_BIT_IS_SET(cmd->features, TX_UDP_TNL, active);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap,
|
virNetDevGetEthtoolGFeatures(const char *ifname,
|
||||||
|
virBitmapPtr bitmap,
|
||||||
int fd,
|
int fd,
|
||||||
struct ifreq *ifr)
|
struct ifreq *ifr)
|
||||||
{
|
{
|
||||||
@ -3157,13 +3160,14 @@ virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap,
|
|||||||
|
|
||||||
g_cmd->cmd = ETHTOOL_GFEATURES;
|
g_cmd->cmd = ETHTOOL_GFEATURES;
|
||||||
g_cmd->size = GFEATURES_SIZE;
|
g_cmd->size = GFEATURES_SIZE;
|
||||||
if (virNetDevGFeatureAvailable(fd, ifr, g_cmd))
|
if (virNetDevGFeatureAvailable(ifname, fd, ifr, g_cmd))
|
||||||
ignore_value(virBitmapSetBit(bitmap, VIR_NET_DEV_FEAT_TXUDPTNL));
|
ignore_value(virBitmapSetBit(bitmap, VIR_NET_DEV_FEAT_TXUDPTNL));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
static int
|
static int
|
||||||
virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap G_GNUC_UNUSED,
|
virNetDevGetEthtoolGFeatures(const char *ifname G_GNUC_UNUSED,
|
||||||
|
virBitmapPtr bitmap G_GNUC_UNUSED,
|
||||||
int fd G_GNUC_UNUSED,
|
int fd G_GNUC_UNUSED,
|
||||||
struct ifreq *ifr G_GNUC_UNUSED)
|
struct ifreq *ifr G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
@ -3228,7 +3232,7 @@ int virNetDevSetCoalesce(const char *ifname,
|
|||||||
|
|
||||||
ifr.ifr_data = (void *) &coal;
|
ifr.ifr_data = (void *) &coal;
|
||||||
|
|
||||||
if (virNetDevSendEthtoolIoctl(fd, &ifr) < 0) {
|
if (virNetDevSendEthtoolIoctl(ifname, fd, &ifr) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Cannot set coalesce info on '%s'"),
|
_("Cannot set coalesce info on '%s'"),
|
||||||
ifname);
|
ifname);
|
||||||
@ -3241,7 +3245,7 @@ int virNetDevSetCoalesce(const char *ifname,
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Don't fail if the update itself fails */
|
/* Don't fail if the update itself fails */
|
||||||
if (virNetDevSendEthtoolIoctl(fd, &ifr) == 0) {
|
if (virNetDevSendEthtoolIoctl(ifname, fd, &ifr) == 0) {
|
||||||
coalesce->rx_max_coalesced_frames = coal.rx_max_coalesced_frames;
|
coalesce->rx_max_coalesced_frames = coal.rx_max_coalesced_frames;
|
||||||
coalesce->rx_coalesce_usecs_irq = coal.rx_coalesce_usecs_irq;
|
coalesce->rx_coalesce_usecs_irq = coal.rx_coalesce_usecs_irq;
|
||||||
coalesce->rx_max_coalesced_frames_irq = coal.rx_max_coalesced_frames_irq;
|
coalesce->rx_max_coalesced_frames_irq = coal.rx_max_coalesced_frames_irq;
|
||||||
@ -3307,9 +3311,9 @@ virNetDevGetFeatures(const char *ifname,
|
|||||||
if ((fd = virNetDevSetupControl(ifname, &ifr)) < 0)
|
if ((fd = virNetDevSetupControl(ifname, &ifr)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
virNetDevGetEthtoolFeatures(*out, fd, &ifr);
|
virNetDevGetEthtoolFeatures(ifname, *out, fd, &ifr);
|
||||||
|
|
||||||
if (virNetDevGetEthtoolGFeatures(*out, fd, &ifr) < 0)
|
if (virNetDevGetEthtoolGFeatures(ifname, *out, fd, &ifr) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virNetDevRDMAFeature(ifname, out) < 0)
|
if (virNetDevRDMAFeature(ifname, out) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user