]> xenbits.xensource.com Git - libvirt.git/commit
util: after hostdev assignment, restore VF MAC address via setting admin MAC
authorLaine Stump <laine@laine.org>
Mon, 6 Mar 2017 14:36:40 +0000 (09:36 -0500)
committerLaine Stump <laine@laine.org>
Mon, 27 Mar 2017 14:19:34 +0000 (10:19 -0400)
commitd6ef331f112ab51af7d14c59cd0b460c2e9609a8
tree01aedf4260e07afb69b07645fcd66432cc3f9c4b
parentcceada574e7b057c82927f7939c7491488e67463
util: after hostdev assignment, restore VF MAC address via setting admin MAC

It takes longer to explain this than to fix it...

In the past we weren't able to save the VF's own MAC address *at all*
when using it for hostdev assignment, because we had already unbound
the VF from the host net driver prior to saving its config. With the
previous patch, that problem has been solved, so we now have the VF's
MAC address saved and can move on to the *next* problem, which is twofold:

1) during teardown we restore the config before we've re-bound, so the
   VF doesn't have a net driver, and thus we can't set its MAC address
   directly.

2) even if we delay restoring the config until the VF is bound to a
   net driver, the request to set its MAC address would fail, since
   (during device setup) we had set the "admin MAC" for the VF via an
   RTM_SETLINK to the PF - once you've set the admin MAC for a VF, the
   VF driver (either on host or on guest) is not allowed to change the
   VF's MAC address "forever" (well, until you reload the PF driver,
   but that requires destroying and recreating every single VF, which
   isn't something you can require).

The solution is to keep the restoration of config at the same place,
but to set the *admin MAC* to the address you want the VF to have -
when the VF net driver is later initialized (as a part of re-binding
to the VF net driver) its MAC will be initialized to the current value
of the admin MAC.
src/util/virhostdev.c