fix: support for sr-iov passthrough virtual machine network adapters #2133
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This change fixes 2 deficiencies in the support for passthrough network adapters on virtual machines.
The support for SR-IOV adapters was added with #2059 which was simply a port of an old change that never made it in #1417
The issues introduced by these changes are:
Both problems have the same root cause. A very long time a go someone made the assumption that virtual network adapters are placed on the virtual PCI bus sequentially on slots 7 onwards. More specifically they made the assumption that passthrough adapters are placed on slots 36-45 descending. The entire implementation hangs on its capability to guess the slot number on which the kernel will place a device. We attempt to set the UnitNumber field on each virtual device (even though this is not respected by the kernel) and compute an address for it that we use internally to find the device in the list of devices post-creation.
This already sounds super-fishy and the original developers of the passthrough support decided that the in-place swapping of adapters when SR-IOV is involved is "too fiddly". Can't blame them.
But there is more! The actual problem is that VMware never guaranteed these PCI slot numbers. All of this is based on assumptions.
Starting from hardware version 20 (vSphere 8 and onwards) the kernel creates VMs with a new motherboard layout called ACPI which changes the bus topology (passthrough adapters go to slot 65 and increment from there for example, but again, this is not guaranteed).
My change effectively eliminates all of the guessing when it comes to network adapters. There is no more special handling for SR-IOV. Adapters are instead identified by their position in the list of network devices. This means that the provider will have the same interface for network adapters as the vSphere client, where they are identified by their position.
No changes are being made to devices other than network adapters.
Acceptance tests
Output from acceptance testing:
Ran all tests for virtual nics and added one new case
Release Note
References
Closes #2092