From nobody Fri May 3 21:17:31 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 1516079109164764.670764261977; Mon, 15 Jan 2018 21:05:09 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2875821C1; Tue, 16 Jan 2018 05:05:05 +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 37F5B88388; Tue, 16 Jan 2018 05:05:02 +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 2C1675FBD5; Tue, 16 Jan 2018 05:04:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0G54u26014995 for ; Tue, 16 Jan 2018 00:04:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id F1EB95D970; Tue, 16 Jan 2018 05:04:55 +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 EB3195D96E for ; Tue, 16 Jan 2018 05:04:53 +0000 (UTC) Received: from zmail18.collab.prod.int.phx2.redhat.com (zmail18.collab.prod.int.phx2.redhat.com [10.5.83.21]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 354715FBD5 for ; Tue, 16 Jan 2018 05:04:53 +0000 (UTC) Date: Tue, 16 Jan 2018 00:04:53 -0500 (EST) From: Dan Zheng To: libvir-list@redhat.com Message-ID: <1989589958.4814.1516079093102.JavaMail.zimbra@redhat.com> In-Reply-To: <444827572.4204.1516079026140.JavaMail.zimbra@redhat.com> MIME-Version: 1.0 X-Originating-IP: [10.66.4.186, 10.4.195.3] Thread-Topic: check/add for mdev_types capability Thread-Index: bk/0mhvcOwGLe9LpGdbltfuQz1JWOQ== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id w0G54u26014995 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] check/add for mdev_types capability 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-Type: text/plain; charset="utf-8" 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 16 Jan 2018 05:05:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 >From be62ea5394d52fa168079edc3aa7e558363a3026 Mon Sep 17 00:00:00 2001 From: Dan Zheng Date: Tue, 16 Jan 2018 12:21:21 +0800 Subject: [PATCH] nodedev: check/add for mdev_types capability This is similar to commit f44ec9c1. Commit id '500cbc06' introduced a new nested capability element of type 'mdev_types' and the ability to use the flag as a way to search for a specific subset of a 'pci' device - namely a 'mdev_types'. The code modified the virNodeDeviceCapMatch whichs allows for searching using the 'virsh nodedev-list [cap]' via virConnectListAllNodeDevices. However, the original patches did not account for other searches for the same capability key from virNodeDeviceNumOfCaps and virNodeDeviceListCaps using nodeDeviceNumOfCaps and nodeDeviceListCaps. This patch adds the check for the 'mdev_types' bits within a 'pci' device and allows the following python code to find the capabilities for the device: import libvirt conn =3D libvirt.openReadOnly('qemu:///system') devs =3D conn.listAllDevices() for dev in devs: if 'mdev_types' in dev.listCaps(): print dev.name(),dev.numOfCaps(),dev.listCaps() Signed-off-by: Dan Zheng Reviewed-by: Erik Skultety (and safe for freeze) - I --- src/node_device/node_device_driver.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index facfeb6..6216a69 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -382,6 +382,12 @@ nodeDeviceNumOfCaps(virNodeDevicePtr device) VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS) ncaps++; } + if (caps->data.type =3D=3D VIR_NODE_DEV_CAP_PCI_DEV) { + if (caps->data.pci_dev.flags & + VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) + ncaps++; + } + } =20 ret =3D ncaps; @@ -432,6 +438,15 @@ nodeDeviceListCaps(virNodeDevicePtr device, goto cleanup; } } + if (caps->data.type =3D=3D VIR_NODE_DEV_CAP_PCI_DEV) { + if (ncaps < maxnames && + caps->data.pci_dev.flags & + VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) { + if (VIR_STRDUP(names[ncaps++], + virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_= MDEV_TYPES)) < 0) + goto cleanup; + } + } } ret =3D ncaps; =20 --=20 1.8.3.1 --=20 Best Regards, Dan Zheng(=E9=83=91=E4=B8=B9) Red Hat Software (Beijing) Co. 9/F, North Tower C, Raycom Infotech Park No.2 Ke Xueyuan Nanlu, Haidian District Beijing 100190 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list