diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in
index 29244a8984580ac8e2045e8d8125ab59562e8750..5095b97d8aec4c7a3f8f3a3650def6db430a391d 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='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 0498489cfd8d5c5b0e82703d8811f7b2eee708f7..0f45d7993eaa2cad7a3375a5170d81c73a2d11c7 100644
--- a/docs/schemas/nodedev.rng
+++ b/docs/schemas/nodedev.rng
@@ -133,6 +133,11 @@
pci
+
+
+ 0x[0-9a-fA-F]{6}
+
+
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 5de51d1f6b4b64edd03216f526892343f73354e7..19c601ae11c55fd2b16411a725ca4e29e2785edd 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;
+ 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 = 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'"),
diff --git a/tests/nodedevschemadata/pci_0000_00_02_0_header_type.xml b/tests/nodedevschemadata/pci_0000_00_02_0_header_type.xml
index 5150fd1e8b613e82203a626d0160d2f9ef71008e..387fce70518169282a212262c2c5abeef713672c 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/tests/nodedevschemadata/pci_0000_00_1c_0_header_type.xml
index c1be9f7d9cc0088f60a0451b3e22ebffb2dbfd86..b07d14faa59a3650785e41c3901400728454e139 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/tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml
index a2d57569af91009e780ca44aa7c61b5a616b2a6f..8e71e3f89782eeea294158dbbc2136b3543c07d2 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/nodedevschemadata/pci_0000_02_10_7_sriov.xml
index 8f243b4d6119e349b87b1363112dff33057b268b..6fa2b406a55b7f8e653ce1782edec561046ef5c2 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 9e8dace020a199e2ed2d88ef107274235473cd7c..74036a65fa85938fe8dc85bfa3662edff3365805 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_header_type.xml b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all_header_type.xml
index 4e6323a3ecdd04e188ab982411a0f382180fc4e8..c30c0d0d2bd70bf6927d2691e255a254465b94a5 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 355eaaad97d4185d1a4e5991b4e39fe876ab9ba9..096055e2ae8553c0e738ae8141c55920cf242a62 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_count.xml b/tests/nodedevschemadata/pci_0000_02_10_7_sriov_zero_vfs_max_count.xml
index e9eb122bfec941536234e3f834d682267fdf75d8..8259cd059b8c91633fa48ffd86470b3754b20161 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/nodedevschemadata/pci_1002_71c4.xml
index 6d5d85bc3cbb16b6ae8d70abe8c0feb4a39e02ef..2039e2201fa240a885be8016e903d787b88cb269 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/tests/nodedevschemadata/pci_8086_0c0c_snd_hda_intel.xml
index 8e8990073d0346d3f579921a12dd9667184e327e..3ffe53b8c9731c7de4c22c4d75e2145ceb770a43 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/nodedevschemadata/pci_8086_10c9_sriov_pf.xml
index 6e1dc868a6501a1a49df9609dda4111e10a0c99a..6bd1292095442ffcbf5f12f95194debca63c307a 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/tests/nodedevschemadata/pci_8086_4238_pcie_wireless.xml
index 18172e900bfdfc84c648278b46fe9b563f3c1dd3..59f5ec86221f933536558efd641f882e2cb7dd03 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/tests/nodedevschemadata/pci_82579LM_network_adapter.xml
index 6e154d6de34c0a25c55d9999800fc7cc7fcb22b9..96a4c517621bfba0e8cb6c511ef033746a5a5465 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