Pass-through wired or wireless (Wi-Fi) NIC to VM using Hyper-V Discrete Device Assignment (DDA) in Windows Server 2016

Hyper-V Discrete Device Assignment (DDA) was developed for attaching (passing through) video adapters into virtual machines. This feature exists on other hypervisors (for example VMDirectPath I/O passthrough on VMware ESXi) for a long time and it is used to virtualize applications that can leverage GPU hardware. Such applications are used for example for scientific calculations or for video encoding.

I tested DDA on network adapters. On Windows Server Technology Preview 5 I attached three network adapters (two wireless and one wired) into Windows 10 Enterprise Update 1511. As you can see on screenshot all interfaces are functional.

If you want to try the same thing, then you can use my code. Just change VM name and InstanceId that you can find in Device Manager (devmgm.msc) or using cmdlet Get-PnpDevice.

Please read verbose stream to understand what steps you need to make.

(Get-PnpDevice -PresentOnly).Where{ $_.Status -eq 'Error' } | Format-Table -AutoSize
(Get-PnpDevice -PresentOnly).Where{ $_.InstanceId -like '*VEN_8086&DEV_1539*' } | Format-List # Intel(R) l211 Gigabit Network Connection
(Get-PnpDevice -PresentOnly).Where{ $_.InstanceId -like '*VEN_168C&DEV_0030*' } | Format-List # Qualcomm Atheros AR938x Wireless Network Adapter
(Get-PnpDevice -PresentOnly).Where{ $_.InstanceId -like '*VEN_168C&DEV_002B*' } | Format-List # Qualcomm Atheros AR9285 Wireless Network Adapter

$vmName = 'VMDDA0'
$instanceId = '*VEN_168C&DEV_002B*'

$ErrorActionPreference = 'Stop'
$vm = Get-VM -Name $vmName
$dev = (Get-PnpDevice -PresentOnly).Where{ $_.InstanceId -like $instanceId }
if (@($dev).Count -eq 1) {
    Write-Verbose -Message ('Disable device (same as in devmgmt.msc): {0}' -f $dev.InstanceId) -Verbose
    Disable-PnpDevice -InstanceId $dev.InstanceId -Confirm:$false

    $locationPath = (Get-PnpDeviceProperty -KeyName DEVPKEY_Device_LocationPaths -InstanceId $dev.InstanceId).Data[0]
    Write-Verbose -Message ('Dismount assignable device using path: {0}' -f $locationPath) -Verbose
    Dismount-VmHostAssignableDevice -LocationPath $locationPath -Force -Verbose

    Write-Verbose -Message 'It is dismounted now - proof:' -Verbose
    (Get-PnpDevice -PresentOnly).Where{ $_.InstanceId -like $instanceId }

    Write-Verbose -Message 'See that our dismounted adapter has become available to be assigned via DDA:' -Verbose
    (Get-VMHostAssignableDevice).Where{ $_.LocationPath -eq $locationPath }

    Write-Verbose -Message 'Set VM required configuration' -Verbose
    Set-VM -VM $vm -StaticMemory -MemoryStartupBytes 4096MB -AutomaticStopAction TurnOff

    Write-Verbose -Message 'Set VM required configuration; Depending on your hardware, you might get error with:'
    Set-VM -VM $vm -GuestControlledCacheTypes $true -LowMemoryMappedIoSpace 2048MB -HighMemoryMappedIoSpace 4096MB -Verbose

    Write-Verbose -Message 'Assign'
    Add-VMAssignableDevice -VM $vm -LocationPath $locationPath -Verbose
} else {
    $dev | Sort-Object -Property Class | Format-Table -AutoSize
    Write-Error -Message ('Number of devices: {0}' -f @($dev).Count)

Leave a Reply

Your email address will not be published.