HTC Vive + QEMU/KVM GPU Passthrough (VFIO): List of USB IDs + Passing bus.dev into QEMU

#!/bin/bash
...
vive_ids=`python3 - <<END

from subprocess import check_output
ids = {'0bb4:0306', '28de:2101', '0bb4:2c87', '28de:2000'}
special_id = '0bb4:2c87'
special_added = False

if __name__ == '__main__':
  busdevs = []
  usbs = check_output('lsusb').decode().strip().split('\n')
  for usb in usbs:
    usb = usb.split()
    usb_id = usb[5]
    if usb_id not in ids:
      continue
    if usb_id == special_id:
      if special_added:
        continue
      special_added = True
    busdevs.append((int(usb[1]), int(usb[3].replace(':', ''))))
  buf = ''
  for bd in busdevs:
    buf += '-usbdevice host:{}.{} '.format(bd[0], bd[1])
  print(buf)

END`

qemu-system-x86_64 \
  ...
  ${vive_ids} \
  ...

The solution works fine. The tracking/performance is just perfect, except that unfortunately it fails if both 0bb4:2c87 is added, the VM will crash, which means the integreated camera can't be used...

The only solution for that is passing through a whole PCI USB controller...

Recommendations

Last modified: 2018-05-06 07:21:10
Powered by Simple Blog