mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
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: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
0eca80e606
commit
3bd4ed4630
@ -70,6 +70,10 @@
|
||||
<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>
|
||||
@ -381,6 +385,7 @@
|
||||
<name>igb</name>
|
||||
</driver>
|
||||
<capability type='pci'>
|
||||
<class>0x020000</class>
|
||||
<domain>0</domain>
|
||||
<bus>2</bus>
|
||||
<slot>0</slot>
|
||||
|
@ -133,6 +133,11 @@
|
||||
<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>
|
||||
|
@ -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'"),
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -5,6 +5,7 @@
|
||||
<name>e1000e</name>
|
||||
</driver>
|
||||
<capability type='pci'>
|
||||
<class>0xffffff</class>
|
||||
<domain>0</domain>
|
||||
<bus>0</bus>
|
||||
<slot>25</slot>
|
||||
|
Loading…
Reference in New Issue
Block a user