On Mon, Jul 23, 2018 at 12:20:12PM +0300, Michael S. Tsirkin wrote: > On Mon, Jul 23, 2018 at 12:59:56PM +0800, Tiwei Bie wrote: [...] > > > > +static int vhost_user_slave_handle_vfio_group(struct vhost_dev *dev, > > + int *fd) > > +{ > > + struct vhost_user *u = dev->opaque; > > + VhostUserState *user = u->user; > > + VirtIODevice *vdev = dev->vdev; > > + int groupfd = fd[0]; > > + VFIOGroup *group; > > + > > + if (!virtio_has_feature(dev->protocol_features, > > + VHOST_USER_PROTOCOL_F_VFIO_GROUP) || > > + vdev == NULL) { > > + return -1; > > + } > > + > > + if (user->vfio_group) { > > + vfio_put_group(user->vfio_group); > > + user->vfio_group = NULL; > > Seems to create a window where mappings are invalid > even if the same fd is re-sent. Is that OK?
Yeah, there will be a window that mappings are invalid when the same fd is re-sent. Based on the proposal [1] of this patch, it should be OK. [1] http://lists.gnu.org/archive/html/qemu-devel/2018-07/msg04335.html """ To keep things simple, this proposal requires the slave to assume the mappings are invalid before receiving the REPLY from master when the slave sends this message to master, and master will destroy the existing VFIO group if any and do the setup for the (new) VFIO group if the message carries a fd. So if a VFIO group fd has been sent and the device has been started, before sending a VFIO group fd (could be the same fd that has been sent), the slave should stop the device first and shouldn't assume the mappings are valid before receiving the REPLY. """ Best regards, Tiwei Bie > > > + } [...]