Single Root I/O Virtualization (SR-IOV)

Single Root I/O Virtualization (SR-IOV) is a feature in Windows Server Hyper-V that allows a physical network adapter to be shared among virtual machines (VMs) with the help of the Physical Function (PF) and the Virtual Function (VF).

The PF represents the physical network adapter that is connected to the physical switch, and the VF is a lightweight virtual network adapter that is assigned to a VM.

SR-IOV improves network performance by reducing CPU overhead and improving network throughput by bypassing the virtual switch in Hyper-V.

To enable SR-IOV in Hyper-V, follow these steps:

  1. Verify that the physical network adapter supports SR-IOV by checking the device manager for the “Virtual Function” driver.
  2. Install the Hyper-V role and the Network Controller role service.
  3. In Hyper-V Manager, right-click the VM and select “Settings”.
  4. Select “Add Hardware” and select “Network Adapter”.
  5. Choose “Legacy Network Adapter” and click “Add”.
  6. Select the newly created network adapter and click “Remove”.
  7. Select “Add Hardware” and select “Network Adapter”.
  8. Choose “Network Adapter” and click “Add”.
  9. Select the physical network adapter and click “Next”.
  10. Select “Enable Single Root I/O Virtualization (SR-IOV)” and click “Next”.
  11. Choose the number of virtual functions that you want to create and click “Next”.
  12. Assign the virtual functions to the VM and click “Finish”.

To create a virtual switch that supports SR-IOV using PowerShell, follow these steps:

  1. Open PowerShell with administrative privileges.
  2. Run the command “Install-WindowsFeature Hyper-V”.
  3. Run the command “Install-WindowsFeature NetworkController”.
  4. Run the command “New-VMSwitch -Name <SwitchName> -NetAdapterName <PhysicalNIC> -AllowManagementOS $false -EnableEmbeddedTeaming $false -MinimumBandwidthMode Weight”.
  5. Run the command “Set-VMSwitch <SwitchName> -EnableEmbeddedTeaming $false”.
  6. Run the command “Add-VMNetworkAdapter -VMName <VMName> -Name <AdapterName> -SwitchName <SwitchName> -EnableSRIOV”.
  7. Run the command “Get-VMNetworkAdapter -VMName <VMName> -Name <AdapterName> | Set-VMNetworkAdapter -MacAddressSpoofing On -DeviceNaming On”.

The command in step 4 creates a new virtual switch with the specified name and assigns it to the physical NIC specified in the “NetAdapterName” parameter. The “-AllowManagementOS $false” parameter prevents the management OS from using the switch. The “-EnableEmbeddedTeaming $false” parameter disables NIC teaming on the switch, and the “-MinimumBandwidthMode Weight” parameter sets the bandwidth allocation mode to “Weight”.

The command in step 6 adds a new virtual network adapter to the specified VM and assigns it to the virtual switch with SR-IOV enabled.

The command in step 7 enables MAC address spoofing and device naming on the virtual network adapter.

Author: tonyhughes