title: How to use USB with QEMU on a Mac host?
body: <p>I tried the following to access a USB storage device via an Ubuntu guest running on macOS host:</p>
  <pre><code>sudo qemu-system-x86_64 -m 8G -boot d -smp 4 -net nic -net user \
     -hda Ubuntu/ubuntu.img -machine type=q35,accel=hvf \
     -device intel-hda -device hda-duplex \
     -device nec-usb-xhci -device usb-host,vendorid=0x0781,productid=0x5580
  </code></pre>
  <p>Unfortunately I can not access the USB device from the guest. Guest syslog says:</p>
  <pre><code>... kernel: [...] usb 5-1: USB new high-speed USB device number 3 using xhci_hcd
  ... kernel: [...] usb 5-1: New USB device found, idVendor=0781, idProduct=5580, bcdDevice= 0.10
  ... kernel: [...] usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
  ... kernel: [...] usb 5-1: Product: Extreme
  ... kernel: [...] usb 5-1: Manufacturer: SanDisk
  ... kernel: [...] usb 5-1: SerialNumber: AA010829152XXXXXXX
  ... kernel: [...] usb 5-1: can't set config #1, error -32
  ... mtp-probe: checking bus 5 device 3: &quot;/sys/devices/pci0000:00/0000:00:04.0/usb5/5-1&quot;
  ... mtp-probe: bus: 5, device:3 was not an MTP device
  </code></pre>
  <p>How can I successfully access the USB device?</p>
  <p>USB is required for doing Android development via Android Studio with a physical device.</p>
  <p>I tried two USB-sticks and an Android smartphone in file transfer mode.</p>
  <p>Version information:
  macOS: 10.13.6,
  qemu: 5.1.0,
  Ubuntu: 20.04.</p>