Help answer threads with 0 replies.
Go Back > Blogs > kingbeowulf
User Name


Rate this Entry

Qemu USB passthrough with specifics for iphone

Posted 09-05-2018 at 02:39 PM by kingbeowulf

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
SUBSYSTEMS=="usb", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="*",GROUP="users", MODE="0660"
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
udevadm control -R
to relaoad the new udev rules. Next run qemu. My qemu Win10 invocation is:
# MS Windows 10 VM
export QEMU_AUDIO_DRV=pa
CPUS="-cpu host -smp 4"
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
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
(qemu) info usbhost
should show the iphone entry. If not, check lsusb on the host and find out why. Next, connect the iphone to the guest:
(qemu) device_add usb-host,bus=ehci.0,port=1,vendorid=0x05ac,productid=0x12a8,id=iphone
productid=0x12a8 is for an iphone 5c, substitute as needed. If you have just the one device, you can also just:
(qemu) device_add usb-host,bus=ehci.0,port=1,vendorid=0x05ac,id=iphone
. Note that with the second verion, the iphone can reboot/reset and still automatically attach to the windows guest. The command line version is:
-device usb-host,bus=ehci.0,port=1,vendorid=0x05ac,id=iphone
The optional "id=xxxx" is important to use the command to detach the usb device.
(qemu) device_del iphone
To restore/reset the iphone via recover mode, be aware that the product ID is diferent in recovery mode. For the iphone 5c
05ac:1281 Apple, Inc. Apple Mobile Device [Recovery Mode]
05ac:12a8 Apple iPhone 5C
If you leave off the product ID, qemu will reattach each time the iphone reboots.

Posted in Uncategorized
Views 7346 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 08:41 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration