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
46.7k stars 2.53k forks source link

Big-sur looping error in QEMU #291

Closed mikob closed 3 years ago

mikob commented 3 years ago

I had everything working before with Catalina and this docker image you provided, thank you! Unfortunately, I needed to upgrade to Big Sur to install the latest XCode and stay compatible. Using upgrade through the MacOS interface didn't seem to work, after restarting, it would still be on Catalina. So I pulled the latest image: sickcodes/docker-osx:big-sur (ee7fe01fa6e8) and the latest naked: sickcodes/docker-osx:naked (45f7cd41be3b) and ran the fresh install on the former, and moved the new image to the latter. Now I can't boot after selecting the drive in the QEMU menu. QEMU is in an endless loop with logs that look like this:

In QEMU:

AMFI: SIP is off, allowing core dump for pid 294 (logd)
Process(294) crashed: logd. Too many corpses being created.
localhost com.apple.xpc.launchd[1] (com.apple.logd.294) <Notice>: Service exited due to SIGILL | sent by exc handler(294)
localhost com.apple.xpc.launchd[1] (com.apple.logd) <Notice>: Service only ran for 0 seconds. Pushing respawn out by 1 seconds.
apfs_get_firmlink_target_vnode:2013: disk2s1:0 vnode_lookupat(Library) failed with error 2

I run the docker image this way: docker run --privileged -p 8081:8081 -p 50922:10022 --ulimit memlock=-1:-1 -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix -e GENERATE_UNIQUE=true -e MASTER_PLIST_URL=https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist -tid --name mac5 -e NOPICKER=true -e IMAGE_PATH=/image/mac_hdd_ng.img -v mac-img-2:/image sickcodes/docker-osx:naked

In docker logs:

commandrvf: stdout=n stderr=y flags=0x0
commandrvf: udevadm --debug settle -E /dev/sdb
No filesystem is currently mounted on /sys/fs/cgroup.
Failed to determine unit we run in, ignoring: No data available
commandrvf: stdout=n stderr=y flags=0x0
commandrvf: udevadm --debug settle -E /dev/sda
No filesystem is currently mounted on /sys/fs/cgroup.
Failed to determine unit we run in, ignoring: No data available
fsync /dev/sda
libguestfs: trace: internal_autosync = 0
libguestfs: sending SIGTERM to process 1202
libguestfs: qemu maxrss 230104K
libguestfs: command: run: rm
libguestfs: command: run: \ -rf /tmp/libguestfs66ceW9
libguestfs: command: run: rm
libguestfs: command: run: \ -rf /tmp/libguestfsdzCMGP
DEVICE_MODEL,SERIAL,BOARD_SERIAL,UUID,MAC_ADDRESS,WIDTH,HEIGHT
"iMacPro1,1","C02FH043HX87","C02113401J9JG361M","44AF920B-DF40-44F1-981E-566569624489","30:D9:D9:8C:C2:E0","1920","1080"
DEVICE_MODEL    SERIAL  BOARD_SERIAL    UUID    MAC_ADDRESS WIDTH   HEIGHT
iMacPro1,1  C02FH043HX87    C02113401J9JG361M   44AF920B-DF40-44F1-981E-566569624489    30:D9:D9:8C:C2:E0   1920    1080

ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519 
nohup: appending output to 'nohup.out'
++ id -u
++ id -g
+ sudo chown 1000:1000 /dev/kvm
++ id -u
++ id -g
+ sudo chown -R 1000:1000 /dev/snd
+ [[ 3 = max ]]
+ [[ 3 = half ]]
++ id -u
++ id -g
+ sudo chown -R 1000:1000 /dev/snd
+ exec qemu-system-x86_64 -m 3000 -cpu Penryn,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+pcid,+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,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 alsa,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-Catalina/OpenCore-nopicker.qcow2 -device ide-hd,bus=sata.2,drive=OpenCoreBoot -drive id=MacHDD,if=none,file=/image/mac_hdd_ng.img,format=qcow2 -device ide-hd,bus=sata.4,drive=MacHDD -netdev user,id=net0,hostfwd=tcp::10022-:22,hostfwd=tcp::5900-:5900, -device vmxnet3,netdev=net0,id=net0,mac=52:54:00:09:49:17 -monitor stdio -vga vmware
qemu-system-x86_64: -drive if=pflash,format=raw,readonly,file=/home/arch/OSX-KVM/OVMF_CODE.fd: warning: short-form boolean option 'readonly' deprecated
Please use readonly=on instead
qemu-system-x86_64: warning: dbind: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-G2sgqXZG12: Connection refused
QEMU 6.0.0 monitor - type 'help' for more information

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

NAME="Linux Mint"
PRETTY_NAME="Linux Mint 20.1"
VERSION_CODENAME=ulyssa
UBUNTU_CODENAME=focal
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p6  1.1T  671G  406G  63% /home
QEMU emulator version 4.2.1 (Debian 1:4.2-3ubuntu6.16)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
libvirtd (libvirt) 6.0.0
              total        used        free      shared  buff/cache   available
Mem:           15Gi       4.8Gi       236Mi       806Mi        10Gi       9.4Gi
Swap:          11Gi       310Mi        11Gi
12
24
crw-rw-rw-+ 1 root kvm 10, 232 Jun 12 22:48 /dev/kvm
total 152K
drwxrwxrwt  2 root root 4.0K Jun 12 21:50 .
drwxrwxrwt 22 root root 144K Jun 12 22:55 ..
srwxrwxrwx  1 root root    0 Jun 12 21:50 X0
root        8306  0.3  0.4 1834604 71472 ?       Ssl  22:07   0:09 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
mikob      32607  0.0  0.0  11572  2352 pts/5    S+   22:55   0:00 grep -i dockerd
dcf5c230fdf5   sickcodes/docker-osx:naked    "/bin/bash -c 'sudo …"   7 minutes ago   Up 7 minutes              0.0.0.0:8081->8081/tcp, :::8081->8081/tcp, 0.0.0.0:50922->10022/tcp, :::50922->10022/tcp   mac5
docker:x:999:mikob
kvm:x:132:mikob
libvirt:x:139:mikob
libvirt-qemu:x:64055:libvirt-qemu
libvirt-dnsmasq:x:140:
sickcodes commented 3 years ago

It will be a struggle to upgrade from Big Sur from Catalina, since one uses HFS and the other uses APFS, you're better off creating a Big Sur, and just rsyncing the data across. You can use hfs progs to mount the old disk from the host, and then rsync it into the new container.

mikob commented 3 years ago

@sickcodes thanks for the quick response. This was my attempt at creating a Big Sur image from scratch. I didn't bring over the old image. The errors are after a fresh install :/

mikob commented 3 years ago

I tried it again this morning and wrote down my steps. Didn't use the naked image at all this time.

docker run --device /dev/kvm -p 50922:10022 -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix -e GENERATE_UNIQUE=true -e MASTER_PLIST_URL=https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist -ti --name mac6 sickcodes/docker-osx:big-sur

  1. In QEMU Menu with "macOS Base System" option. Select that.
  2. Click Disk Utility
  3. Delete biggest disk
  4. Make a new APNS disk called "Mac"
  5. Close disk utility
  6. Click Reinstall macOS Big Sur
  7. Select "Mac" as disk to install onto and wait ~1.5 hours
  8. After install at some point there's a reboot and we're back in the QEMU menu with a new option "MacOS Install". Select "MacOS Install" We see the apple logo and loading. Wait the 30m or so.
  9. Again there's a reboot and we're in the QEMU Menu. Now in the QEMU menu, change startup disk to "Mac" and restart.
  10. In QEMU menu click "Mac"

Here the same aforementioned error appears.

mikob commented 3 years ago

@sickcodes I just tried the sickcodes/docker-osx:auto image based on the comment here: https://github.com/sickcodes/Docker-OSX/pull/158#issuecomment-787060331 (auto-big-sur doesn't seem to exist) but the auto image has Catalina.

sickcodes commented 3 years ago

Can you confirm that you have the latest version? docker pull sickcodes/docker-osx:big-sur

I'm testing now

mikob commented 3 years ago

Got it working finally! The issue was virtlogd wasn't running. I copied and pasted the commands that included:

...
sudo systemctl enable --now virtlogd
...

So not sure exactly how it happened. Thanks for your attentiveness!

sickcodes commented 3 years ago

No worries!

JAicewizard commented 7 months ago

I have the same issue at the moment, just updated arch linux, started libvirtd and virtlogd, /sys/module/kvm/parameters/ignore_msrs set to Y, and loaded kvm, using big-sur. Do you have any tips for debugging this?