#!/bin/bash
d="$(dirname "${BASH_SOURCE[0]}")"
exec sudo DYLD_FALLBACK_LIBRARY_PATH="$d/build/angle:$d/lib" "$d/bin/qemu-system-x86_64" \
-display cocoa,gl=es \
-nodefaults \
-vga none \
-device e1000,mac=1E:1D:76:3B:80:F6,netdev=net0 \
-netdev vmnet-bridged,id=net0,ifname=en0 \
-device virtio-vga-gl \
-cpu Penryn,+sse4.1,+sse4.2,+ssse3 -smp cpus=1,sockets=1,cores=1,threads=1 \
-machine pc-q35-7.2,vmport=off,i8042=off,hpet=off \
-accel hvf \
-global ICH9-LPC.disable_s3=1 \
-drive if=pflash,format=raw,unit=0,file=/Applications/UTM.app/Contents/Resources/qemu/edk2-x86_64-code.fd,readonly=on \
-drive "if=pflash,unit=1,file=$HOME/Library/Containers/com.utmapp.UTM/Data/Documents/Snow Leopard.utm/Data/efi_vars.fd" \
-m 4096 \
-audiodev coreaudio,id=audio1 \
-device usb-audio,audiodev=audio1 \
-usb \
-device usb-tablet,bus=usb-bus.0 \
-device usb-mouse,bus=usb-bus.0 \
-device usb-kbd,bus=usb-bus.0 \
-device ich9-usb-ehci1,id=usb-controller-0 \
-device ich9-usb-uhci1,masterbus=usb-controller-0.0,firstport=0,multifunction=on \
-device ich9-usb-uhci2,masterbus=usb-controller-0.0,firstport=2,multifunction=on \
-device ich9-usb-uhci3,masterbus=usb-controller-0.0,firstport=4,multifunction=on \
-chardev spicevmc,name=usbredir,id=usbredirchardev0 \
-device usb-redir,chardev=usbredirchardev0,id=usbredirdev0,bus=usb-controller-0.0 \
-chardev spicevmc,name=usbredir,id=usbredirchardev1 \
-device usb-redir,chardev=usbredirchardev1,id=usbredirdev1,bus=usb-controller-0.0 \
-chardev spicevmc,name=usbredir,id=usbredirchardev2 \
-device usb-redir,chardev=usbredirchardev2,id=usbredirdev2,bus=usb-controller-0.0 \
-device ide-hd,bus=ide.0,drive=drive7E7A1E5D-D66F-48A1-A892-FE7BDFDE979D,bootindex=0 \
-drive "if=none,media=disk,id=drive7E7A1E5D-D66F-48A1-A892-FE7BDFDE979D,file=$HOME/Library/Containers/com.utmapp.UTM/Data/Documents/Snow Leopard.utm/Data/1920x1080-OpenCoreSLeopard.qcow2,discard=unmap,detect-zeroes=unmap" \
-device ide-hd,bus=ide.1,drive=driveA51C89E5-8257-4DD2-A2AE-C05E689F3C99,bootindex=1 \
-drive "if=none,media=disk,id=driveA51C89E5-8257-4DD2-A2AE-C05E689F3C99,file=$HOME/Library/Containers/com.utmapp.UTM/Data/Documents/Snow Leopard.utm/Data/macintosh.qcow2,discard=unmap,detect-zeroes=unmap" \
-device virtio-serial \
-device virtserialport,chardev=vdagent,name=com.redhat.spice.0 \
-chardev spicevmc,id=vdagent,debug=0,name=vdagent \
-name "Snow Leopard" -uuid 192340CB-7E2B-4F09-8859-7FF5C5981A28 \
-device virtio-rng-pci \
-device virtio-balloon-pci \
-chardev qemu-vdagent,id=spice,name=vdagent,clipboard=on \
-device virtio-serial-pci \