title: How do I get Qemu USB Passthrough to work for iPad / iPhone?
body: <p>I'm trying to setup a Mac OS virtual machine to do iPad development. The host system is Ubuntu 18.04, and I'm using the stock qemu packages from the Ubuntu repo.</p>
  
  <p>I've got a Mojave VM up and running using <a href="https://github.com/kholia/OSX-KVM" rel="noreferrer">these instructions</a>, and in the script to boot the VM, I've added this line:</p>
  
  <pre><code>  -device usb-host,vendorid=0x05ac,productid=0x12ab \
  </code></pre>
  
  <p>The devices in question are an iPad Air 2, and an iPad Mini 4, which seem to share the same product ids, according to lsusb.</p>
  
  <p>Here's the issue: when I boot into my Mojave VM, when I plug the iPad in, I see it appear in <code>ioreg -p IOUSB</code> for a few seconds, then it disappears. Other devices (I tried a USB LTE modem and a USB RS232 interface) don't do this; it appears to be specific to iDevices.</p>
  
  <p>On the host side, I see the device appear to connect and disconnect in a loop. Here's what I see in <code>dmesg -w</code>:</p>
  
  <pre><code>[  483.734771] usb 1-2.4.1: new high-speed USB device number 39 using xhci_hcd
  [  483.849408] usb 1-2.4.1: New USB device found, idVendor=05ac, idProduct=12ab
  [  483.849416] usb 1-2.4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
  [  483.849420] usb 1-2.4.1: Product: iPad
  [  483.849425] usb 1-2.4.1: Manufacturer: Apple Inc.
  [  483.849435] usb 1-2.4.1: SerialNumber: &lt;xxx&gt;
  [  484.543671] usb 2-2.1.4.1.3.3: reset SuperSpeed USB device number 9 using xhci_hcd
  [  488.616849] usb 1-2.4.1: reset high-speed USB device number 39 using xhci_hcd
  [  488.732805] usb 1-2.4.1: device firmware changed
  [  488.733301] usb 1-2.4.1: USB disconnect, device number 39
  [  488.824694] usb 1-2.4.1: new high-speed USB device number 40 using xhci_hcd
  [  488.938611] usb 1-2.4.1: New USB device found, idVendor=05ac, idProduct=12ab
  [  488.938613] usb 1-2.4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
  [  488.938614] usb 1-2.4.1: Product: iPad
  [  488.938615] usb 1-2.4.1: Manufacturer: Apple Inc.
  [  488.938616] usb 1-2.4.1: SerialNumber: &lt;xxx&gt;
  [  490.961709] usb 1-2.4.1: reset high-speed USB device number 40 using xhci_hcd
  [  491.076908] usb 1-2.4.1: usbfs: process 2557 (gvfs-gphoto2-vo) did not claim interface 0 before use
  [  494.579362] usb 2-2.1.4.1.3.3: reset SuperSpeed USB device number 9 using xhci_hcd
  [  531.110536] usb 1-2.4.1: USB disconnect, device number 40
  [  533.905116] usb 1-2.4.1: new high-speed USB device number 41 using xhci_hcd
  [  534.019231] usb 1-2.4.1: New USB device found, idVendor=05ac, idProduct=12ab
  [  534.019237] usb 1-2.4.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
  [  534.019241] usb 1-2.4.1: Product: iPad
  [  534.019244] usb 1-2.4.1: Manufacturer: Apple Inc.
  [  534.019247] usb 1-2.4.1: SerialNumber: &lt;xxx&gt;
  [  534.602098] usb 1-2.1.4.4: USB disconnect, device number 17
  </code></pre>
  
  <p>Note that the above is not me physically connecting and diconnecting -- something is doing it on its own. Also of note, I don't get this connect / disconnect loop if my VM isn't running (or if I remove the line setting up the USB passthrough)</p>
  
  <p><strong>Things I've tried</strong></p>
  
  <p>I've been operating on the assumption that this is something that the host (probably udevd) is doing which is preventing qemu (well, libusb, I presume) from being able to keep hold of the device. To that end I've been going through and disabling any udev rules that look like they might be implicated. Specifically, I've created symlinks to <code>/dev/null</code> for the following udev files:</p>
  
  <ul>
  <li>/etc/udev/rules.d/39-usbmuxd.rules</li>
  <li>/etc/udev/rules.d/60-libgphoto2-6.rules</li>
  <li>/etc/udev/rules.d/90-libgpod.rules</li>
  </ul>
  
  <p>I also tried disabling the gphoto2 service, like so:</p>
  
  <pre><code>systemctl --user stop gvfs-gphoto2-volume-monitor.service
  </code></pre>
  
  <p>Despite all of these things, the behavior is essentially the same. Also noteworthy: even after disabling all these things, the kernel is still somehow detecting the iPad when I connect it, and logs its serial number, etc to syslog, and I've reached the limit of my knowledge on how to disable things on Linux!</p>
  
  <p>How can I get my iPad to appear (and stay) in my qemu virtual machine?</p>