Qemu USB passthrough with specifics for iphone
Posted 09-05-2018 at 01:39 PM by kingbeowulf
Tags iphone, pasthrough, qemu, usb, windows
Qemu still befuddles me at times. It doesn't help when various command line options are deprecated and changes. For qemu-3.xx, there have been some changes to setting up USB passthrough. This all all came to a head when I needed to restore an iphone. The powermac G5 is dismantled at the moment, so I thought, why not use the Windows 10 VM? After letting Win10 grind along updating itself (I don't fire it up very often), I installed itunes (win10 has an "app store"? ugh.), the fun began.
Since qemu runs as a regular user, it cannot connect to hot-plug USB devices unless you change permssions on the host. Being in group plugdev might be sufficient for standard USD block devices. For others, such as an iphone, you need to manually change the /dev/bus/usb/xxx/yyy to group users or create
/etc/udev/rules.d/97-iphone.rules
0x05ac vendor ID in this case is for an Apple iPhone 5C. For iphones specifically, it can help to disable usbmuxd with an empty /etc/udev/rules.d/39-usbmuxd.rules
Now, either reboot (ha! this ain't windows!) or run as root
to relaoad the new udev rules. Next run qemu. My qemu Win10 invocation is:
You need to specify an ehci USB hub otherwise the iphone won't connect (speed mismatch). Note the new "-device" options for all devices. The older option versions are deprecated. Also, you will need to install the windows virtio guest drivers to use virtio-net-pci. I download the iso and replace /dev/dvd to install. Using the gtk display is nice since you get a nice menu to access the qemu console. Now, plug in the iphone into the host, open the qemu console
should show the iphone entry. If not, check lsusb on the host and find out why. Next, connect the iphone to the guest:
productid=0x12a8 is for an iphone 5c, substitute as needed. If you have just the one device, you can also just:
. Note that with the second verion, the iphone can reboot/reset and still automatically attach to the windows guest. The command line version is:
The optional "id=xxxx" is important to use the command to detach the usb device.
To restore/reset the iphone via recover mode, be aware that the product ID is diferent in recovery mode. For the iphone 5c
If you leave off the product ID, qemu will reattach each time the iphone reboots.
1. https://qemu.weilnetz.de/doc/qemu-doc.html
2. https://github.com/qemu/qemu/blob/master/docs/usb2.txt
3. https://docs.fedoraproject.org/en-US...ers/index.html
Since qemu runs as a regular user, it cannot connect to hot-plug USB devices unless you change permssions on the host. Being in group plugdev might be sufficient for standard USD block devices. For others, such as an iphone, you need to manually change the /dev/bus/usb/xxx/yyy to group users or create
/etc/udev/rules.d/97-iphone.rules
Code:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="*",GROUP="users", MODE="0660"
Now, either reboot (ha! this ain't windows!) or run as root
Code:
udevadm control -R
Code:
#!/bin/sh # MS Windows 10 VM export QEMU_AUDIO_DRV=pa BASE="windows10.img" CPUS="-cpu host -smp 4" RAM="8G" qemu-system-x86_64 -enable-kvm -machine accel=kvm -m $RAM -hda $BASE -cdrom /dev/dvd -boot order=cd $CPUS \ -name "Windows10" -soundhw hda -device usb-ehci,id=ehci -usb -device usb-tablet -vga std -display gtk \ -netdev user,id=mynet1,hostname=win10vm,smb=/games/win32/ -device virtio-net-pci,netdev=mynet1,mac=52:54:00:35:a6:50
Code:
(qemu) info usbhost
Code:
(qemu) device_add usb-host,bus=ehci.0,port=1,vendorid=0x05ac,productid=0x12a8,id=iphone
Code:
(qemu) device_add usb-host,bus=ehci.0,port=1,vendorid=0x05ac,id=iphone
Code:
-device usb-host,bus=ehci.0,port=1,vendorid=0x05ac,id=iphone
Code:
(qemu) device_del iphone
Code:
05ac:1281 Apple, Inc. Apple Mobile Device [Recovery Mode] 05ac:12a8 Apple iPhone 5C
1. https://qemu.weilnetz.de/doc/qemu-doc.html
2. https://github.com/qemu/qemu/blob/master/docs/usb2.txt
3. https://docs.fedoraproject.org/en-US...ers/index.html
Total Comments 0