I virtualize Windows on Linux via QEMU-KVM and VFIO. A Bluetooth adapter populates one of the USB ports of the Host. When I start a Windows VM, I have libvirt take over control of the USB device and pass it through to the client.

All fine, device detected. The only issue that I run into, is that I need to re-pair my Bluetooth devices after switching (and after switching back again).

To solve this issue: copy the Bluetooth link key from the paired OS to the other OS. Assuming the device is paired in Windows, and you want to share it with a Linux OS:

  1. On the Windows OS: Open registry editor as admin
  2. Go to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters.
  3. Add the Administrators user to Permissions on the Keys registry key to be able to see the keys (refresh, F5, afterwards).
  4. Go to \{adapter-id}, and note the Data value of the registry key \{device-id}.
  5. On the Linux OS: Convert to uppercase, no-spaces and copy to /var/lib/bluetooth/{adapter-id}/{device-id}/info’s Key entry.
  6. Restart Bluetooth service systemctl restart bluetooth.service

Done! You should be able to connect to the device from both OS’s. Swap the Linux and Windows parts to copy a key from Linux to Windows instead.

For reference:

[LinkKey]
Key=<128-bit-key-here>
Type=4
PINLength=0

snippet of /var/lib/bluetooth/{adapter-id}/{device_id}/info

<domain>
  <!-- ... --> 
  <devices>
    <!-- ... -->
    <hostdev mode='subsystem' type='usb' managed='yes'>                                                                                                                                                            
      <source>                                                                                                                                                                                                     
        <vendor id='0x0a12'/>                                                                                                                                                                                      
        <product id='0x0001'/>                                                                                                                                                                                     
      </source>                                                                                                                                                                                                    
      <address type='usb' bus='0' port='5'/>                                                                                                                                                                       
    </hostdev>                          
  </devices>
</domain>

libvirt XML configuration