ra2 studio - Fotolia
One of the really great new features in Windows Server 2016 Hyper-V is the Discrete Device Assignment feature....
This feature could best be described as hardware pass through. It allows a VM to obtain exclusive use of a physical hardware component.
In some ways, Hyper-V has featured hardware pass through capabilities for quite some time. It has long been possible, for example, to configure a VM to use a physical DVD drive or a physical hard disk through the SCSI Pass Through feature. The Discrete Device Assignment feature is different, however. It allows for the pass through of, among other things, a physical graphics processing unit (GPU).
In all fairness, there was a roundabout way of doing GPU pass through in Windows Server 2012 R2 Hyper-V. The problem with that, however, was that it was based on the use of the Remote Desktop Services (RDS), and therefore required a licensing server and the necessary RDS licenses. The Windows Server 2016 Pass Through feature will allow for native GPU pass through, and can also unofficially be used to perform pass through for other types of hardware devices.
Requirements and process
The new hardware pass through capabilities require Intel Virtualization Technology for Directed I/O or Advanced Micro Devices (AMD) Virtualization. The new capabilities are exposed to the operating system by a new PowerShell module called PnpDevice. You can see some of the configuration data that is exposed through this module by typing Get-PnpDevice on the host server as shown in Figure A.
This server is equipped with two different graphics adapters. There is an AMD Radeon and a Microsoft Basic Display Adapter. Since the Radeon adapter is a higher-end graphics adapter than the generic Basic Display Adapter, let's associate it with a VM. In order to do so, you will need the device's instance ID, and you will need the name of the VM with which you wish to associate the device. Keep in mind that the VM must reside on the same host as the discrete device.
The easiest way to get the device's instance ID is by using the Get-PnpDevice cmdlet where Class is equal to Display. Doing so, however, truncates the instance ID.
A better approach is to associate this command with a variable. By doing so, we can reference the variable name and append the Select-Object cmdlet as a way of retrieving the full instance ID. You can see how this works in Figure B.
The next step in the process is to disable the video adapter to prevent the host OS from using it. We could do this from the Device Manager, but using PowerShell is also an option. Since my A$ variable only contains a single device, I can disable the device by using this command:
Disable-PnpDevice -InstanceID $A.InstanceID
Now, we need to dismount the video adapter from the host. Use the following commands to do so:
$LocationPath = (Get-PnpDeviceProperty -KeyName DEVPKEY_Device_LocationPaths -InstanceId $A.InstanceID).Data
Dismount-VMHostAssignableDevice -LocationPath $LocationPath -Force -Verbose
It's important to note that this process will only work if your server's Unified Extensible Firmware Interface is configured to allow the OS to control the PCI Express Bus. Otherwise, you will receive an error.
The device is now ready to associate with a VM. According to TechNet, the VM must be configured with an Automatic Stop Action of Turn off the VM. Furthermore, the VM must be configured so that its dynamic memory uses the same values for minimum memory and startup memory.
You can now associate the device with the VM by using this command:
Add-VMAssignableDevice -VM <virtual machine name> -LocationPath $LocationPath -Verbose
After you associate a hardware device with a VM, you will need to provide the VM with a driver that it can use to interact with the device. Otherwise, the VM may fail to recognize it as a discrete device.
Explore other Windows Server 2016 Hyper-V features
Protect data in Hyper-V VMs with Host Guardian
Test your knowledge of Hyper-V Server 2016 security features