sickcodes / Docker-OSX

Run macOS VM in a Docker! Run near native OSX-KVM in Docker! X11 Forwarding! CI/CD for OS X Security Research! Docker mac Containers.
https://hub.docker.com/r/sickcodes/docker-osx
GNU General Public License v3.0
36.1k stars 1.78k forks source link

QEMU Docker OSX, Mouse always not working after running 2 minutes #666

Open ikhsansdqq opened 1 year ago

ikhsansdqq commented 1 year ago

OS related issued, please help us identify the issue by posting the output of this

uname -a \ ; echo "${DISPLAY}" \ ; echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs \ ; grep NAME /etc/os-release \ ; df -h . \ ; qemu-system-x86_64 --version \ ; libvirtd --version \ ; free -mh \ ; nproc \ ; egrep -c '(svm|vmx)' /proc/cpuinfo \ ; ls -lha /dev/kvm \ ; ls -lha /tmp/.X11-unix/ \ ; ps aux | grep dockerd \ ; docker ps | grep osx \ ; grep "docker|kvm|virt" /etc/group

Hi Guys, just want to ask question regarding the mouse is not working after 2 minutes, suddenly when running QEMU it looks fine for the first minute but after 2 minutes, it made my mouse not working I don't know why, I can't type, can't click or whatsoever. Any idea how to fix this issue guys? (I'm running docker OSX on Windows 11 22H2)

prodbyola commented 11 months ago

I'm facing somewhat similar issue. DId you fix this?

marcucio commented 6 months ago

same issue here

Linux MikeWindows 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
:0
1
NAME="Ubuntu"
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
Filesystem      Size  Used Avail Use% Mounted on
C:\             931G  560G  372G  61% /mnt/c
QEMU emulator version 4.2.1 (Debian 1:4.2-3ubuntu6.27)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
Command 'libvirtd' not found, but can be installed with:

sudo apt install libvirt-daemon
              total        used        free      shared  buff/cache   available
Mem:           15Gi       4.9Gi       192Mi        13Mi        10Gi        10Gi
Swap:         4.0Gi       326Mi       3.7Gi
12
12
crw-rw-rw- 1 root root 10, 232 Dec 30 11:06 /dev/kvm
total 0
drwxrwxrwx 2 root root  60 Dec 30 11:06 .
drwxrwxrwt 7 root root 300 Jan  3 08:09 ..
srwxrwxrwx 1 mike mike   0 Dec 30 11:06 X0
mike       574  0.0  0.0   8168   708 pts/3    S+   10:46   0:00 grep --color=auto dockerd
ee97ed0b1382   sickcodes/docker-osx:latest   "/bin/bash -c 'sudo …"   3 hours ago   Up 13 minutes   0.0.0.0:50922->10022/tcp   serene_tharp
shawe commented 4 months ago

same here

Linux Fractal 6.5.0-17-generic #17~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 16 14:32:32 UTC 2 x86_64 x86_64 x86_64 GNU/Linux :0 1 PRETTY_NAME="Ubuntu 22.04.3 LTS" NAME="Ubuntu" VERSION_CODENAME=jammy UBUNTU_CODENAME=jammy S.ficheros Tamaño Usados Disp Uso% Montado en /dev/nvme0n1p7 822G 103G 678G 14% / QEMU emulator version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.16) Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers libvirtd (libvirt) 8.0.0 total usado libre compartido búf/caché disponible Mem: 125Gi 7,4Gi 72Gi 240Mi 45Gi 116Gi Inter: 0B 0B 0B 32 64 crw-rw----+ 1 root kvm 10, 232 feb 9 19:37 /dev/kvm total 8,0K drwxrwxrwt 2 root root 4,0K feb 9 18:17 . drwxrwxrwt 23 root root 4,0K feb 9 20:20 .. srwxrwxrwx 1 root root 0 feb 9 18:17 X0 root 2308 0.0 0.0 3386988 80172 ? Ssl 18:17 0:03 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock francesc 10070 0.0 0.0 11848 2304 pts/3 S+ 20:22 0:00 grep --color=auto dockerd 5d9c01e5e139 sickcodes/docker-osx:ventura "/bin/bash -c 'sudo …" 4 hours ago Up 44 minutes 0.0.0.0:50922->10022/tcp, :::50922->10022/tcp quizzical_hawking

atiqsamtia commented 3 months ago

Same issue here, only mouse & keyboard not working. I can see the screen updating and it confirms the OS is running fine and doing processing but won't accept any inputs

atiqsamtia commented 3 months ago

This is how I solved this issue.

It is related to Linux dedicating so much RAM to buff/cache and not enough RAM is remaining for macOS to function properly.

For example in my case, I have a total of 15GB of RAM allocated to WSL and I assigned 12GB of RAM to the docker container of macOS. Whenever I first booted up the macOS it worked fine but quickly buff/cache usage reached around 8GB and free memory went to around 100MB that's where input get stuck. I tried many things and now my OS is working without those issues.

This is my RAM info now free -mh. Before my optimizations, the free part was going to 100MB and crashing macOS.

               total        used        free      shared  buff/cache   available
Mem:            15Gi       9.2Gi       2.4Gi        28Mi       4.0Gi       6.1Gi
Swap:           16Gi          0B        16Gi

Here's what I did.

Changed my macOS container RAM to 8GB -e RAM=8

add

kernelCommandLine="sysctl.vm.swappiness=70"

to .wslconfig

Created a script and added it to cronjob to clear buff/cache every minute so the free RAM stays within the useable range of macOS.

Create a script to clear the cache. Let's name it clear_cache.sh

#!/bin/bash
sync; echo 3 > /proc/sys/vm/drop_caches

make it executable chmod +x clear_cache.sh

Add to root user cron by sudo crontab -e accept new file creation if already does not exist.

Put the corn command to cron file.

* * * * * /path/to/clear_cache.sh

And now start the container. I kept it running for a couple of hours to install and configure Xcode, flutter, IntelliJ Idea and it did not get stuck.

Maybe @sickcodes can add a script to the container to utilize the RAM well so Linux kernel does not allocate free RAM to buff/cache. Maybe reserve the RAM?

Now figuring out Command Key pass through to QEMU.

Maybe helpful for #191 & #218