提交 3bd4ed46 编写于 作者: N Nikolay Shirokovskiy

xml: nodedev: add class info for pci capability

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: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 0eca80e6
...@@ -70,6 +70,10 @@ ...@@ -70,6 +70,10 @@
<dd>Describes a device on the host's PCI bus. Sub-elements <dd>Describes a device on the host's PCI bus. Sub-elements
include: include:
<dl> <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> <dt><code>domain</code></dt>
<dd>Which domain the device belongs to.</dd> <dd>Which domain the device belongs to.</dd>
<dt><code>bus</code></dt> <dt><code>bus</code></dt>
...@@ -381,6 +385,7 @@ ...@@ -381,6 +385,7 @@
&lt;name&gt;igb&lt;/name&gt; &lt;name&gt;igb&lt;/name&gt;
&lt;/driver&gt; &lt;/driver&gt;
&lt;capability type='pci'&gt; &lt;capability type='pci'&gt;
&lt;class&gt;0x020000&lt;/class&gt;
&lt;domain&gt;0&lt;/domain&gt; &lt;domain&gt;0&lt;/domain&gt;
&lt;bus&gt;2&lt;/bus&gt; &lt;bus&gt;2&lt;/bus&gt;
&lt;slot&gt;0&lt;/slot&gt; &lt;slot&gt;0&lt;/slot&gt;
......
...@@ -133,6 +133,11 @@ ...@@ -133,6 +133,11 @@
<value>pci</value> <value>pci</value>
</attribute> </attribute>
<element name='class'>
<data type="string">
<param name="pattern">0x[0-9a-fA-F]{6}</param>
</data>
</element>
<element name='domain'> <element name='domain'>
<ref name='unsignedLong'/> <ref name='unsignedLong'/>
</element> </element>
......
...@@ -208,6 +208,7 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf, ...@@ -208,6 +208,7 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf,
{ {
size_t i; size_t i;
virBufferAsprintf(buf, "<class>0x%.6x</class>\n", data->pci_dev.klass);
virBufferAsprintf(buf, "<domain>%d</domain>\n", virBufferAsprintf(buf, "<domain>%d</domain>\n",
data->pci_dev.domain); data->pci_dev.domain);
virBufferAsprintf(buf, "<bus>%d</bus>\n", data->pci_dev.bus); virBufferAsprintf(buf, "<bus>%d</bus>\n", data->pci_dev.bus);
...@@ -1644,6 +1645,18 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, ...@@ -1644,6 +1645,18 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt,
orignode = ctxt->node; orignode = ctxt->node;
ctxt->node = 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, if (virNodeDevCapsDefParseULong("number(./domain[1])", ctxt,
&pci_dev->domain, def, &pci_dev->domain, def,
_("no PCI domain ID supplied for '%s'"), _("no PCI domain ID supplied for '%s'"),
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<name>pci_0000_00_02_0</name> <name>pci_0000_00_02_0</name>
<parent>computer</parent> <parent>computer</parent>
<capability type='pci'> <capability type='pci'>
<class>0xffffff</class>
<domain>0</domain> <domain>0</domain>
<bus>0</bus> <bus>0</bus>
<slot>2</slot> <slot>2</slot>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<name>pci_0000_00_1c_0</name> <name>pci_0000_00_1c_0</name>
<parent>computer</parent> <parent>computer</parent>
<capability type='pci'> <capability type='pci'>
<class>0xffffff</class>
<domain>0</domain> <domain>0</domain>
<bus>0</bus> <bus>0</bus>
<slot>28</slot> <slot>28</slot>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<name>pci_0000_02_10_7</name> <name>pci_0000_02_10_7</name>
<parent>pci_0000_00_04_0</parent> <parent>pci_0000_00_04_0</parent>
<capability type='pci'> <capability type='pci'>
<class>0xffffff</class>
<domain>0</domain> <domain>0</domain>
<bus>2</bus> <bus>2</bus>
<slot>16</slot> <slot>16</slot>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<name>pci_0000_02_10_7</name> <name>pci_0000_02_10_7</name>
<parent>pci_0000_00_04_0</parent> <parent>pci_0000_00_04_0</parent>
<capability type='pci'> <capability type='pci'>
<class>0xffffff</class>
<domain>0</domain> <domain>0</domain>
<bus>2</bus> <bus>2</bus>
<slot>16</slot> <slot>16</slot>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<name>pci_0000_02_10_7</name> <name>pci_0000_02_10_7</name>
<parent>pci_0000_00_04_0</parent> <parent>pci_0000_00_04_0</parent>
<capability type='pci'> <capability type='pci'>
<class>0xffffff</class>
<domain>0</domain> <domain>0</domain>
<bus>2</bus> <bus>2</bus>
<slot>16</slot> <slot>16</slot>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<name>pci_0000_02_10_7</name> <name>pci_0000_02_10_7</name>
<parent>pci_0000_00_04_0</parent> <parent>pci_0000_00_04_0</parent>
<capability type='pci'> <capability type='pci'>
<class>0xffffff</class>
<domain>0</domain> <domain>0</domain>
<bus>2</bus> <bus>2</bus>
<slot>16</slot> <slot>16</slot>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<name>pci_0000_02_10_7</name> <name>pci_0000_02_10_7</name>
<parent>pci_0000_00_04_0</parent> <parent>pci_0000_00_04_0</parent>
<capability type='pci'> <capability type='pci'>
<class>0xffffff</class>
<domain>0</domain> <domain>0</domain>
<bus>2</bus> <bus>2</bus>
<slot>16</slot> <slot>16</slot>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<name>pci_0000_02_10_7</name> <name>pci_0000_02_10_7</name>
<parent>pci_0000_00_04_0</parent> <parent>pci_0000_00_04_0</parent>
<capability type='pci'> <capability type='pci'>
<class>0xffffff</class>
<domain>0</domain> <domain>0</domain>
<bus>2</bus> <bus>2</bus>
<slot>16</slot> <slot>16</slot>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<name>pci_1002_71c4</name> <name>pci_1002_71c4</name>
<parent>pci_8086_27a1</parent> <parent>pci_8086_27a1</parent>
<capability type='pci'> <capability type='pci'>
<class>0xffffff</class>
<domain>0</domain> <domain>0</domain>
<bus>1</bus> <bus>1</bus>
<slot>0</slot> <slot>0</slot>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<name>pci_0000_00_03_0</name> <name>pci_0000_00_03_0</name>
<parent>computer</parent> <parent>computer</parent>
<capability type='pci'> <capability type='pci'>
<class>0xffffff</class>
<domain>0</domain> <domain>0</domain>
<bus>0</bus> <bus>0</bus>
<slot>3</slot> <slot>3</slot>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<name>pci_0000_02_00_0</name> <name>pci_0000_02_00_0</name>
<parent>pci_0000_00_04_0</parent> <parent>pci_0000_00_04_0</parent>
<capability type='pci'> <capability type='pci'>
<class>0xffffff</class>
<domain>0</domain> <domain>0</domain>
<bus>2</bus> <bus>2</bus>
<slot>0</slot> <slot>0</slot>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<name>pci_0000_03_00_0</name> <name>pci_0000_03_00_0</name>
<parent>pci_0000_00_1c_1</parent> <parent>pci_0000_00_1c_1</parent>
<capability type='pci'> <capability type='pci'>
<class>0xffffff</class>
<domain>0</domain> <domain>0</domain>
<bus>3</bus> <bus>3</bus>
<slot>0</slot> <slot>0</slot>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<name>e1000e</name> <name>e1000e</name>
</driver> </driver>
<capability type='pci'> <capability type='pci'>
<class>0xffffff</class>
<domain>0</domain> <domain>0</domain>
<bus>0</bus> <bus>0</bus>
<slot>25</slot> <slot>25</slot>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册