From nobody Thu May 15 02:21:58 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 1515586786191102.71252064176213; Wed, 10 Jan 2018 04:19:46 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D7373A252; Wed, 10 Jan 2018 12:19:44 +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 01CD3811B6; Wed, 10 Jan 2018 12:19:44 +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 1CCDF410B3; Wed, 10 Jan 2018 12:19:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0ACIcPE027336 for ; Wed, 10 Jan 2018 07:18:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1299080E97; Wed, 10 Jan 2018 12:18:37 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1083680E1C; Wed, 10 Jan 2018 12:18:35 +0000 (UTC) Received: from huawei.com (unknown [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0EA7C780FC; Wed, 10 Jan 2018 12:18:10 +0000 (UTC) Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 7360A863F79A5; Wed, 10 Jan 2018 20:17:52 +0800 (CST) Received: from HSH1000044456.huawei.com (10.184.157.230) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.361.1; Wed, 10 Jan 2018 20:17:44 +0800 From: Wu Zongyong To: Date: Wed, 10 Jan 2018 20:14:51 +0800 Message-ID: <1515586491-2808-4-git-send-email-cordius.wu@huawei.com> In-Reply-To: <1515586491-2808-1-git-send-email-cordius.wu@huawei.com> References: <1515586491-2808-1-git-send-email-cordius.wu@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.184.157.230] X-CFilter-Loop: Reflected X-Greylist: Delayed for 48:39:55 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 10 Jan 2018 12:18:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 10 Jan 2018 12:18:15 +0000 (UTC) for IP:'45.249.212.32' DOMAIN:'[45.249.212.32]' HELO:'huawei.com' FROM:'cordius.wu@huawei.com' RCPT:'' X-RedHat-Spam-Score: 1.272 * (RDNS_NONE, SPF_HELO_PASS, SPF_PASS) 45.249.212.32 [45.249.212.32] 45.249.212.32 [45.249.212.32] X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: weijinfen@huawei.com, wanzongshun@huawei.com, eskultet@redhat.com Subject: [libvirt] [PATCH 3/3] nodedev: update caps before invoking nodedev driver interfaces 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: , 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 10 Jan 2018 12:19:45 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Some capabilities of node devices rely on what driver they bound to, and therefore, these capabilities may change when the driver change. So, it is necessary to manually update devices' capabilities each time before nodedev driver interfaces invoked. Signed-off-by: Wu Zongyong --- src/node_device/node_device_driver.c | 55 ++++++++++++++++++++++++++++++++= ++++ 1 file changed, 55 insertions(+) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index facfeb6..d854516 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -155,6 +155,42 @@ nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def ATT= RIBUTE_UNUSED) #endif =20 =20 +static int +nodeConnectUpdateAllNodeDevicesCaps(virConnectPtr conn, + virNodeDeviceObjListFilter filter) +{ + int ret =3D -1; + size_t i; + virNodeDevicePtr *devices; + + if (virNodeDeviceObjListExport(conn, driver->devs, &devices, filter, 0= ) < 0) + return -1; + + for (i =3D 0; devices[i]; i++) { + virNodeDeviceObjPtr obj; + virNodeDeviceDefPtr def; + + if (!(obj =3D virNodeDeviceObjListFindByName(driver->devs, devices= [i]->name))) + goto cleanup; + def =3D virNodeDeviceObjGetDef(obj); + + if (nodeDeviceUpdateCaps(def) < 0) { + virNodeDeviceObjEndAPI(&obj); + goto cleanup; + } + + virNodeDeviceObjEndAPI(&obj); + } + + ret =3D 0; + cleanup: + for (i =3D 0; devices[i]; i++) + virObjectUnref(devices[i]); + VIR_FREE(devices); + return ret; +} + + void nodeDeviceLock(void) { @@ -179,6 +215,9 @@ nodeNumOfDevices(virConnectPtr conn, =20 virCheckFlags(0, -1); =20 + if (nodeConnectUpdateAllNodeDevicesCaps(conn, virNodeNumOfDevicesCheck= ACL) < 0) + return -1; + return virNodeDeviceObjListNumOfDevices(driver->devs, conn, cap, virNodeNumOfDevicesCheckACL); } @@ -196,6 +235,9 @@ nodeListDevices(virConnectPtr conn, =20 virCheckFlags(0, -1); =20 + if (nodeConnectUpdateAllNodeDevicesCaps(conn, virNodeListDevicesCheckA= CL) < 0) + return -1; + return virNodeDeviceObjListGetNames(driver->devs, conn, virNodeListDevicesCheckACL, cap, names, maxnames); @@ -212,6 +254,10 @@ nodeConnectListAllNodeDevices(virConnectPtr conn, if (virConnectListAllNodeDevicesEnsureACL(conn) < 0) return -1; =20 + if (nodeConnectUpdateAllNodeDevicesCaps(conn, + virConnectListAllNodeDevicesCh= eckACL) < 0) + return -1; + return virNodeDeviceObjListExport(conn, driver->devs, devices, virConnectListAllNodeDevicesCheckACL, flags); @@ -248,6 +294,9 @@ nodeDeviceLookupByName(virConnectPtr conn, if (virNodeDeviceLookupByNameEnsureACL(conn, def) < 0) goto cleanup; =20 + if (nodeDeviceUpdateCaps(def) < 0) + goto cleanup; + if ((device =3D virGetNodeDevice(conn, name))) { if (VIR_STRDUP(device->parent, def->parent) < 0) { virObjectUnref(device); @@ -370,6 +419,9 @@ nodeDeviceNumOfCaps(virNodeDevicePtr device) if (virNodeDeviceNumOfCapsEnsureACL(device->conn, def) < 0) goto cleanup; =20 + if (nodeDeviceUpdateCaps(def) < 0) + goto cleanup; + for (caps =3D def->caps; caps; caps =3D caps->next) { ++ncaps; =20 @@ -411,6 +463,9 @@ nodeDeviceListCaps(virNodeDevicePtr device, if (virNodeDeviceListCapsEnsureACL(device->conn, def) < 0) goto cleanup; =20 + if (nodeDeviceUpdateCaps(def) < 0) + goto cleanup; + for (caps =3D def->caps; caps && ncaps < maxnames; caps =3D caps->next= ) { if (VIR_STRDUP(names[ncaps++], virNodeDevCapTypeToString(caps->dat= a.type)) < 0) goto cleanup; --=20 1.9.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list