mirror of
				https://github.com/kholia/OSX-KVM.git
				synced 2025-11-03 21:22:44 +00:00 
			
		
		
		
	OSX-KVM - October 2021 Batch Update #2
This commit is contained in:
		
							parent
							
								
									26ce72f258
								
							
						
					
					
						commit
						a9ef589cc2
					
				@ -40,7 +40,7 @@ args=(
 | 
			
		||||
  # -device usb-mouse,bus=ehci.0
 | 
			
		||||
  # -device nec-usb-xhci,id=xhci
 | 
			
		||||
  -device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
 | 
			
		||||
  -drive if=pflash,format=raw,readonly=true,file="$REPO_PATH/$OVMF_DIR/OVMF_CODE.fd"
 | 
			
		||||
  -drive if=pflash,format=raw,readonly=on,file="$REPO_PATH/$OVMF_DIR/OVMF_CODE.fd"
 | 
			
		||||
  -drive if=pflash,format=raw,file="$REPO_PATH/$OVMF_DIR/OVMF_VARS-1024x768.fd"
 | 
			
		||||
  -smbios type=2
 | 
			
		||||
  -device ich9-intel-hda -device hda-duplex
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										35
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								README.md
									
									
									
									
									
								
							@ -7,7 +7,7 @@ Note: All blobs and resources included in this repository are re-derivable (all
 | 
			
		||||
instructions are included!).
 | 
			
		||||
 | 
			
		||||
:green_heart: Looking for **commercial** support with this stuff? I am [available
 | 
			
		||||
over email](mailto:dhiru.kholia@gmail.com?subject=[GitHub]%20OSX-KVM%20Commercial%20Support%20Request&body=Hi%20-%20We%20are%20interested%20in%20purchasing%20commercial%20support%20options%20for%20your%20project.) for a chat for **commercial support options only**.
 | 
			
		||||
over email](mailto:dhiru.kholia@gmail.com?subject=[GitHub]%20OSX-KVM%20Commercial%20Support%20Request&body=Hi%20-%20We%20are%20interested%20in%20purchasing%20commercial%20support%20options%20for%20your%20project.) for a chat for **commercial support options only**. Note: Project sponsors get access to the `Private OSX-KVM` repository, and direct support.
 | 
			
		||||
 | 
			
		||||
Working with `Proxmox` and macOS? See [Nick's blog for sure](https://www.nicksherlock.com/).
 | 
			
		||||
 | 
			
		||||
@ -78,10 +78,11 @@ Phenom II X3 720 does not. Ryzen processors work just fine.
 | 
			
		||||
 | 
			
		||||
  This step may need to be adapted for your Linux distribution.
 | 
			
		||||
 | 
			
		||||
* Add user to the `kvm` group (might be needed).
 | 
			
		||||
* Add user to the `kvm` and `libvirt` groups (might be needed).
 | 
			
		||||
 | 
			
		||||
  ```
 | 
			
		||||
  sudo usermod -aG kvm $(whoami)
 | 
			
		||||
  sudo usermod -aG libvirt $(whoami)
 | 
			
		||||
  ```
 | 
			
		||||
 | 
			
		||||
  Note: Re-login after executing this command.
 | 
			
		||||
@ -97,6 +98,14 @@ Phenom II X3 720 does not. Ryzen processors work just fine.
 | 
			
		||||
  cd OSX-KVM
 | 
			
		||||
  ```
 | 
			
		||||
 | 
			
		||||
  Repository updates can be pulled via the following command:
 | 
			
		||||
 | 
			
		||||
  ```
 | 
			
		||||
  git pull --rebase
 | 
			
		||||
  ```
 | 
			
		||||
 | 
			
		||||
  This repository uses rebase based workflows heavily.
 | 
			
		||||
 | 
			
		||||
* Fetch macOS installer.
 | 
			
		||||
 | 
			
		||||
  ```
 | 
			
		||||
@ -106,7 +115,7 @@ Phenom II X3 720 does not. Ryzen processors work just fine.
 | 
			
		||||
  You can choose your desired macOS version here. After executing this step,
 | 
			
		||||
  you should have the `BaseSystem.dmg` file in the current folder.
 | 
			
		||||
 | 
			
		||||
  ATTENTION: Let the `Big Sur` setup sit at the `Country Selection` screen, and
 | 
			
		||||
  ATTENTION: Let `>= Big Sur` setup sit at the `Country Selection` screen, and
 | 
			
		||||
  other similar places for a while if things are being slow. The initial macOS
 | 
			
		||||
  setup wizard will eventually succeed.
 | 
			
		||||
 | 
			
		||||
@ -116,10 +125,11 @@ Phenom II X3 720 does not. Ryzen processors work just fine.
 | 
			
		||||
  $ ./fetch-macOS-v2.py
 | 
			
		||||
  1. High Sierra (10.13)
 | 
			
		||||
  2. Mojave (10.14)
 | 
			
		||||
  3. Catalina (10.15) - RECOMMENDED
 | 
			
		||||
  4. Latest (Big Sur - 11)
 | 
			
		||||
  3. Catalina (10.15)
 | 
			
		||||
  4. Big Sur (11.6) - RECOMMENDED
 | 
			
		||||
  5. Monterey (latest)
 | 
			
		||||
 | 
			
		||||
  Choose a product to download (1-4): 3
 | 
			
		||||
  Choose a product to download (1-5):
 | 
			
		||||
  ```
 | 
			
		||||
 | 
			
		||||
  Note: Modern NVIDIA GPUs are supported on HighSierra but not on later
 | 
			
		||||
@ -157,6 +167,8 @@ Phenom II X3 720 does not. Ryzen processors work just fine.
 | 
			
		||||
 | 
			
		||||
- You are all set! 🙌
 | 
			
		||||
 | 
			
		||||
- TIP: Using a non-APFS filesystem is recommended.
 | 
			
		||||
 | 
			
		||||
- (OPTIONAL) Use this macOS VM disk with libvirt (virt-manager / virsh stuff).
 | 
			
		||||
 | 
			
		||||
  - Edit `macOS-libvirt-Catalina.xml` file and change the various file paths (search
 | 
			
		||||
@ -184,9 +196,6 @@ Phenom II X3 720 does not. Ryzen processors work just fine.
 | 
			
		||||
 | 
			
		||||
  - Launch `virt-manager` and start the `macOS` virtual machine.
 | 
			
		||||
 | 
			
		||||
    Note: You may need to run `sudo ip link delete tap0` command before
 | 
			
		||||
    `virt-manager` is able to start the `macOS` VM.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Setting Expectations Right
 | 
			
		||||
 | 
			
		||||
@ -195,7 +204,7 @@ for a variety of purposes (e.g. software builds, testing, reversing work), and
 | 
			
		||||
it may be all you need, along with some tweaks documented in this repository.
 | 
			
		||||
 | 
			
		||||
However, such a system lacks graphical acceleration, a reliable sound sub-system,
 | 
			
		||||
USB (3) functionality and other similar things. To enable these things, take a
 | 
			
		||||
USB 3 functionality and other similar things. To enable these things, take a
 | 
			
		||||
look at our [notes](notes.md). We would like to resume our testing and
 | 
			
		||||
documentation work around this area. Please [reach out to us](mailto:dhiru.kholia@gmail.com?subject=[GitHub]%20OSX-KVM%20Funding%20Support)
 | 
			
		||||
if you are able to fund this area of work.
 | 
			
		||||
@ -245,6 +254,12 @@ Gabriel Somlo also has [some thoughts](http://www.contrib.andrew.cmu.edu/~somlo/
 | 
			
		||||
You may also find [this 'Announcing Amazon EC2 Mac instances for macOS' article](https://aws.amazon.com/about-aws/whats-new/2020/11/announcing-amazon-ec2-mac-instances-for-macos/
 | 
			
		||||
) interesting.
 | 
			
		||||
 | 
			
		||||
Note: It is your responsibility to understand, and accept (or not accept) the
 | 
			
		||||
Apple EULA.
 | 
			
		||||
 | 
			
		||||
Note: This is not legal advice, so please make the proper assessments yourself
 | 
			
		||||
and discuss with your lawyers if you have any concerns (Text credit: Dortania)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Motivation
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -5,3 +5,11 @@
 | 
			
		||||
* https://www.kraxel.org/blog/2017/09/running-macos-as-guest-in-kvm/
 | 
			
		||||
 | 
			
		||||
* https://github.com/foxlet/macOS-Simple-KVM
 | 
			
		||||
 | 
			
		||||
* https://support.apple.com/en-us/HT211683 (How to get old versions of macOS)
 | 
			
		||||
 | 
			
		||||
* https://github.com/sickcodes/Docker-OSX/issues/341#issuecomment-919913745 (awesome qemu automation)
 | 
			
		||||
 | 
			
		||||
* https://github.com/ofawx/VmAssetCacheEnable
 | 
			
		||||
 | 
			
		||||
* https://dortania.github.io/OpenCore-Install-Guide/troubleshooting/extended/post-issues.html
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										60
									
								
								boot-linux-for-debugging.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										60
									
								
								boot-linux-for-debugging.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,60 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
# Special thanks to:
 | 
			
		||||
# https://github.com/Leoyzen/KVM-Opencore
 | 
			
		||||
# https://github.com/thenickdude/KVM-Opencore/
 | 
			
		||||
# https://github.com/qemu/qemu/blob/master/docs/usb2.txt
 | 
			
		||||
#
 | 
			
		||||
# qemu-img create -f qcow2 mac_hdd_ng.img 128G
 | 
			
		||||
#
 | 
			
		||||
# echo 1 > /sys/module/kvm/parameters/ignore_msrs (this is required)
 | 
			
		||||
 | 
			
		||||
############################################################################
 | 
			
		||||
# NOTE: Tweak the "MY_OPTIONS" line in case you are having booting problems!
 | 
			
		||||
############################################################################
 | 
			
		||||
 | 
			
		||||
MY_OPTIONS="+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check"
 | 
			
		||||
 | 
			
		||||
# This script works for Big Sur, Catalina, Mojave, and High Sierra. Tested with
 | 
			
		||||
# macOS 10.15.6, macOS 10.14.6, and macOS 10.13.6
 | 
			
		||||
 | 
			
		||||
ALLOCATED_RAM="3072" # MiB
 | 
			
		||||
CPU_SOCKETS="1"
 | 
			
		||||
CPU_CORES="2"
 | 
			
		||||
CPU_THREADS="4"
 | 
			
		||||
 | 
			
		||||
REPO_PATH="."
 | 
			
		||||
OVMF_DIR="."
 | 
			
		||||
 | 
			
		||||
# This causes high cpu usage on the *host* side
 | 
			
		||||
# qemu-system-x86_64 -enable-kvm -m 3072 -cpu Penryn,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,hypervisor=off,vmx=on,kvm=off,$MY_OPTIONS\
 | 
			
		||||
 | 
			
		||||
# shellcheck disable=SC2054
 | 
			
		||||
args=(
 | 
			
		||||
  -enable-kvm -m "$ALLOCATED_RAM" -cpu host,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,"$MY_OPTIONS"
 | 
			
		||||
  -machine q35
 | 
			
		||||
  -usb -device usb-kbd -device usb-tablet
 | 
			
		||||
  -smp "$CPU_THREADS",cores="$CPU_CORES",sockets="$CPU_SOCKETS"
 | 
			
		||||
  -device usb-ehci,id=ehci
 | 
			
		||||
  # -device usb-kbd,bus=ehci.0
 | 
			
		||||
  # -device usb-mouse,bus=ehci.0
 | 
			
		||||
  # -device nec-usb-xhci,id=xhci
 | 
			
		||||
  -device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
 | 
			
		||||
  -drive if=pflash,format=raw,readonly=on,file="$REPO_PATH/$OVMF_DIR/OVMF_CODE.fd"
 | 
			
		||||
  -drive if=pflash,format=raw,file="$REPO_PATH/$OVMF_DIR/OVMF_VARS-1024x768.fd"
 | 
			
		||||
  -smbios type=2
 | 
			
		||||
  -device ich9-intel-hda -device hda-duplex
 | 
			
		||||
  -device ich9-ahci,id=sata
 | 
			
		||||
  -drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file="$REPO_PATH/OpenCore/OpenCore.qcow2"
 | 
			
		||||
  -device ide-hd,bus=sata.3,drive=OpenCoreBoot
 | 
			
		||||
  -device ide-hd,bus=sata.2,drive=InstallMedia
 | 
			
		||||
  -drive id=InstallMedia,if=none,file="$REPO_PATH/linux.iso",format=raw   # archlinux-2021.10.01-x86_64.iso works nicely!
 | 
			
		||||
  -drive id=MacHDD,if=none,file="$REPO_PATH/linux_hdd.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
 | 
			
		||||
  -netdev user,id=net0 -device virtio-net-pci,netdev=net0,id=net0,mac=52:54:00:c9:18:27
 | 
			
		||||
  -monitor stdio
 | 
			
		||||
  -device VGA,vgamem_mb=128
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
qemu-system-x86_64 "${args[@]}"
 | 
			
		||||
@ -41,15 +41,22 @@ args=(
 | 
			
		||||
  -smp "$CPU_THREADS",cores="$CPU_CORES",sockets="$CPU_SOCKETS"
 | 
			
		||||
  -device usb-ehci,id=ehci
 | 
			
		||||
  -vga none
 | 
			
		||||
  # 01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] [1002:67df] (rev ef)
 | 
			
		||||
  #         Subsystem: Sapphire Technology Limited Nitro+ Radeon RX 570/580/590 [1da2:e366]
 | 
			
		||||
  # 01:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] [1002:aaf0]
 | 
			
		||||
  #         Subsystem: Sapphire Technology Limited Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] [1da2:aaf0]
 | 
			
		||||
  -device vfio-pci,host=01:00.0,multifunction=on
 | 
			
		||||
  -device vfio-pci,host=01:00.1
 | 
			
		||||
  # ASMedia ASM1142 USB 3.1 Host Controller (comment out as needed)
 | 
			
		||||
  # 03:00.0 USB controller [0c03]: ASMedia Technology Inc. ASM1142 USB 3.1 Host Controller [1b21:1242]
 | 
			
		||||
  -device vfio-pci,host=03:00.0,bus=pcie.0
 | 
			
		||||
  -device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
 | 
			
		||||
  -drive if=pflash,format=raw,readonly,file="$REPO_PATH/$OVMF_DIR/OVMF_CODE.fd"
 | 
			
		||||
  -drive if=pflash,format=raw,file="$REPO_PATH/$OVMF_DIR/OVMF_VARS-1024x768.fd"
 | 
			
		||||
  -smbios type=2
 | 
			
		||||
  -device ich9-intel-hda -device hda-duplex
 | 
			
		||||
  -device ich9-ahci,id=sata
 | 
			
		||||
  # -drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file="$REPO_PATH/OpenCore/OpenCore.qcow2"
 | 
			
		||||
  -drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file="$REPO_PATH/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="$REPO_PATH/BaseSystem.img",format=raw
 | 
			
		||||
 | 
			
		||||
@ -456,12 +456,13 @@ def main():
 | 
			
		||||
        return action_guess(args)
 | 
			
		||||
 | 
			
		||||
    # No action specified, so present a download menu instead
 | 
			
		||||
    # https://github.com/acidanthera/OpenCorePkg/blob/master/Utilities/macrecovery/boards.json
 | 
			
		||||
    products = [
 | 
			
		||||
            {"name": "High Sierra (10.13)", "b": "Mac-7BA5B2D9E42DDD94", "m": "00000000000J80300"},
 | 
			
		||||
            {"name": "Mojave (10.14)", "b": "Mac-7BA5B2DFE22DDD8C", "m": "00000000000KXPG00"},
 | 
			
		||||
            {"name": "Catalina (10.15) - RECOMMENDED", "b": "Mac-00BE6ED71E35EB86", "m": "00000000000000000"},
 | 
			
		||||
            # {"name": "Latest (Big Sur - 11)", "b": "Mac-E43C1C25D4880AD6", "m": "00000000000000000", "os_type": "latest"}
 | 
			
		||||
            {"name": "Latest (Big Sur - 11)", "b": "Mac-E43C1C25D4880AD6", "m": "00000000000000000", "os_type": "default"}
 | 
			
		||||
            {"name": "Catalina (10.15)", "b": "Mac-00BE6ED71E35EB86", "m": "00000000000000000"},
 | 
			
		||||
            {"name": "Big Sur (11.6) - RECOMMENDED", "b": "Mac-2BD1B31983FE1663", "m": "00000000000000000"},
 | 
			
		||||
            {"name": "Monterey (latest)", "b": "Mac-7BA5B2D9E42DDD94", "m": "00000000000000000", "os_type": "latest"}
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    for index, product in enumerate(products):
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										8
									
								
								notes.md
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								notes.md
									
									
									
									
									
								
							@ -158,6 +158,8 @@ AMD RX 570 GPU (May 2021).
 | 
			
		||||
  ```
 | 
			
		||||
  @kvm            soft    memlock         unlimited
 | 
			
		||||
  @kvm            hard    memlock         unlimited
 | 
			
		||||
  @libvirt        soft    memlock         unlimited
 | 
			
		||||
  @libvirt        hard    memlock         unlimited
 | 
			
		||||
  ```
 | 
			
		||||
 | 
			
		||||
  Thanks to `Heiko Sieger` for this solution.
 | 
			
		||||
@ -168,6 +170,10 @@ AMD RX 570 GPU (May 2021).
 | 
			
		||||
* To reuse the keyboard and mouse devices from the host, setup "Automatic
 | 
			
		||||
  login" in System Preferences in macOS and configure Synergy software.
 | 
			
		||||
 | 
			
		||||
UPDATE: Project sponsors get access to the `Private OSX-KVM repository`, and
 | 
			
		||||
direct support. This private repository has a playbook to automate 95% of this
 | 
			
		||||
work in a rugged, consistent manner.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### USB passthrough notes
 | 
			
		||||
 | 
			
		||||
@ -209,7 +215,7 @@ These steps will need to be adapted for your particular setup.
 | 
			
		||||
  $ scripts/vfio-group.sh 13
 | 
			
		||||
  ```
 | 
			
		||||
 | 
			
		||||
* Add `-device vfio-pci,host=03:00.0,bus=pcie.0 \` line to `boot-passthrough.sh`.
 | 
			
		||||
* Add `-device vfio-pci,host=03:00.0,bus=pcie.0` line to `boot-passthrough.sh`.
 | 
			
		||||
 | 
			
		||||
* Boot the VM, and devices attached to the ASMedia USB controller should just work under macOS.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user