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) :
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.
Some further “observations”…
This process seems to be somewhat “sensitive” to which USB cards you use. The first one I tried - a “FebSmart 2-Ports Superspeed 5Gbps USB 3.0 PCI Express Expansion Card (FS-U2S-Pro)” worked perfectly… for me. But 2 ports was a bit limiting, so I tried a few other 5 & 7 port cards and got all sorts of flakey results. Typically, the device wouldn’t be recognized after a host reboot, the VM wouldn’t find the hardware it needed & would refuse to boot! In the end, I just got a 2nd 2-port card (same one), and everything is great - I have Z-Wave, Zigbee, Blutooth & 1 spare (that I’ve used to initialize ESPHome devices).
For that “VM won’t boot” issue, I found I could delete & recreate the VM definition, keeping the same hard disk file. Then putting back the functioning USB card, going through the disable/dismount/add process again to assign it to the new VM (sometimes, some of the steps were done already). HA would find the different card, but the same USB devices & carry on happily!
I’ve been trying to get this running on my HA hyper-v VM. I’ve gotten as far as to contact Asrock and they provided me with a BIOS update that seems to have ACS enabled, I have IOMMU, SR-IOV, above 4g decoding, etc enabled.
I’ve run the DDA survey script and it shows 2 of my onboard USB controllers as assignable for DDA, as well as the 2-port add-on card I bought based on your post (it’s not your exact card, but looking at the board layout it’s very very similar).
I’ve also changed some registry keys and group policies based on other people who resolved their issues that way…
Still, once I add the USB controller to the VM and try to run it, I get the same error I used to get back before I got the BIOS update:
Virtual Pci Express Port Failed to Power on with Error ‘A hypervisor feature is not available to the user.’
I’m beginning to think this could be due to me being on Windows 11 Pro and not Windows Server…
Thank you! There is so much mixed responses about this online that I genuinely thought my OS would be fine. People tend to mention the OS requirements for Hyper-V and overlook those for DDA specifically -_-
Well hey go Win svr 25 and get Hotpaching too! … Kidding.
Seriously though I’m an Ex MS Identity and Infrastructure field engineer and I would not use HV for this workload. Too many non-standard hacky configurations that arent guaranteed to keep working. Im currently building my AI rig in Proxmox.
Note you get I to trouble with Windows when you start doing non-standard stuff. The dev team only tests the mainstream and critical use cases in the scripts… This rarely includes things like say passing usb through DDA.
Until the DDA thing the only other option was piping the com port over. At least DDA is a supported feature.