On Thu, Jan 28, 2021 at 12:41:15PM -0300, Leonardo Augusto GuimarĂ£es Garcia wrote: > On 1/27/21 8:19 AM, Stefan Hajnoczi wrote: > > On Tue, Jan 26, 2021 at 03:23:38PM -0300, lagar...@linux.ibm.com wrote: > > + > > + if (virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM) && > > + !(fs->vhost_dev.hdev_features & (1ull << VIRTIO_F_IOMMU_PLATFORM))) > > { > > + error_setg(errp, "IOMMU is not supported by the vhost-user device > > backend"); > > + goto err_iommu_needed; > > + } > > > > Also, can this logic be made generic for all vhost-user devices? It's > > not really specific to vhost-user-fs. > > > I am afraid I will need some additional guidance on how to do that. If I am > reading the code correctly, the vhost-user devices don't follow any specific > pattern. Looking at the vhost-user-fs code path, we have: > > vuf_device_realize -> vhost_dev_init -> vhost_user_backend_init > > So, I thought that naturally, if the check was in vuf_device_realize on my > previous patch, I should move it to vhost_user_backend_init. However, in > order to check if the VirtIODevice has been specified with the > VIRTIO_F_IOMMU_PLATFORM option, I would need to have access to the > VirtIODevice inside vhost_user_backend_init, which currently is not > available and not one of the arguments of vhost_backend_init virtual > function it implements. vhost_dev_init doesn't have access to VirIODevices > as well. Looking at other device types that call vhost_dev_init, not all of > them initialized the VirtIODevice by the time vhost_dev_init is called (e.g. > cryptodev-host). Hence, adding a VirtIODevice as parameter to vhost_dev_init > and vhost_backedn_init is not a feasible solution. vhost_dev_init does > receive structu vhost_dev which has a field VirtIODevice vdev. But as the > VirtIODevice hasn't been initialized by the time vhost_dev_init is called on > all vhost-user devices today also makes this not a solution. > > Any ideas on this? Is it correct for a virtio-user devices to call > vhost_dev_init before having VirtIODevice ready?
Maybe Michael Tsirkin has an idea. Otherwise let's go with a vhost-user-fs fix. Stefan
signature.asc
Description: PGP signature