On 30.09.2021 09:52, Oleksandr Andrushchenko wrote: > --- a/xen/drivers/passthrough/pci.c > +++ b/xen/drivers/passthrough/pci.c > @@ -889,6 +889,31 @@ int pci_remove_virtual_device(struct domain *d, const > struct pci_dev *pdev) > xfree(vdev); > return 0; > } > + > +/* > + * Find the physical device which is mapped to the virtual device > + * and translate virtual SBDF to the physical one. > + */ > +bool pci_translate_virtual_device(const struct domain *d, pci_sbdf_t *sbdf) > +{ > + struct vpci_dev *vdev;
const (afaict) > + bool found = false; > + > + pcidevs_lock(); > + list_for_each_entry ( vdev, &d->vdev_list, list ) > + { > + if ( vdev->sbdf.sbdf == sbdf->sbdf ) > + { > + /* Replace virtual SBDF with the physical one. */ > + *sbdf = vdev->pdev->sbdf; > + found = true; > + break; > + } > + } > + pcidevs_unlock(); As per the comments on the earlier patch, locking as well as placement may need reconsidering. Jan