From nobody Sun May 5 20:02:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1505811258802544.5676701092145; Tue, 19 Sep 2017 01:54:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8AAC481DE5; Tue, 19 Sep 2017 08:54:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3DDF60618; Tue, 19 Sep 2017 08:54:16 +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 B9E7E1806104; Tue, 19 Sep 2017 08:54:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8J8VcQx019660 for ; Tue, 19 Sep 2017 04:31:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id A0DB35C891; Tue, 19 Sep 2017 08:31:38 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.219]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A0515C542 for ; Tue, 19 Sep 2017 08:31:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8AAC481DE5 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Date: Tue, 19 Sep 2017 10:31:31 +0200 Message-Id: <20170919083131.26162-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] configure: Fix devlink detection 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 19 Sep 2017 08:54:18 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There are some quirks to detecting whether devlink support can be activated due to symbols being renamed between Linux versions. Make detection more robust so that the code can once again compile on RHEL 7 and others. Signed-off-by: Andrea Bolognani --- configure.ac | 26 ++++++++++++++++++++++---- src/util/virnetdev.c | 5 +++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index c9509c7f9..6f03152b4 100644 --- a/configure.ac +++ b/configure.ac @@ -632,12 +632,30 @@ dnl check for kernel headers required by devlink dnl if test "$with_linux" =3D "yes"; then AC_CHECK_HEADERS([linux/devlink.h]) - AC_CHECK_DECLS([DEVLINK_GENL_VERSION, DEVLINK_GENL_NAME, DEVLINK_ATTR_= MAX, DEVLINK_CMD_ESWITCH_GET, DEVLINK_ATTR_BUS_NAME, DEVLINK_ATTR_DEV_NAME,= DEVLINK_ATTR_ESWITCH_MODE, DEVLINK_ESWITCH_MODE_SWITCHDEV], - [AC_DEFINE([HAVE_DECL_DEVLINK], - [1], - [whether devlink declarations are available]= )], + + dnl DEVLINK_CMD_ESWITCH_MODE_GET was introduced in Linux 4.8, but Linux + dnl 4.11 renamed it to DEVLINK_CMD_ESWITCH_GET. We can use either, but + dnl we need at least one of them to be available + have_eswitch_get=3D0 + AC_CHECK_DECLS([DEVLINK_CMD_ESWITCH_GET, DEVLINK_CMD_ESWITCH_MODE_GET], + [have_eswitch_get=3D1], + [], + [[#include ]]) + + dnl We use a bunch of other symbols as well + have_all_others=3D1 + AC_CHECK_DECLS([DEVLINK_GENL_VERSION, DEVLINK_GENL_NAME, DEVLINK_ATTR_= MAX, DEVLINK_ATTR_BUS_NAME, DEVLINK_ATTR_DEV_NAME, DEVLINK_ATTR_ESWITCH_MOD= E, DEVLINK_ESWITCH_MODE_SWITCHDEV], [], + [have_all_others=3D0], [[#include ]]) + + dnl If we have at least one variation of DEVLINK_CMD_ESWITCH_GET *and* + dnl all other symbols, then we can enable the devlink code + if test have_eswitch_get =3D 1 && test have_all_others =3D 1; then + AC_DEFINE_UNQUOTED([HAVE_DECL_DEVLINK], + [1], + [whether devlink declarations are available]) + fi fi =20 dnl Allow perl/python overrides diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 040693925..1e0a257e1 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -3245,7 +3245,12 @@ virNetDevSwitchdevFeature(const char *ifname, if (!(gmsgh =3D virNetDevPutExtraHeader(nlmsg_hdr(nl_msg), sizeof(stru= ct genlmsghdr)))) goto cleanup; =20 +#if HAVE_DEVLINK_CMD_ESWITCH_GET gmsgh->cmd =3D DEVLINK_CMD_ESWITCH_GET; +#elif HAVE_DEVLINK_CMD_ESWITCH_MODE_GET + gmsgh->cmd =3D DEVLINK_CMD_ESWITCH_MODE_GET; +#endif + gmsgh->version =3D DEVLINK_GENL_VERSION; =20 pci_device_ptr =3D pfname ? virNetDevGetPCIDevice(pfname) : --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list