From nobody Thu May 2 19:10:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599140054; cv=none; d=zohomail.com; s=zohoarc; b=QZpWz7TbdI3WTfclXqaih2eM2QVJsgPSRt+9Ok0jQBFuP9VVhj3sB3kaBRV9iwWcZQwQh+zsA3r60lczHiS19e0DprufbAkMxNe79Dd0l5zeCYOc6EqHUOMqhV48Rqgf36diaxXktMEASnlc+ixjZ56G8RKTgGPEyB3/wsKWle8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599140054; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=1mhdxSNQUp78FHr7aWGT+7FmLY5F+dgBAM2xcILv4Ao=; b=XE6hxXhvsMikNWlr/F5JG6hnRn81067PNlogAGtQKHt+1NyZhqxiFZzhlHMaDfVngiv3UEf83UFE33Vv893kCovKS8i9uHGyrr44zLQZi0AXF0p1NqVKprOBdNNPkVS9CLAWLrU8HCgfAGoHfs1QcIyadYHgiTyRQ35rWHmngjM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1599140054423385.3020409710401; Thu, 3 Sep 2020 06:34:14 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-335-hBXSA56gOuqF86OCvbF-Eg-1; Thu, 03 Sep 2020 09:34:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BFC8D801AB3; Thu, 3 Sep 2020 13:34:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 16FCD5D9CC; Thu, 3 Sep 2020 13:34:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3874979DAE; Thu, 3 Sep 2020 13:34:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 083DXwqL026546 for ; Thu, 3 Sep 2020 09:33:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2570F1A340; Thu, 3 Sep 2020 13:33:58 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 879C319C78; Thu, 3 Sep 2020 13:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599140053; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1mhdxSNQUp78FHr7aWGT+7FmLY5F+dgBAM2xcILv4Ao=; b=OrN6tOwNmEjhoEtlkflfI70fqzYijw5p11BBAkEkGTpRiLM6bcFoL8YB3wxrXN772OM6wN NODHttslArnwAmGaSjUoMoIx70ck/kYuCaxAKI0CJFi0GsSPhQpZ3YOuZt7sfBEawGby/6 eMEM4irjch1/yeA03iqewDsnIZGRsk4= X-MC-Unique: hBXSA56gOuqF86OCvbF-Eg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [PATCH] util: add device name in errors from ethtool ioctls Date: Thu, 3 Sep 2020 14:33:55 +0100 Message-Id: <20200903133355.3575460-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Laine Stump --- src/util/virnetdev.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 3040f129d1..e1a4cc2bef 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -2849,7 +2849,7 @@ virNetDevRDMAFeature(const char *ifname, * Returns 0 on success, -1 on failure. */ static int -virNetDevSendEthtoolIoctl(int fd, struct ifreq *ifr) +virNetDevSendEthtoolIoctl(const char *ifname, int fd, struct ifreq *ifr) { int ret =3D -1; =20 @@ -2857,13 +2857,13 @@ virNetDevSendEthtoolIoctl(int fd, struct ifreq *ifr) if (ret !=3D 0) { switch (errno) { case EINVAL: /* kernel doesn't support SIOCETHTOOL */ - VIR_DEBUG("ethtool ioctl: invalid request"); + VIR_DEBUG("ethtool ioctl: invalid request on %s", ifname); break; 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; default: - virReportSystemError(errno, "%s", _("ethtool ioctl error")); + virReportSystemError(errno, _("ethtool ioctl error on %s"), if= name); break; } } @@ -2888,10 +2888,10 @@ struct virNetDevEthtoolFeatureCmd { * Returns true if the feature is available, false otherwise. */ static bool -virNetDevFeatureAvailable(int fd, struct ifreq *ifr, struct ethtool_value = *cmd) +virNetDevFeatureAvailable(const char *ifname, int fd, struct ifreq *ifr, s= truct ethtool_value *cmd) { ifr->ifr_data =3D (void*)cmd; - if (virNetDevSendEthtoolIoctl(fd, ifr) =3D=3D 0 && + if (virNetDevSendEthtoolIoctl(ifname, fd, ifr) =3D=3D 0 && cmd->data > 0) return true; return false; @@ -2899,7 +2899,8 @@ virNetDevFeatureAvailable(int fd, struct ifreq *ifr, = struct ethtool_value *cmd) =20 =20 static void -virNetDevGetEthtoolFeatures(virBitmapPtr bitmap, +virNetDevGetEthtoolFeatures(const char *ifname, + virBitmapPtr bitmap, int fd, struct ifreq *ifr) { @@ -2941,13 +2942,13 @@ virNetDevGetEthtoolFeatures(virBitmapPtr bitmap, =20 for (i =3D 0; i < G_N_ELEMENTS(ethtool_cmds); i++) { cmd.cmd =3D ethtool_cmds[i].cmd; - if (virNetDevFeatureAvailable(fd, ifr, &cmd)) + if (virNetDevFeatureAvailable(ifname, fd, ifr, &cmd)) ignore_value(virBitmapSetBit(bitmap, ethtool_cmds[i].feat)); } =20 # if WITH_DECL_ETHTOOL_GFLAGS cmd.cmd =3D ETHTOOL_GFLAGS; - if (virNetDevFeatureAvailable(fd, ifr, &cmd)) { + if (virNetDevFeatureAvailable(ifname, fd, ifr, &cmd)) { for (i =3D 0; i < G_N_ELEMENTS(flags); i++) { if (cmd.data & flags[i].cmd) 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. */ static bool -virNetDevGFeatureAvailable(int fd, +virNetDevGFeatureAvailable(const char *ifname, + int fd, struct ifreq *ifr, struct ethtool_gfeatures *cmd) { ifr->ifr_data =3D (void*)cmd; - if (virNetDevSendEthtoolIoctl(fd, ifr) =3D=3D 0) + if (virNetDevSendEthtoolIoctl(ifname, fd, ifr) =3D=3D 0) return !!FEATURE_BIT_IS_SET(cmd->features, TX_UDP_TNL, active); return false; } =20 =20 static int -virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap, +virNetDevGetEthtoolGFeatures(const char *ifname, + virBitmapPtr bitmap, int fd, struct ifreq *ifr) { @@ -3157,13 +3160,14 @@ virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap, =20 g_cmd->cmd =3D ETHTOOL_GFEATURES; g_cmd->size =3D GFEATURES_SIZE; - if (virNetDevGFeatureAvailable(fd, ifr, g_cmd)) + if (virNetDevGFeatureAvailable(ifname, fd, ifr, g_cmd)) ignore_value(virBitmapSetBit(bitmap, VIR_NET_DEV_FEAT_TXUDPTNL)); return 0; } # else 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, struct ifreq *ifr G_GNUC_UNUSED) { @@ -3228,7 +3232,7 @@ int virNetDevSetCoalesce(const char *ifname, =20 ifr.ifr_data =3D (void *) &coal; =20 - if (virNetDevSendEthtoolIoctl(fd, &ifr) < 0) { + if (virNetDevSendEthtoolIoctl(ifname, fd, &ifr) < 0) { virReportSystemError(errno, _("Cannot set coalesce info on '%s'"), ifname); @@ -3241,7 +3245,7 @@ int virNetDevSetCoalesce(const char *ifname, }; =20 /* Don't fail if the update itself fails */ - if (virNetDevSendEthtoolIoctl(fd, &ifr) =3D=3D 0) { + if (virNetDevSendEthtoolIoctl(ifname, fd, &ifr) =3D=3D 0) { coalesce->rx_max_coalesced_frames =3D coal.rx_max_coalesced_fr= ames; coalesce->rx_coalesce_usecs_irq =3D coal.rx_coalesce_usecs_irq; coalesce->rx_max_coalesced_frames_irq =3D coal.rx_max_coalesce= d_frames_irq; @@ -3307,9 +3311,9 @@ virNetDevGetFeatures(const char *ifname, if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) return -1; =20 - virNetDevGetEthtoolFeatures(*out, fd, &ifr); + virNetDevGetEthtoolFeatures(ifname, *out, fd, &ifr); =20 - if (virNetDevGetEthtoolGFeatures(*out, fd, &ifr) < 0) + if (virNetDevGetEthtoolGFeatures(ifname, *out, fd, &ifr) < 0) return -1; =20 if (virNetDevRDMAFeature(ifname, out) < 0) --=20 2.25.4