Hyper-V doesn’t support USB passthrough. But, as of Windows 2016, it does support PCIe device passthrough (using “Discreet Device Assignment” - DDA). So, I tried installing a PCIe expansion card with a couple of USB 3.0 ports, plugged in a Z-Wave stick & passed the card through to a new VM using the standard haos vhdx. It booted right up, found the Z-Wave device & offered to install Z-Wave JS - I let it & it works! Same for a Sonoff ZigBee 3.0 device.
A few pre-requisites:
-
I’m using Windows Server 2022 (DEV machine) - I’m not sure if DDA is supported on Windows 11
-
In the BIOS, I needed to enable SR-IOV (“single-root I/O virtualization”). On mine (ASUS TUF Gaming X570) it was under Advanced | PCI settings
-
In Device Manager, expand “Ports (COM & LPT)” and “Universal Serial Bus controllers” - take a ‘before’ screenshot.
Then: -
In the Hyper-V settings for the HomeAssistant VM, change the ‘Automatic Stop Action’ to ‘Power Off’.
-
Power off, plug in the PCI card, power on & back to Device Manager. Compare with the ‘before’ screenshot, you should have a new COM port a new USB device & a new USB Controller. Right click the new COM port, Properties, Details & Property: Location paths. Value should be something like: PCIROOT(0)#PCI(0102)#PCI(0000)#PCI(0600)#PCI(0000)#USBROOT(0)#USB(3) - take note! Then right click it again & disable. Now find the new USB Device & USB Controller - again check the Location paths for them, looking for mostly matching path info - and disable both of those.
-
Then from an admin powershell (changing the LocationPath & VMname to match yours) :
Dismount-VMHostAssignableDevice -force -LocationPath "PCIROOT(0)#PCI(0102)#PCI(0000)#PCI(0600)#PCI(0000)"
Add-VMAssignableDevice -LocationPath "PCIROOT(0)#PCI(0102)#PCI(0000)#PCI(0600)#PCI(0000)" -VMname HomeAssistant
One thing to look out for, in my case anyway, changing the SR-IOV setting in the BIOS caused all the VMs to lose network connectivity. I had to create a new virtual network switch, check ‘Enable SR-IOV’ and change all the client VMs to use this network.