seteuid0's blog
Themed by Diary.
Run macOS on QEMU/KVM

有需要跑macOS,遂找资料进行下初期的技术验证。看了一些网页后大多都基于https://github.com/kholia/OSX-KVM 来做,简单验证流程如下: 使用fedora30系统(系统运行qemu的操作省略)``` git clone https://github.com/kholia/OSX-KVM.git cd OSX-KVM ./fetch-macOS.py

ProductID Version Build Post Date Title

1 041-91758 10.13.6 17G66 2019-10-19 macOS High Sierra 2 041-88800 10.14.4 18E2034 2019-10-23 macOS Mojave 3 061-26589 10.14.6 18G103 2019-10-14 macOS Mojave 4 061-10700 10.15.2 19C57 2019-12-10 macOS Catalina 5 041-90855 10.13.5 17F66a 2019-10-23 Install macOS High Sierra Beta 6 061-26578 10.14.5 18F2059 2019-10-14 macOS Mojave 7 061-44345 10.15.2 19C39d 2019-11-15 macOS Catalina Beta Choose a product to download (1-7): 2

qemu-img convert BaseSystem.dmg -O raw BaseSystem.img

qemu-img create -f qcow2 mac_hdd_ng.img 128G mv mac_hdd_ng.img mac_hdd.img 然后基于boot-macOS-Catalina进行修改,我修改后的内容如下,安装后即可进入系统,参数添加了spice可以通过spice进行访问。 ############################################################################

NOTE: Tweak the “MY_OPTIONS” line in case you are having booting problems!

############################################################################

This works for Catalina as well as Mojave. Tested with macOS 10.14.6 and macOS 10.15.

MY_OPTIONS="+pcid,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check"

OVMF=./firmware

OVMF="./"

qemu-system-x86_64 -enable-kvm -m 3072 -cpu Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,$MY_OPTIONS\
-machine q35 \
-smp 4,cores=2 \
-usb -device usb-kbd -device usb-mouse \
-device isa-applesmc,osk=“ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc” \
-drive if=pflash,format=raw,readonly,file=$OVMF/OVMF_CODE.fd \
-drive if=pflash,format=raw,file=$OVMF/OVMF_VARS-1024x768.fd \
-smbios type=2 \
-device ich9-intel-hda -device hda-duplex \
-device ich9-ahci,id=sata \
-drive id=Clover,if=none,snapshot=on,format=qcow2,file=./‘Catalina/CloverNG.qcow2’ \
-device ide-hd,bus=sata.2,drive=Clover \
-device ide-hd,bus=sata.3,drive=InstallMedia \
-drive id=InstallMedia,if=none,file=BaseSystem.img,format=raw \
-drive id=MacHDD,if=none,file=./mac_hdd_ng.img,format=qcow2 \
-device ide-hd,bus=sata.4,drive=MacHDD \
-netdev tap,id=net0,ifname=tap0,script=no,downscript=no -device vmxnet3,netdev=net0,id=net0,mac=52:54:00:c9:18:27 \
-monitor stdio \
-vnc 0.0.0.0:0 -k en-us \
-spice port=7900,addr=0.0.0.0,disable-ticketing,image-compression=off,seamless-migration=on \
-vga vmware