From: Nikolay Shirokovskiy Date: Thu, 21 Mar 2019 07:12:40 +0000 (+0300) Subject: xml: nodedev: make pci capability class element optional X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1193d9737b932621e3d067c2fec881224c593a48;p=libvirt.git xml: nodedev: make pci capability class element optional Commit 3bd4ed46 introduced this element as required which breaks backcompat for test driver. Let's make the element optional. Reviewed-by: Erik Skultety Signed-off-by: Nikolay Shirokovskiy --- diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in index 5095b97d8a..c2a8f8fb7a 100644 --- a/docs/formatnode.html.in +++ b/docs/formatnode.html.in @@ -71,7 +71,7 @@ include:
class
-
Combined class, subclass and +
Optional element for combined class, subclass and programming interface codes as 6-digit hexadecimal number. Since 5.2.0
domain
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 0f45d7993e..fe6ffa0b53 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -133,11 +133,13 @@ pci - - - 0x[0-9a-fA-F]{6} - - + + + + 0x[0-9a-fA-F]{6} + + + diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 19c601ae11..b96d10cab8 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -208,7 +208,8 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf, { size_t i; - virBufferAsprintf(buf, "0x%.6x\n", data->pci_dev.klass); + if (data->pci_dev.klass >= 0) + 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); @@ -1645,16 +1646,16 @@ 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 ((tmp = virXPathString("string(./class[1])", ctxt))) { + if (virStrToLong_i(tmp, NULL, 16, &pci_dev->klass) < 0 || + pci_dev->klass > 0xffffff) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid PCI class supplied for '%s'"), def->name); + goto out; + } + VIR_FREE(tmp); + } else { + pci_dev->klass = -1; } if (virNodeDevCapsDefParseULong("number(./domain[1])", ctxt, diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index b13bc13b87..e8cb315e30 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -153,7 +153,7 @@ struct _virNodeDevCapPCIDev { unsigned int function; unsigned int product; unsigned int vendor; - unsigned int klass; + int klass; char *product_name; char *vendor_name; virPCIDeviceAddressPtr physical_function; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index f0e61e4236..7dd9804a0e 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -402,7 +402,8 @@ udevProcessPCI(struct udev_device *device, privileged = driver->privileged; nodeDeviceUnlock(); - if (udevGetUintProperty(device, "PCI_CLASS", &pci_dev->klass, 16) < 0) + pci_dev->klass = -1; + if (udevGetIntProperty(device, "PCI_CLASS", &pci_dev->klass, 16) < 0) goto cleanup; if ((p = strrchr(def->sysfs_path, '/')) == NULL || 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 74036a65fa..9e8dace020 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,7 +2,6 @@ pci_0000_02_10_7 pci_0000_00_04_0 - 0xffffff 0 2 16