Hi folks, I was trying to understand if we have a way to specify which vDPA bus driver (e.g. vhost-vdpa, virtio-vdpa) a device should use. IIUC we don't have it, and the first registered driver is used when a new device is registered. I was thinking if it makes sense to extend the management API to specify which bus driver to use for a device. A use case could be for example a single host handling VMs and bare-metal containers, so we would have both virtio-vdpa and vhost-vdpa loaded and we want to attach some devices to VMs through vhost-vdpa and others to containers through virtio-vdpa. What do you think? I can prepare an RFC with some code, the idea is to use the .match callback of "struct bus_type" to use a driver instead of the other, and extend netlink API to specify the vDPA bus driver name to use. Thanks, Stefano
Hi Stefano,> From: Stefano Garzarella <sgarzare at redhat.com> > Sent: Wednesday, October 27, 2021 8:04 PM > > Hi folks, > I was trying to understand if we have a way to specify which vDPA bus driver > (e.g. vhost-vdpa, virtio-vdpa) a device should use. > IIUC we don't have it, and the first registered driver is used when a new device > is registered. > > I was thinking if it makes sense to extend the management API to specify which > bus driver to use for a device. A use case could be for example a single host > handling VMs and bare-metal containers, so we would have both virtio-vdpa > and vhost-vdpa loaded and we want to attach some devices to VMs through > vhost-vdpa and others to containers through virtio-vdpa. > > What do you think? >One option is, user keeps the drivers_autoprobe disabled for the vdpa bus using, $ vdpa/vdpa dev add mgmtdev vdpasim_net name vdpa0 mac 00:11:22:33:44:55 $ echo 0 > /sys/bus/vdpa/drivers_autoprobe And after vdpa device creation, it manually binds to the desired driver such as, $ echo vdpa0 > /sys/bus/vdpa/drivers/virtio_vdpa/bind Or $ echo vdpa0 > /sys/bus/vdpa/drivers/vhost_vdpa/bind In an case of VDUSE, it makes more sense to bind to the one of the above driver after user space has connected the use space backend to the kernel device.
On Wed, Oct 27, 2021 at 04:33:50PM +0200, Stefano Garzarella wrote:> Hi folks, > I was trying to understand if we have a way to specify which vDPA bus > driver (e.g. vhost-vdpa, virtio-vdpa) a device should use. > IIUC we don't have it, and the first registered driver is used when a > new device is registered. > > I was thinking if it makes sense to extend the management API to > specify which bus driver to use for a device. A use case could be for > example a single host handling VMs and bare-metal containers, so we > would have both virtio-vdpa and vhost-vdpa loaded and we want to > attach some devices to VMs through vhost-vdpa and others to containers > through virtio-vdpa. > > What do you think? > > I can prepare an RFC with some code, the idea is to use the .match > callback of "struct bus_type" to use a driver instead of the other, > and extend netlink API to specify the vDPA bus driver name to use. > > Thanks, > StefanoSo I think that doing this at create time is somewhat limited. For example a great way to do migration could be to unbind device from VM then bind virtio on the host to it, then bind macvtap to that. Ideas on how to allow that? -- MST