Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: document how to connect an iPhone to a macOS virtual machine #468

Open
nicolasmol opened this issue May 10, 2022 · 8 comments
Open
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed

Comments

@nicolasmol
Copy link

nicolasmol commented May 10, 2022

Hi everyone.
French here, sorry I'll do my best with English

Manajro (latest) + Gnome, on HP laptop, 3 USB port on the same bus.

It's quite strange because three days before, I installed Quickemu, Mac OS , and I was amazingly surprised that at first run, plugging my Iphone 8 made it instantly recognizes into the VM.

I mean..the goal you know, Xcode, flutter, etc...Why the hell would we need MacOS VM for anything else ? But after hours of investigations I found no solution why it disappeared.

After having struggled with the display mode (BTW: with default mode, the area into which the mouse can mouve is smaller that the displayed screen) for which I made so many operations until I undertook that the best is to use "gtk" or "spice", it became impossible to get this f** iphone back into the VM.

Three methods :

No config, gtk display
Terminal repeatedly says ...

usb_desc_get_descriptor: 2 unknown type 33 (len 10)
usb_desc_get_descriptor: 1 unknown type 33 (len 10

Host redirection, gtk display with usb_devices=("05ac:12a8")

  • sudo chown -v rask requested

Terminal repeatedly says ...

qemu-system-x86_64: libusb_set_configuration: -6 [BUSY]

I see that I have on my hp popup notifications, like Manjaro is trying the re-hotplug the device. Impossible to find any simple solution to disable the service which as a kind of "fenix" mode...not sure which one, but it sounds to be usbmuxd
(libimobiledevice/usbmuxd#110)

spice
image

Investigated docs without any success:

arindas/mac-on-linux-with-qemu#25
https://null-src.com/posts/qemu-vfio-pci/post.php
https://askubuntu.com/questions/1269061/qemu-kvm-with-spice-fails-to-maintain-access-to-apple-device-usb-redirection
https://github.com/Silfalion/Iphone_docker_osx_passthrough

Also failed:

And may others...

==> Note also that quitting Spice window doesn't remove the process macos-catalina that has to me manually killed.

[EDIT, 1 day after]

I manage to understand that "my"rules where not in etc/udev/rules.d but in usr/lib/udev/rules.d (who can like linux for this recurrent problem...we never know where are the used files...anyway)
So after commenting all rules in 39-usbmux.rules, I face a new dialog box (in spice mode)

error resetting device: LIBUSB_ERROR_NOT_FOUND

image

Conclusion

At the end some ppl says that it's impossible.
Did I dream when I saw the iphone appearing first time ?

Thanks for your help

[FINAL EDIT - SOLUTION FOR DESPERATE PPL who like me spent 48h finding the fix]

ALTHOUGH I'm not sure it will work in "headless mode" (which is the goal) since it may be using "spice" ???
Keep going...

NOTE: no solution found for "spice mode"

  1. In either etc/udev/rules.d or usr/lib/udev/rules.d find a file named something like ??-usbmuxd.rules

For example in my case 39-usbmuxd.rules

  1. Comments the following lines (adding a #)
# systemd should receive all events relating to device
#SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{PRODUCT}=="5ac/12[9a][0-9a-f]/*", TAG+="systemd"

# Initialize iOS devices into "deactivated" USB configuration state and activate usbmuxd
#SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{PRODUCT}=="5ac/12[9a][0-9a-f]/*", ACTION=="add", ENV{USBMUX_SUPPORTED}="1", ATTR{bConfigurationValue}="0", OWNER="usbmux", ENV{SYSTEMD_WANTS}="usbmuxd.service"

# Make sure properties don't get lost when bind action is called
#SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{PRODUCT}=="5ac/12[9a][0-9a-f]/*", ACTION=="bind", ENV{USBMUX_SUPPORTED}="1", OWNER="usbmux", ENV{SYSTEMD_WANTS}="usbmuxd.service"

# Exit usbmuxd when the last device is removed
#SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{PRODUCT}=="5ac/12[9a][0-9a-f]/*", ACTION=="remove", RUN+="/usr/sbin/usbmuxd -x"

Note that doing this, you're iphone's content won't be accessible through whatever your use for file explorer (e.g. nautilus)... You can't have all you want, make your choice... ;-)

  1. in terminal reload the rules

sudo udevadm control --reload-rule

  1. Remove if exist (gnome users only I think) : gvfs-gphoto2

  2. in the macos-catalina.conf

  • don't use display="spice", use "gtk" instead
  • add the device line
    the file should look like :
guest_os="macos"
disk_img="macos-catalina/disk.qcow2"
img="macos-catalina/RecoveryImage.img"
macos_release="catalina"
display="gtk"
usb_devices=("05ac:12a8")
  1. ensure where is quickemu by typing in your terminal

where quickemu

  1. edit this this (in my case /usr/bin/quickemu)
  2. search the line:

USB_PASSTHROUGH="${USB_PASSTHROUGH} -device usb-host,bus=hostpass.0,vendorid=0x${VENDOR_ID},productid=0x${PRODUCT_ID}

  1. add ,guest-reset=false after {PRODUCT_ID} :
    USB_PASSTHROUGH="${USB_PASSTHROUGH} -device usb-host,bus=hostpass.0,vendorid=0x${VENDOR_ID},productid=0x${PRODUCT_ID},guest-reset=false

Hope it'll help someone.

@github-actions
Copy link

Hello there 👋
Thanks for submitting your first issue to the Quickemu project 🐛 We'll try and take a look at your issue soon ⏲

In the meantime you might want to join the Wimpys World Discord 🗣 where we have a large community of Linux 🐧 enthusiasts and passionate open source developers 🧑‍💻

You might also be interested in following Wimpys World Twitch 📡 channel where Wimpy streams let's code video, including this project, several times a week. A back catalog of past live stream and other Linux related content is available on Wimpys World YouTube 📺 channel.

@sowinski
Copy link

sowinski commented Jun 9, 2022

Any progress on that?

@flexiondotorg flexiondotorg added documentation Improvements or additions to documentation help wanted Extra attention is needed labels Sep 20, 2022
@flexiondotorg
Copy link
Member

It would be good to see a definitive solution for this issue added to the documentation 🙂

@flexiondotorg flexiondotorg changed the title Can anyone tell me if it's only possible to connect on Iphone into the VM ? Document how to connect an iPhone to a macOS virtual machine Sep 20, 2022
@nicolasmol
Copy link
Author

nicolasmol commented Sep 20, 2022

@flexiondotorg have you seen that it requires a modification in quickemu script by adding this option : guest-reset=false

@flexiondotorg flexiondotorg changed the title Document how to connect an iPhone to a macOS virtual machine docs: document how to connect an iPhone to a macOS virtual machine Apr 16, 2024
@nobodyguy
Copy link

Hope it'll help someone.

Merci. It works for me :)

@SiBurgmaier
Copy link

SiBurgmaier commented May 30, 2024

Hello,

the solution above doesn't work for me. After I connect the iPhone, I get the message where I can choose "trust the computer" or I "don't trust the computer".
I choose trust, but on the macOS Sonoma VM changes nothing. The iPhone is not listed in the finder and is not chooseable in Xcode.

I tried to use spice but not I get the error: usb_redirection error libusb_error_not_found
More information here: https://chatgpt.com/share/759bdff2-e230-492e-bc28-04d0498881df

It worked one time and only one time with that solution from chatgpt. I can't reproduce it.

With lsusb I can see, that the iPhone is disconnecting and reconnecting very often. The device number is rising and the error-message, mentioned above, reopens every few seconds. This is because the option in spice "auto redirect newly plugged in USB devices.

This is my config:
#!/usr/bin/quickemu --vm
guest_os="macos"
disk_img="macos-sonoma/disk.qcow2"
img="macos-sonoma/RecoveryImage.img"
macos_release="sonoma"
extra_args="-cpu host -usb -device usb-ehci,id=spiceusb -device usb-host,vendorid=0x05ac,productid=0x12a8"
display="spice"
cpu_cores=8
ram="8G"

Thanks for the mentioned solution above. I hope to find a solution for this problem and I am thankfull for every anwser.

@nobodyguy
Copy link

@SiBurgmaier Yeah, it worked for me only once, so I ended up buying 2018 mac mini instead just to get the initial ios development stages done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants