On Thu, Mar 19, 2026 at 17:36:48 +0100, Pavel Hrdina via Devel wrote:
> From: Pavel Hrdina <[email protected]>
> 
> Future patches will need to check if the host device uses IOMMUFD or not
> but we also need to keep a function that will check only if it is PCI device.
> 
> Signed-off-by: Pavel Hrdina <[email protected]>
> ---
>  src/conf/domain_conf.c | 34 +++++++++++++++++++++++++++++-----
>  1 file changed, 29 insertions(+), 5 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index b1a73afef2..01e2bd631a 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -33026,6 +33026,33 @@ virHostdevIsMdevDevice(const virDomainHostdevDef 
> *hostdev)
>  }
>  
>  
> +static bool
> +virHostdevPCIDevHasIOMMUFD(const virDomainHostdevDef *hostdev)
> +{
> +    return hostdev->source.subsys.u.pci.driver.name == 
> VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_VFIO &&
> +        hostdev->source.subsys.u.pci.driver.iommufd == VIR_TRISTATE_BOOL_YES;
> +}
> +
> +
> +static bool
> +virHostdevIsPCIDeviceImpl(const virDomainHostdevDef *hostdev,
> +                          virTristateBool iommufd)
> +{
> +    if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
> +        return false;
> +
> +    if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
> +        return false;
> +
> +    if (iommufd != VIR_TRISTATE_BOOL_ABSENT) {
> +        bool hasIOMMUFD = iommufd == VIR_TRISTATE_BOOL_YES;
> +        return hasIOMMUFD == virHostdevPCIDevHasIOMMUFD(hostdev);

I guess using 'virTristateBoolToBool' wouldn't make this any better.

> +    }
> +
> +    return true;
> +}
> +
> +
>  /**
>   * virHostdevIsPCIDevice:
>   * @hostdev: host device to check

Reviewed-by: Peter Krempa <[email protected]>

Reply via email to