From nobody Fri May 16 05:43:29 2025 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 1502415780383599.2071697399072; Thu, 10 Aug 2017 18:43:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4B91C098D1F; Fri, 11 Aug 2017 01:42:58 +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 9D4F2600C6; Fri, 11 Aug 2017 01:42:58 +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 4B72F3FCFB; Fri, 11 Aug 2017 01:42:58 +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 v7B1gXmk003154 for ; Thu, 10 Aug 2017 21:42:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD09F98150; Fri, 11 Aug 2017 01:42:33 +0000 (UTC) Received: from vhost2.laine.org (ovpn-117-36.phx2.redhat.com [10.3.117.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5933F98145; Fri, 11 Aug 2017 01:42:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C4B91C098D1F Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=laine.org Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C4B91C098D1F From: Laine Stump To: libvir-list@redhat.com Date: Thu, 10 Aug 2017 21:42:19 -0400 Message-Id: <20170811014222.29548-5-laine@laine.org> In-Reply-To: <20170811014222.29548-1-laine@laine.org> References: <20170811014222.29548-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, moshele@mellanox.com Subject: [libvirt] [PATCH v2 4/7] util: match phys_port_id when converting PF-netdev to/from VF-netdev 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 11 Aug 2017 01:42:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch updates functions in netdev.c to pay attention to phys_port_id. It uses the new function virNetDevGetPhysPortID() to learn the phys_port_id of a VF or PF, then sends that info to virPCIGetNetName(), which has newly been modified to take an optional phys_port_id. --- Change from V1 - Minor changes due to differences in patch 3. src/util/virnetdev.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index b6ef00e2e..5738a8936 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1231,13 +1231,17 @@ virNetDevGetVirtualFunctions(const char *pfname, char *pf_sysfs_device_link =3D NULL; char *pci_sysfs_device_link =3D NULL; char *pciConfigAddr =3D NULL; + char *pfPhysPortID =3D NULL; =20 *virt_fns =3D NULL; *n_vfname =3D 0; *max_vfs =3D 0; =20 + if (virNetDevGetPhysPortID(pfname, &pfPhysPortID) < 0) + goto cleanup; + if (virNetDevSysfsFile(&pf_sysfs_device_link, pfname, "device") < 0) - return ret; + goto cleanup; =20 if (virPCIGetVirtualFunctions(pf_sysfs_device_link, virt_fns, n_vfname, max_vfs) < 0) @@ -1263,7 +1267,7 @@ virNetDevGetVirtualFunctions(const char *pfname, } =20 if (virPCIGetNetName(pci_sysfs_device_link, 0, - NULL, &((*vfname)[i])) < 0) { + pfPhysPortID, &((*vfname)[i])) < 0) { goto cleanup; } =20 @@ -1278,6 +1282,7 @@ virNetDevGetVirtualFunctions(const char *pfname, VIR_FREE(*vfname); VIR_FREE(*virt_fns); } + VIR_FREE(pfPhysPortID); VIR_FREE(pf_sysfs_device_link); VIR_FREE(pci_sysfs_device_link); VIR_FREE(pciConfigAddr); @@ -1359,14 +1364,19 @@ int virNetDevGetPhysicalFunction(const char *ifname, char **pfname) { char *physfn_sysfs_path =3D NULL; + char *vfPhysPortID =3D NULL; int ret =3D -1; =20 + if (virNetDevGetPhysPortID(ifname, &vfPhysPortID) < 0) + goto cleanup; + if (virNetDevSysfsDeviceFile(&physfn_sysfs_path, ifname, "physfn") < 0) - return ret; + goto cleanup; =20 if (virPCIGetNetName(physfn_sysfs_path, 0, - NULL, pfname) < 0) + vfPhysPortID, pfname) < 0) { goto cleanup; + } =20 if (!*pfname) { /* this shouldn't be possible. A VF can't exist unless its @@ -1380,6 +1390,7 @@ virNetDevGetPhysicalFunction(const char *ifname, char= **pfname) =20 ret =3D 0; cleanup: + VIR_FREE(vfPhysPortID); VIR_FREE(physfn_sysfs_path); return ret; } @@ -1407,8 +1418,16 @@ virNetDevPFGetVF(const char *pfname, int vf, char **= vfname) { char *virtfnName =3D NULL; char *virtfnSysfsPath =3D NULL; + char *pfPhysPortID =3D NULL; int ret =3D -1; =20 + /* a VF may have multiple "ports", each one having its own netdev, + * and each netdev having a different phys_port_id. Be sure we get + * the VF netdev with a phys_port_id matchine that of pfname + */ + if (virNetDevGetPhysPortID(pfname, &pfPhysPortID) < 0) + goto cleanup; + if (virAsprintf(&virtfnName, "virtfn%d", vf) < 0) goto cleanup; =20 @@ -1425,11 +1444,12 @@ virNetDevPFGetVF(const char *pfname, int vf, char *= *vfname) * isn't bound to a netdev driver, it won't have a netdev name, * and vfname will be NULL). */ - ret =3D virPCIGetNetName(virtfnSysfsPath, 0, NULL, vfname); + ret =3D virPCIGetNetName(virtfnSysfsPath, 0, pfPhysPortID, vfname); =20 cleanup: VIR_FREE(virtfnName); VIR_FREE(virtfnSysfsPath); + VIR_FREE(pfPhysPortID); =20 return ret; } --=20 2.13.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list