On 18.04.2025 20:58, Stewart Hildebrand wrote: > --- a/xen/drivers/vpci/vpci.c > +++ b/xen/drivers/vpci/vpci.c > @@ -174,6 +174,41 @@ int vpci_assign_device(struct pci_dev *pdev) > } > #endif /* __XEN__ */ > > +#ifdef CONFIG_HAS_VPCI_GUEST_SUPPORT > +/* > + * Find the physical device which is mapped to the virtual device > + * and translate virtual SBDF to the physical one. > + */ > +static const struct pci_dev *translate_virtual_device(const struct domain *d, > + pci_sbdf_t *sbdf) > +{ > + const struct pci_dev *pdev; > + > + ASSERT(!is_hardware_domain(d)); > + ASSERT(rw_is_locked(&d->pci_lock)); > + > + for_each_pdev ( d, pdev ) > + { > + if ( pdev->vpci && (pdev->vpci->guest_sbdf.sbdf == sbdf->sbdf) ) > + { > + /* Replace guest SBDF with the physical one. */ > + *sbdf = pdev->sbdf; > + return pdev; > + } > + } > + > + return NULL; > +} > +#else > +static const struct pci_dev *translate_virtual_device(const struct domain *d, > + pci_sbdf_t *sbdf) > +{ > + ASSERT_UNREACHABLE(); > + > + return NULL; > +} > +#endif /* CONFIG_HAS_VPCI_GUEST_SUPPORT */
I'm not a maintainer of this code, but if I was I'd strictly request that the #ifdef move inside the function, to limit redundancy. Even the "return NULL" is common between both forms. Jan