LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Blogs > kingbeowulf
User Name
Password

Notices


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
/etc/udev/rules.d/97-iphone.rules
Code:
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
Code:
udevadm control -R
to relaoad the new udev rules. Next run qemu. My qemu Win10 invocation is:
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
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
Code:
(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:
Code:
(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:
Code:
(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:
Code:
-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.
Code:
(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
Code:
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.

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
Posted in Uncategorized
Views 516 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 03:04 PM.

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