Silfalion / Iphone_docker_osx_passthrough

The scripts in here allows one to passthrough a usb controller consequently an iphone to a VM created through Docker OSX, this should work but was tested with other OSs
48 stars 10 forks source link

"VFIO_MAP_DMA failed: Cannot allocate memory" in docker environment #3

Open y0va opened 6 months ago

y0va commented 6 months ago

In docker environment host usb address range seems to be unaccessible. See also https://github.com/sickcodes/Docker-OSX/issues/133#issuecomment-894647710

With following command:

docker run -it \
           --privileged \
           --device /dev/kvm -p 50922:10022 \
           -e DEVICE_MODEL="iMacPro1,1" \
           -e WIDTH=1440 \
           -e HEIGHT=900 \
           -e RAM=16 \
           -e CORES=4 \
           -e INTERNAL_SSH_PORT=23 \
           -e AUDIO_DRIVER=none \
           -v /dev:/dev \
           -v /sys:/sys \
           -e 'EXTRA=-vnc 0.0.0.0:1' \
           -e EXTRA="-device pcie-root-port,bus=pcie.0,multifunction=on,port=1,chassis=1,id=port.1 -device vfio-pci,host="00:1a.0",bus=port.1" \
           -e GENERATE_UNIQUE=true \
           -e MASTER_PLIST_URL=https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist sickcodes/docker-osx:big-sur

I get

+ exec qemu-system-x86_64 -m 16000 -cpu Penryn,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check, -machine q35,accel=kvm:tcg -smp 4,cores=4 -usb -device usb-kbd -device usb-tablet -device 'isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc' -drive if=pflash,format=raw,readonly=on,file=/home/arch/OSX-KVM/OVMF_CODE.fd -drive if=pflash,format=raw,file=/home/arch/OSX-KVM/OVMF_VARS-1024x768.fd -smbios type=2 -audiodev none,id=hda -device ich9-intel-hda -device hda-duplex,audiodev=hda -device ich9-ahci,id=sata -drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file=/home/arch/OSX-KVM/OpenCore/OpenCore.qcow2 -device ide-hd,bus=sata.2,drive=OpenCoreBoot -device ide-hd,bus=sata.3,drive=InstallMedia -drive id=InstallMedia,if=none,file=/home/arch/OSX-KVM/BaseSystem.img,format=qcow2 -drive id=MacHDD,if=none,file=/home/arch/OSX-KVM/mac_hdd_ng.img,format=qcow2 -device ide-hd,bus=sata.4,drive=MacHDD -netdev user,id=net0,hostfwd=tcp::23-:22,hostfwd=tcp::5900-:5900, -device vmxnet3,netdev=net0,id=net0,mac=52:54:00:09:49:17 -monitor stdio -boot menu=on -vga vmware -device pcie-root-port,bus=pcie.0,multifunction=on,port=1,chassis=1,id=port.1 -device vfio-pci,host=00:1a.0,bus=port.1
QEMU 7.1.0 monitor - type 'help' for more information
(qemu) qemu-system-x86_64: -device vfio-pci,host=00:1a.0,bus=port.1: VFIO_MAP_DMA failed: Cannot allocate memory
qemu-system-x86_64: -device vfio-pci,host=00:1a.0,bus=port.1: VFIO_MAP_DMA failed: Cannot allocate memory
qemu-system-x86_64: -device vfio-pci,host=00:1a.0,bus=port.1: VFIO_MAP_DMA failed: Cannot allocate memory
qemu-system-x86_64: -device vfio-pci,host=00:1a.0,bus=port.1: vfio 0000:00:1a.0: failed to setup container for group 10: memory listener initialization failed: Region pc.ram: vfio_dma_map(0x56275d6bf170, 0x0, 0xa0000, 0x7fbfbde00000) = -12 (Cannot allocate memory)

This happened on a debian machine on

# inxi
CPU: 2x 6-Core Intel Xeon E5-2620 0 (-MT MCP SMP-) speed/min/max: 1200/1200/2500 MHz Kernel: 5.10.0-26-amd64 x86_64 Up: 1h 09m 
Mem: 1037.6/32109.4 MiB (3.2%) Storage: 1.04 TiB (63.1% used) Procs: 323 Shell: Bash inxi: 3.3.01 
andrewcharnley commented 4 months ago

Did you manage to get this working? I also have the same now.


qemu-system-x86_64: -device vfio-pci,host=0000:0a:00.3,bus=port.1: VFIO_MAP_DMA failed: Cannot allocate memory
qemu-system-x86_64: -device vfio-pci,host=0000:0a:00.3,bus=port.1: vfio 0000:0a:00.3: failed to setup container for group 14:```
andrewcharnley commented 4 months ago

Hi,

Add this to /etc/security/limits.conf

*            soft    memlock         unlimited
*            hard    memlock         unlimited

And it's resolved.