]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: probe stub driver from within function that binds to stub driver
authorLaine Stump <laine@redhat.com>
Sun, 9 Jul 2023 19:00:26 +0000 (15:00 -0400)
committerLaine Stump <laine@redhat.com>
Fri, 25 Aug 2023 03:36:18 +0000 (23:36 -0400)
commit2d9c9445b9cc093c870f101eb884ddeac3ae40f7
tree142f5939832c148d4703d4ff1cba8b67c55d20e6
parent6ce071f6097d9e96892d5a6c7bd3040f43cc925b
util: probe stub driver from within function that binds to stub driver

virPCIProbeStubDriver() and virPCIDeviceBindToStub() both have
very similar code that locally sets a driver name (based on
stubDriverType). These two functions are each also called in just one
place (virPCIDeviceDetach()), with just a small bit of validation code
in between.

To eliminate the "duplicated" code (which is going to be expanded
slightly in upcoming patches to support manually or automatically
picking a VFIO variant driver), this patch modifies
virPCIProbeStubDriver() to take the driver name as an argument
(rather than the virPCIDevice object), and calls it from within
virPCIDeviceBindToStub() (rather than from that function's caller),
using the driverName it has just figured out with the
now-not-duplicated code.

(NB: Since it could be used to probe *any* driver module, the name is
changed to virPCIProbeDriver()).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virpci.c