]> xenbits.xensource.com Git - libvirt.git/commitdiff
xml: nodedev: make pci capability class element optional
authorNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Thu, 21 Mar 2019 07:12:40 +0000 (10:12 +0300)
committerNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Fri, 22 Mar 2019 09:59:56 +0000 (12:59 +0300)
Commit 3bd4ed46 introduced this element as required which
breaks backcompat for test driver. Let's make the element optional.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
docs/formatnode.html.in
docs/schemas/nodedev.rng
src/conf/node_device_conf.c
src/conf/node_device_conf.h
src/node_device/node_device_udev.c
tests/nodedevschemadata/pci_0000_02_10_7_sriov_pf_vfs_all.xml

index 5095b97d8aec4c7a3f8f3a3650def6db430a391d..c2a8f8fb7ad0f8815fc6da9d9f771d07d7030557 100644 (file)
@@ -71,7 +71,7 @@
             include:
             <dl>
               <dt><code>class</code></dt>
-              <dd>Combined class, subclass and
+              <dd>Optional element for 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>
index 0f45d7993eaa2cad7a3375a5170d81c73a2d11c7..fe6ffa0b5318bbd6b4d6e077f58f6b3af3e7df13 100644 (file)
       <value>pci</value>
     </attribute>
 
-    <element name='class'>
-      <data type="string">
-        <param name="pattern">0x[0-9a-fA-F]{6}</param>
-      </data>
-    </element>
+    <optional>
+      <element name='class'>
+        <data type="string">
+          <param name="pattern">0x[0-9a-fA-F]{6}</param>
+        </data>
+      </element>
+    </optional>
     <element name='domain'>
       <ref name='unsignedLong'/>
     </element>
index 19c601ae11c55fd2b16411a725ca4e29e2785edd..b96d10cab80edabcd1582b002b903f160c72bcc9 100644 (file)
@@ -208,7 +208,8 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf,
 {
     size_t i;
 
-    virBufferAsprintf(buf, "<class>0x%.6x</class>\n", data->pci_dev.klass);
+    if (data->pci_dev.klass >= 0)
+        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);
@@ -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,
index b13bc13b87fbbb0771a2815d9b45e1c374d80f92..e8cb315e305263cc5dd2642ac397313e06619d9d 100644 (file)
@@ -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;
index f0e61e4236b5ee210d0f1ca4b265ac84fc7dc4d3..7dd9804a0e044521e29e74f5f26163853d031de5 100644 (file)
@@ -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 ||
index 74036a65fa85938fe8dc85bfa3662edff3365805..9e8dace020a199e2ed2d88ef107274235473cd7c 100644 (file)
@@ -2,7 +2,6 @@
   <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>