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

Andrea Bolognani abologna at redhat.com
Wed Jun 3 12:15:20 UTC 2020


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.

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list