From nobody Mon Feb 9 08:56:45 2026 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 155238930931771.36239126409623; Tue, 12 Mar 2019 04:15:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57E9137E79; Tue, 12 Mar 2019 11:15:07 +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 1C1791001E74; Tue, 12 Mar 2019 11:15:07 +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 BD0D9181A136; Tue, 12 Mar 2019 11:15:06 +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 x2CBF5Uo007265 for ; Tue, 12 Mar 2019 07:15:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5A5A960FD1; Tue, 12 Mar 2019 11:15:05 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 543BC60FFE for ; Tue, 12 Mar 2019 11:15:03 +0000 (UTC) Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) (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 658F8C057F42 for ; Tue, 12 Mar 2019 11:15:01 +0000 (UTC) Received: from [10.94.3.220] (helo=dim-vz7.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1h3fN3-0003r0-NI for libvir-list@redhat.com; Tue, 12 Mar 2019 14:14:57 +0300 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Date: Tue, 12 Mar 2019 14:14:40 +0300 Message-Id: <1552389281-629582-3-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1552389281-629582-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1552389281-629582-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Greylist: Sender passed SPF test, ACL 242 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 12 Mar 2019 11:15:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 12 Mar 2019 11:15:01 +0000 (UTC) for IP:'185.231.240.75' DOMAIN:'relay.sw.ru' HELO:'relay.sw.ru' FROM:'nshirokovskiy@virtuozzo.com' RCPT:'' X-RedHat-Spam-Score: -0.001 (SPF_PASS) 185.231.240.75 relay.sw.ru 185.231.240.75 relay.sw.ru X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/3] xml: nodedev: add class info for pci 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: , 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 12 Mar 2019 11:15:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This info can be useful to filter devices visible to mgmt clients so that they won't see devices that unsafe/not meaningful to pass thru. Provide class info the way it is provided by udev or kernel that is as single 6-digit hexadecimal. Class element is not optional. I guess this should not break users that use virNodeDeviceCreateXML because they probably specify only scsi_host capability on input and then node device driver gets other capabilities from udev after device appeared. HAL driver does not get support for the new element in this patch. Signed-off-by: Nikolay Shirokovskiy Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/formatnode.html.in | 5 +++++ docs/schemas/nodedev.rng | 5 +++++ src/conf/node_device_conf.c | 13 +++++++++= ++++ tests/nodedevschemadata/pci_0000_00_02_0_header_type.xml | 1 + tests/nodedevschemadata/pci_0000_00_1c_0_header_type.xml | 1 + tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml | 1 + tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml | 1 + .../nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml | 1 + .../pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml | 1 + tests/nodedevschemadata/pci_0000_02_10_7_sriov_vfs.xml | 1 + .../pci_0000_02_10_7_sriov_zero_vfs_max_count.xml | 1 + tests/nodedevschemadata/pci_1002_71c4.xml | 1 + tests/nodedevschemadata/pci_8086_0c0c_snd_hda_intel.xml | 1 + tests/nodedevschemadata/pci_8086_10c9_sriov_pf.xml | 1 + tests/nodedevschemadata/pci_8086_4238_pcie_wireless.xml | 1 + tests/nodedevschemadata/pci_82579LM_network_adapter.xml | 1 + 16 files changed, 36 insertions(+) diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in index 29244a8984..5095b97d8a 100644 --- a/docs/formatnode.html.in +++ b/docs/formatnode.html.in @@ -70,6 +70,10 @@
Describes a device on the host's PCI bus. Sub-elements include:
+
class
+
Combined class, subclass and + programming interface codes as 6-digit hexadecimal number. + Since 5.2.0
domain
Which domain the device belongs to.
bus
@@ -381,6 +385,7 @@ <name>igb</name> </driver> <capability type=3D'pci'> + <class>0x020000</class> <domain>0</domain> <bus>2</bus> <slot>0</slot> diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 0498489cfd..0f45d7993e 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -133,6 +133,11 @@ pci =20 + + + 0x[0-9a-fA-F]{6} + + diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 5de51d1f6b..19c601ae11 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -208,6 +208,7 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf, { size_t i; =20 + virBufferAsprintf(buf, "0x%.6x\n", data->pci_dev.klass); virBufferAsprintf(buf, "%d\n", data->pci_dev.domain); virBufferAsprintf(buf, "%d\n", data->pci_dev.bus); @@ -1644,6 +1645,18 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, orignode =3D ctxt->node; ctxt->node =3D node; =20 + if (virNodeDevCapsDefParseHexId("string(./class[1])", ctxt, + &pci_dev->klass, def, + _("no PCI class supplied for '%s'"), + _("invalid PCI class supplied for '%s'= ")) < 0) + goto out; + + if (pci_dev->klass > 0xffffff) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid PCI class supplied for '%s'"), def->name= ); + goto out; + } + if (virNodeDevCapsDefParseULong("number(./domain[1])", ctxt, &pci_dev->domain, def, _("no PCI domain ID supplied for '%s'"= ), diff --git a/tests/nodedevschemadata/pci_0000_00_02_0_header_type.xml b/tes= ts/nodedevschemadata/pci_0000_00_02_0_header_type.xml index 5150fd1e8b..387fce7051 100644 --- a/tests/nodedevschemadata/pci_0000_00_02_0_header_type.xml +++ b/tests/nodedevschemadata/pci_0000_00_02_0_header_type.xml @@ -2,6 +2,7 @@ pci_0000_00_02_0 computer + 0xffffff 0 0 2 diff --git a/tests/nodedevschemadata/pci_0000_00_1c_0_header_type.xml b/tes= ts/nodedevschemadata/pci_0000_00_1c_0_header_type.xml index c1be9f7d9c..b07d14faa5 100644 --- a/tests/nodedevschemadata/pci_0000_00_1c_0_header_type.xml +++ b/tests/nodedevschemadata/pci_0000_00_1c_0_header_type.xml @@ -2,6 +2,7 @@ pci_0000_00_1c_0 computer + 0xffffff 0 0 28 diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml b/test= s/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml index a2d57569af..8e71e3f897 100644 --- a/tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml +++ b/tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml @@ -2,6 +2,7 @@ pci_0000_02_10_7 pci_0000_00_04_0 + 0xffffff 0 2 16 diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml b/tests/nod= edevschemadata/pci_0000_02_10_7_sriov.xml index 8f243b4d61..6fa2b406a5 100644 --- a/tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml +++ b/tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml @@ -2,6 +2,7 @@ pci_0000_02_10_7 pci_0000_00_04_0 + 0xffffff 0 2 16 diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml = b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml index 9e8dace020..74036a65fa 100644 --- a/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml +++ b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml @@ -2,6 +2,7 @@ pci_0000_02_10_7 pci_0000_00_04_0 + 0xffffff 0 2 16 diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all_head= er_type.xml b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all_hea= der_type.xml index 4e6323a3ec..c30c0d0d2b 100644 --- a/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all_header_type= .xml +++ b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all_header_type= .xml @@ -2,6 +2,7 @@ pci_0000_02_10_7 pci_0000_00_04_0 + 0xffffff 0 2 16 diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_sriov_vfs.xml b/tests= /nodedevschemadata/pci_0000_02_10_7_sriov_vfs.xml index 355eaaad97..096055e2ae 100644 --- a/tests/nodedevschemadata/pci_0000_02_10_7_sriov_vfs.xml +++ b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_vfs.xml @@ -2,6 +2,7 @@ pci_0000_02_10_7 pci_0000_00_04_0 + 0xffffff 0 2 16 diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_sriov_zero_vfs_max_co= unt.xml b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_zero_vfs_max_count= .xml index e9eb122bfe..8259cd059b 100644 --- a/tests/nodedevschemadata/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml +++ b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml @@ -2,6 +2,7 @@ pci_0000_02_10_7 pci_0000_00_04_0 + 0xffffff 0 2 16 diff --git a/tests/nodedevschemadata/pci_1002_71c4.xml b/tests/nodedevschem= adata/pci_1002_71c4.xml index 6d5d85bc3c..2039e2201f 100644 --- a/tests/nodedevschemadata/pci_1002_71c4.xml +++ b/tests/nodedevschemadata/pci_1002_71c4.xml @@ -2,6 +2,7 @@ pci_1002_71c4 pci_8086_27a1 + 0xffffff 0 1 0 diff --git a/tests/nodedevschemadata/pci_8086_0c0c_snd_hda_intel.xml b/test= s/nodedevschemadata/pci_8086_0c0c_snd_hda_intel.xml index 8e8990073d..3ffe53b8c9 100644 --- a/tests/nodedevschemadata/pci_8086_0c0c_snd_hda_intel.xml +++ b/tests/nodedevschemadata/pci_8086_0c0c_snd_hda_intel.xml @@ -2,6 +2,7 @@ pci_0000_00_03_0 computer + 0xffffff 0 0 3 diff --git a/tests/nodedevschemadata/pci_8086_10c9_sriov_pf.xml b/tests/nod= edevschemadata/pci_8086_10c9_sriov_pf.xml index 6e1dc868a6..6bd1292095 100644 --- a/tests/nodedevschemadata/pci_8086_10c9_sriov_pf.xml +++ b/tests/nodedevschemadata/pci_8086_10c9_sriov_pf.xml @@ -2,6 +2,7 @@ pci_0000_02_00_0 pci_0000_00_04_0 + 0xffffff 0 2 0 diff --git a/tests/nodedevschemadata/pci_8086_4238_pcie_wireless.xml b/test= s/nodedevschemadata/pci_8086_4238_pcie_wireless.xml index 18172e900b..59f5ec8622 100644 --- a/tests/nodedevschemadata/pci_8086_4238_pcie_wireless.xml +++ b/tests/nodedevschemadata/pci_8086_4238_pcie_wireless.xml @@ -2,6 +2,7 @@ pci_0000_03_00_0 pci_0000_00_1c_1 + 0xffffff 0 3 0 diff --git a/tests/nodedevschemadata/pci_82579LM_network_adapter.xml b/test= s/nodedevschemadata/pci_82579LM_network_adapter.xml index 6e154d6de3..96a4c51762 100644 --- a/tests/nodedevschemadata/pci_82579LM_network_adapter.xml +++ b/tests/nodedevschemadata/pci_82579LM_network_adapter.xml @@ -5,6 +5,7 @@ e1000e + 0xffffff 0 0 25 --=20 2.16.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list