
On 05/20/2014 05:53 PM, Alex Williamson wrote:
The driver_override field allows us to specify the driver for a device rather than relying on the driver to provide a positive match of the device. This shortcuts the existing process of looking up the vendor and device ID, adding them to the driver new_id, binding the device, then removing the ID, but it also provides a couple advantages.
First, the above existing process allows the driver to bind to any device matching the new_id for the window where it's enabled. This is often not desired, such as the case of trying to bind a single device to a meta driver like pci-stub or vfio-pci. Using driver_override we can do this deterministically using:
echo pci-stub > /sys/bus/pci/devices/0000:03:00.0/driver_override echo 0000:03:00.0 > /sys/bus/pci/devices/0000:03:00.0/driver/unbind echo 0000:03:00.0 > /sys/bus/pci/drivers_probe
I'm not qualified to review the mechanics of the patch, but as a potential consumer of this new interface (in libvirt), I want to say that it is *immensely* improved over the racy, error prone method that the kernel currently has available. The first day that I looked at the libvirt code that uses the "new_id" method to bind drivers to devices, I wished that there would instead be an interface more or less identical to what Alex has described here - simple, deterministic, and with minimal side effect outside of the exact device and driver pair we want to bind.