mirror of
https://github.com/sickcodes/Docker-OSX.git
synced 2026-01-13 13:53:28 +01:00
Igpu passthrough #107
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Silfalion on GitHub (Jan 22, 2021).
Stumbled upon this:
https://github.com/patmagauran/i915ovmfPkg/wiki
From this article:
https://www.reddit.com/r/VFIO/comments/innriq/successful_macos_catalina_with_intel_gvtg/?utm_source=share&utm_medium=ios_app&utm_name=iossmf
(Way more up to date details in the first comment)
This could be used to improve the responsiveness of the container even more if passed in the args, thoughts?
@sickcodes commented on GitHub (Jan 27, 2021):
I have tried this but I have AMD + AMD GPU + NVIDIA iGPU and I was unable to get it to work.
I do believe it's possible on intel iGPU.
Some more notes here: https://github.com/sickcodes/Docker-OSX/blob/master/helm/INSTALL-QEMU-AND-GPU-IOMMU.md
@Silfalion commented on GitHub (Jan 27, 2021):
I see. Then once I set up the container I will give it a try and report back on it.
@Silfalion commented on GitHub (Apr 5, 2021):
so, following these resources:
https://www.reddit.com/r/VFIO/comments/innriq/successful_macos_catalina_with_intel_gvtg/
https://wiki.archlinux.org/index.php/Intel_GVT-g
https://github.com/patmagauran/i915ovmfPkg/wiki
so it's basically consist of activating gvt-g and using a custom rom while on the vm, the rom is available from the 3rd link in the release section.
I arrived to this result:
(qemu) qemu-system-x86_64: -device vfio-pci,sysfsdev=/sys/bus/mdev/devices/0f9daa70-9637-11eb-9840-7b4d486004cd,display=on,x-igd-opregion=on,romfile=i915ovmf.rom: vfio 0f9daa70-9637-11eb-9840-7b4d486004cd: failed to open /dev/vfio/13: Permission deniedeven after adding myself to both the qemu and libvirt gorup.
Any idea on how to fix this?
(usb passthrough works here and with iphone as well)
@sickcodes commented on GitHub (Apr 6, 2021):
Add
--privilegedyou might almost have it!@sickcodes commented on GitHub (Apr 6, 2021):
Very cool getting the iPhone to pasthrough! Would love a PR or a blog post I can link to if you want to write something up :)
@Silfalion commented on GitHub (Apr 6, 2021):
That was the thing that was needed for the iphone passthrough, it took me 3 days to figure it out lol. Any other ideas?
@Silfalion commented on GitHub (Apr 6, 2021):
Sure! Just need a little bit of time. Also, the issue that helped me incredibly was this one:
https://github.com/sickcodes/Docker-OSX/issues/36
The even cooler thing is that I was able to sign up the app for a job no problem, so it should be 100% functional.
@mandelake commented on GitHub (May 7, 2021):
Hey Silfalion, is it possible for you to share the steps needed for the iPhone passthrough? Every other day I'm checking this tread for your instructions, in no avail.
Thanks
@Silfalion commented on GitHub (May 7, 2021):
Oh very sorry, ping without any problem, just got distracted with work. Will try to add the steps here today or tomorrow, if that's alright.
@Silfalion commented on GitHub (May 10, 2021):
@mandelake
Ok, so, the first step is to edit the grub to activate iommu:
1-Go to /etc/default/grub with sudo gedit /etc/default/grub
2-On the line that starts with
GRUB_CMDLINE_LINUX_DEFAULTadd intel_iommu=on or amd_iommu=on, depending on which processor brand you have. It will look like this:GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_iommu=on"or
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash amd_iommu=on"3-Update your grub with the command
sudo update-grub4-Reboot
This part will allow us to passthrough devices to the VM.
To be able to do the passthrough we need to identify your usb controllers and which one to pass. To do so, execute or put in a file then execute(make sure the execution permission is on in the file properties in case you put it in one):
The result will be a list of groups and with each group items. You want to look for one called usb controller, there could be many, just choose one and make sure you're not using it for something important.
Once you decide on one, mark down the digits at the very beginning of its line, the ones between brackets, Ex: 00:00:12.0.
This actually may need a bit of research as I didn't too much into. The next step will make your usb available to the guest(VM) but not the host(your OS), read somewhere this could be irreversible but didn't find on other tutorial, still go about it with caution.
The following script will bind your USB controller but you will need to reboot to gain back access to your USB, there is most definitely a script to unbind it, but didn't find one at the moment:
https://raw.githubusercontent.com/andre-richter/vfio-pci-bind/master/vfio-pci-bind.sh
Execute it as follow:
sudo ./vfio-pci-bind XX:XX:XX.XReplace the number with the numbers you got earlier. Now your usb should be ready to passthrough.
All you have to do now is add these 2 lines to your docker run command:
--privileged \And
-e EXTRA='-device vfio-pci,host=XX:XX.X'Just remove the 2 first zeros of the number of earlier and replace it instead of the Xs.
This should be all, if you have any problem, do ask.
@mandelake commented on GitHub (May 11, 2021):
@Silfalion
Thank you for taking the time to answer, still, your help would be much appreciated. I'm stucked with the vfio-pci-bind script.
Error: Please provide Version:Device (vvvv:dddd) and/or Domain:Bus:Device.Function (dddd:bb:dd.f)By the way, the first script throws an error:
15: Syntax error: end of file unexpected (expecting "done")I fixed it with:
d changed to
done;added
done;And so, the script show that I have two usb controllers.
The processor virtualization is enabled:
@Silfalion commented on GitHub (May 12, 2021):
Ah yes sorry, must've forgotten the last character when copy-pasting.
You're very close. Didn't try with a thunderbolt USB controller, may be really useful with the new ipad. So choose the first one, your XX.... number is 00:14.0. Just need to add it as an argument with the first script you mentioned.
@sickcodes commented on GitHub (May 13, 2021):
Yo yo this is awesome!
Will give it a try this week and make it easy to use :) thanks a ton for writing this!
@Silfalion commented on GitHub (May 15, 2021):
All my pleasure:) the more we democratize Macos for everyone, the better it is.
@Silfalion commented on GitHub (May 15, 2021):
@mandelake
Did evrerything work for you?
@mandelake commented on GitHub (May 16, 2021):
@Silfalion
Sorry for the delay, I was out of town. Anyways, the answer is NO, I didn't make it work just yet.
The vfio-pci-bind is sorted out

I'm stucked now with
to which I'm looking for a fix.
So don't worry, I'll leave a word once everything works.
@Silfalion commented on GitHub (May 16, 2021):
If you want, you can post your run docker container script so that we sort it out.
@mandelake commented on GitHub (May 16, 2021):
Being an old container, initially I tried to use start instead of run to initialize it, but it complained about
unknown flag: --privilegedthat gave
So, I changed that to
which creates an entirely new container and also gives
@sickcodes commented on GitHub (May 17, 2021):
This doesn't work on Docker, you can use the image in naked following these steps:
https://github.com/sickcodes/Docker-OSX#container-creation-examples
@Silfalion commented on GitHub (May 19, 2021):
True, forgot to add that I extracted the system image and made it work with the naked version not the classic one. (Sorry was busy with work)
@henriquenunez commented on GitHub (May 27, 2021):
Hello everyone!
First things first, so thank you for providing this awesome utility!
I am having the following problem when trying to forward the usb:
My init script is:
afaik, i did everything correctly:
00:14.0 USB controller: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller (rev 21)sudo ./vfio-pci-bind.sh 00:14.0And now this problem is happening.
Any suggestions? thx a lot
@henriquenunez commented on GitHub (Jun 5, 2021):
Hey everyone, for some reason, it now works.
Probably I just needed to put my laptop to rest for a while XD.
@EhsanFortuna commented on GitHub (Jun 23, 2021):
Hi everyone , I am having the same problem
any suggestions ?
Thank you so much.
@evertonrobertoauler commented on GitHub (Aug 7, 2021):
Hey guys, I Had the same issue and struggle a lot to find a way to make it work, from inside the Docker container, unfortunatly I couldn't pass this error.
After a lot of research, I fixed it runing qemu with sudo from my host system and my USB controller passthrough is working pefectly.
A made it work doing the following steps, I hope it helps some of you guys that like me depends on it for iOS development that some times needs to debug or test some functionality on a real device.
Start your docker container normaly without
-e EXTRA='-device vfio-pci,host=05:00.0'and add a folder as a volume-v /home/myuser/myfolder:/home/arch/OSX-KVM/myfolder:rw --name=mycontainerIn another terminal
docker exec -ti mycontainer bashThen from inside the container, copy the following files to myfolder
Now you can turn down the VM.
Download https://raw.githubusercontent.com/andre-richter/vfio-pci-bind/master/vfio-pci-bind.sh inside your folder
Update your Launch.sh, and replace 05:00.0 with your USB Controller.
bash Launch.shand enjoy.I'm using 8GB of RAM (-m 8000), 8 threads and 4 cores, but you guys can easily change this params above and adjust anything that is needed.
@sickcodes commented on GitHub (Aug 7, 2021):
Nice one! Possible work around could be passing
-v /sys:/sysand-v /dev:/devBut this is great, I will try and give it a go
@evertonrobertoauler commented on GitHub (Aug 7, 2021):
Thanks men, unfortunatly passing those volumes
-v /sys:/sys -v /dev:/devdidn't fixed thegroup 22: memory listener initialization failedissue for me, I'm using Fedora, it could be something related to my host system, something related to Selinux or something that is blocking access to the vfio-pci device from inside the container.But still, this is an awesome project, I only had this USB Controller Passthrough issue, that I was able to work around with the steps above.
But overall, thanks a lot for this project, I think that this is the easiest way to get a Mac OSx vm up and running.
@Silfalion commented on GitHub (Aug 7, 2021):
If its usb controller passtrhough, added this repo that should be later merged with docker osx.
https://github.com/Silfalion/Iphone_docker_osx_passthrough
Any suggestions/contributions/bug report is welcome.
@Silfalion commented on GitHub (Aug 7, 2021):
And if anyone needs something for igpu, this sounds very promising:
https://github.com/patmagauran/i915ovmfPkg/wiki
But didn't get the time to test yet, if anyone manage to make it work, would be great if they shared it here:)
The issues seem to have the key for making it work.
@sickcodes commented on GitHub (Aug 16, 2021):
Other options:
@sickcodes commented on GitHub (Aug 27, 2021):
Adding instructions tomorrow, this is insane
@noelhibbard commented on GitHub (Aug 30, 2021):
brew isn't finding a package named autoheader.
@sickcodes commented on GitHub (Aug 30, 2021):
Ignore that one, I'll fix the readme now, thanks!
@noelhibbard commented on GitHub (Aug 31, 2021):
I got Configurator 2 to connect to an iDevice but I'm unable to supervise the device. It tells the phone to erase and reboot but then it never reconnects. Why does Apple only give us one way to supervise an iDevice. Apple is so ridiculous sometimes.
@sickcodes commented on GitHub (Sep 1, 2021):
This will be something about device resetting, does either usbfluxd window close? What happens if you run usbmuxd in the foreground?
@noelhibbard commented on GitHub (Sep 1, 2021):
I got it working. I just had to hit cancel in Configurator and then restart both ends of usbfluxd and then the device came back up in Configurator and I was able to supervise on my second attempt because the device was then in an erased state.
It would be cool if usbmuxd survived disconnect/connects.
@andrestone commented on GitHub (Sep 7, 2021):
Did anyone make progress with the iGPU passthrough?
@jthoward64 commented on GitHub (May 6, 2022):
...
Are these configs for iGPU pass-through with patmagauran/i915ovmfPkg?