]> xenbits.xensource.com Git - libvirt.git/commitdiff
xml: nodedev: add class info for pci capability
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Tue, 19 Feb 2019 12:41:37 +0000 (15:41 +0300)
committerNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Mon, 18 Mar 2019 08:14:58 +0000 (11:14 +0300)
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 <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
16 files changed:
docs/formatnode.html.in
docs/schemas/nodedev.rng
src/conf/node_device_conf.c
tests/nodedevschemadata/pci_0000_00_02_0_header_type.xml
tests/nodedevschemadata/pci_0000_00_1c_0_header_type.xml
tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml
tests/nodedevschemadata/pci_0000_02_10_7_sriov.xml
tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml
tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml
tests/nodedevschemadata/pci_0000_02_10_7_sriov_vfs.xml
tests/nodedevschemadata/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml
tests/nodedevschemadata/pci_1002_71c4.xml
tests/nodedevschemadata/pci_8086_0c0c_snd_hda_intel.xml
tests/nodedevschemadata/pci_8086_10c9_sriov_pf.xml
tests/nodedevschemadata/pci_8086_4238_pcie_wireless.xml
tests/nodedevschemadata/pci_82579LM_network_adapter.xml

index 29244a8984580ac8e2045e8d8125ab59562e8750..5095b97d8aec4c7a3f8f3a3650def6db430a391d 100644 (file)
           <dd>Describes a device on the host's PCI bus.  Sub-elements
             include:
             <dl>
+              <dt><code>class</code></dt>
+              <dd>Combined class, subclass and
+                programming interface codes as 6-digit hexadecimal number.
+                <span class="since">Since 5.2.0</span></dd>
               <dt><code>domain</code></dt>
               <dd>Which domain the device belongs to.</dd>
               <dt><code>bus</code></dt>
     &lt;name&gt;igb&lt;/name&gt;
   &lt;/driver&gt;
   &lt;capability type='pci'&gt;
+    &lt;class&gt;0x020000&lt;/class&gt;
     &lt;domain&gt;0&lt;/domain&gt;
     &lt;bus&gt;2&lt;/bus&gt;
     &lt;slot&gt;0&lt;/slot&gt;
index 0498489cfd8d5c5b0e82703d8811f7b2eee708f7..0f45d7993eaa2cad7a3375a5170d81c73a2d11c7 100644 (file)
       <value>pci</value>
     </attribute>
 
+    <element name='class'>
+      <data type="string">
+        <param name="pattern">0x[0-9a-fA-F]{6}</param>
+      </data>
+    </element>
     <element name='domain'>
       <ref name='unsignedLong'/>
     </element>
index 5de51d1f6b4b64edd03216f526892343f73354e7..19c601ae11c55fd2b16411a725ca4e29e2785edd 100644 (file)
@@ -208,6 +208,7 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf,
 {
     size_t i;
 
+    virBufferAsprintf(buf, "<class>0x%.6x</class>\n", data->pci_dev.klass);
     virBufferAsprintf(buf, "<domain>%d</domain>\n",
                       data->pci_dev.domain);
     virBufferAsprintf(buf, "<bus>%d</bus>\n", data->pci_dev.bus);
@@ -1644,6 +1645,18 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt,
     orignode = ctxt->node;
     ctxt->node = node;
 
+    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'"),
index 5150fd1e8b613e82203a626d0160d2f9ef71008e..387fce70518169282a212262c2c5abeef713672c 100644 (file)
@@ -2,6 +2,7 @@
   <name>pci_0000_00_02_0</name>
   <parent>computer</parent>
   <capability type='pci'>
+    <class>0xffffff</class>
     <domain>0</domain>
     <bus>0</bus>
     <slot>2</slot>
index c1be9f7d9cc0088f60a0451b3e22ebffb2dbfd86..b07d14faa59a3650785e41c3901400728454e139 100644 (file)
@@ -2,6 +2,7 @@
   <name>pci_0000_00_1c_0</name>
   <parent>computer</parent>
   <capability type='pci'>
+    <class>0xffffff</class>
     <domain>0</domain>
     <bus>0</bus>
     <slot>28</slot>
index a2d57569af91009e780ca44aa7c61b5a616b2a6f..8e71e3f89782eeea294158dbbc2136b3543c07d2 100644 (file)
@@ -2,6 +2,7 @@
   <name>pci_0000_02_10_7</name>
   <parent>pci_0000_00_04_0</parent>
   <capability type='pci'>
+    <class>0xffffff</class>
     <domain>0</domain>
     <bus>2</bus>
     <slot>16</slot>
index 8f243b4d6119e349b87b1363112dff33057b268b..6fa2b406a55b7f8e653ce1782edec561046ef5c2 100644 (file)
@@ -2,6 +2,7 @@
   <name>pci_0000_02_10_7</name>
   <parent>pci_0000_00_04_0</parent>
   <capability type='pci'>
+    <class>0xffffff</class>
     <domain>0</domain>
     <bus>2</bus>
     <slot>16</slot>
index 9e8dace020a199e2ed2d88ef107274235473cd7c..74036a65fa85938fe8dc85bfa3662edff3365805 100644 (file)
@@ -2,6 +2,7 @@
   <name>pci_0000_02_10_7</name>
   <parent>pci_0000_00_04_0</parent>
   <capability type='pci'>
+    <class>0xffffff</class>
     <domain>0</domain>
     <bus>2</bus>
     <slot>16</slot>
index 4e6323a3ecdd04e188ab982411a0f382180fc4e8..c30c0d0d2bd70bf6927d2691e255a254465b94a5 100644 (file)
@@ -2,6 +2,7 @@
   <name>pci_0000_02_10_7</name>
   <parent>pci_0000_00_04_0</parent>
   <capability type='pci'>
+    <class>0xffffff</class>
     <domain>0</domain>
     <bus>2</bus>
     <slot>16</slot>
index 355eaaad97d4185d1a4e5991b4e39fe876ab9ba9..096055e2ae8553c0e738ae8141c55920cf242a62 100644 (file)
@@ -2,6 +2,7 @@
   <name>pci_0000_02_10_7</name>
   <parent>pci_0000_00_04_0</parent>
   <capability type='pci'>
+    <class>0xffffff</class>
     <domain>0</domain>
     <bus>2</bus>
     <slot>16</slot>
index e9eb122bfec941536234e3f834d682267fdf75d8..8259cd059b8c91633fa48ffd86470b3754b20161 100644 (file)
@@ -2,6 +2,7 @@
   <name>pci_0000_02_10_7</name>
   <parent>pci_0000_00_04_0</parent>
   <capability type='pci'>
+    <class>0xffffff</class>
     <domain>0</domain>
     <bus>2</bus>
     <slot>16</slot>
index 6d5d85bc3cbb16b6ae8d70abe8c0feb4a39e02ef..2039e2201fa240a885be8016e903d787b88cb269 100644 (file)
@@ -2,6 +2,7 @@
   <name>pci_1002_71c4</name>
   <parent>pci_8086_27a1</parent>
   <capability type='pci'>
+    <class>0xffffff</class>
     <domain>0</domain>
     <bus>1</bus>
     <slot>0</slot>
index 8e8990073d0346d3f579921a12dd9667184e327e..3ffe53b8c9731c7de4c22c4d75e2145ceb770a43 100644 (file)
@@ -2,6 +2,7 @@
   <name>pci_0000_00_03_0</name>
   <parent>computer</parent>
   <capability type='pci'>
+    <class>0xffffff</class>
     <domain>0</domain>
     <bus>0</bus>
     <slot>3</slot>
index 6e1dc868a6501a1a49df9609dda4111e10a0c99a..6bd1292095442ffcbf5f12f95194debca63c307a 100644 (file)
@@ -2,6 +2,7 @@
   <name>pci_0000_02_00_0</name>
   <parent>pci_0000_00_04_0</parent>
   <capability type='pci'>
+    <class>0xffffff</class>
     <domain>0</domain>
     <bus>2</bus>
     <slot>0</slot>
index 18172e900bfdfc84c648278b46fe9b563f3c1dd3..59f5ec86221f933536558efd641f882e2cb7dd03 100644 (file)
@@ -2,6 +2,7 @@
   <name>pci_0000_03_00_0</name>
   <parent>pci_0000_00_1c_1</parent>
   <capability type='pci'>
+    <class>0xffffff</class>
     <domain>0</domain>
     <bus>3</bus>
     <slot>0</slot>
index 6e154d6de34c0a25c55d9999800fc7cc7fcb22b9..96a4c517621bfba0e8cb6c511ef033746a5a5465 100644 (file)
@@ -5,6 +5,7 @@
     <name>e1000e</name>
   </driver>
   <capability type='pci'>
+    <class>0xffffff</class>
     <domain>0</domain>
     <bus>0</bus>
     <slot>25</slot>