>-----Original Message----- >From: Cédric Le Goater <c...@redhat.com> >Sent: Saturday, October 28, 2023 12:07 AM >Subject: Re: [PATCH v3 18/37] vfio/container: Implement attach/detach_device > >Sorry, previous email was empty. Friday effect ! > >On 10/26/23 12:30, Zhenzhong Duan wrote: >> From: Eric Auger <eric.au...@redhat.com> >> >> No fucntional change intended. >> >> Signed-off-by: Eric Auger <eric.au...@redhat.com> >> Signed-off-by: Yi Liu <yi.l....@intel.com> >> Signed-off-by: Yi Sun <yi.y....@linux.intel.com> >> Signed-off-by: Zhenzhong Duan <zhenzhong.d...@intel.com> >> Signed-off-by: Cédric Le Goater <c...@redhat.com> >> --- >> hw/vfio/common.c | 16 ++++++++++++++++ >> hw/vfio/container.c | 12 +++++------- >> 2 files changed, 21 insertions(+), 7 deletions(-) >> >> diff --git a/hw/vfio/common.c b/hw/vfio/common.c >> index d62c815d7f..64565b4ae9 100644 >> --- a/hw/vfio/common.c >> +++ b/hw/vfio/common.c >> @@ -1500,3 +1500,19 @@ retry: >> >> return info; >> } >> + >> +int vfio_attach_device(char *name, VFIODevice *vbasedev, >> + AddressSpace *as, Error **errp) >> +{ >> + const VFIOIOMMUOps *ops = &vfio_legacy_ops; > >hmm, this looks wrong. please explain.
The final shape will be: int vfio_attach_device(char *name, VFIODevice *vbasedev, AddressSpace *as, Error **errp) { const VFIOIOMMUOps *ops; #ifdef CONFIG_IOMMUFD if (vbasedev->iommufd) { ops = &vfio_iommufd_ops; } else #endif { ops = &vfio_legacy_ops; } return ops->attach_device(name, vbasedev, as, errp); } Depending on if iommufd is selected, different ops will be chosen. Then corresponding attach_device callback is called to attach to iommufd or legacy container. Thanks Zhenzhong