Re: [PATCH libvirt v1 4/6] qemu: move ZPCI uid validation into device validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andrea,

Thank you for the review.

On 6/3/20 2:15 PM, Andrea Bolognani wrote:
On Thu, 2020-04-09 at 12:31 +0200, Shalini Chellathurai Saroja wrote:
+static bool
+qemuDomainDeviceDefValidateZPCIUid(virZPCIDeviceAddressPtr zpci)
+{
+    if (zpci->uid_set &&
+        (zpci->uid > VIR_DOMAIN_DEVICE_ZPCI_MAX_UID ||
+         zpci->uid == 0)) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("Invalid PCI address uid='0x%.4x', "
+                         "must be > 0x0000 and <= 0x%.4x"),
+                       zpci->uid,
+                       VIR_DOMAIN_DEVICE_ZPCI_MAX_UID);
+        return false;
+    }
+
+    return true;
+}
+
+
  static int
  qemuValidateDomainDeviceDefZPCIAddress(virDomainDeviceInfoPtr info,
                                         virQEMUCapsPtr qemuCaps)
@@ -960,6 +978,12 @@ qemuValidateDomainDeviceDefZPCIAddress(virDomainDeviceInfoPtr info,
          return -1;
      }
+ /* We don't need to check fid because fid covers
+     * all range of uint32 type.
+     */
+    if (!qemuDomainDeviceDefValidateZPCIUid(&info->addr.pci.zpci))
+        return -1;
No need to create a separate function, just perform the check inline
here.
ok, I will do it.





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux