XNU as a loadable kernel module inside Linux (macOS personality for arm64 Linux)
C
run the VM with its console captured through a host pty
Heyang Zhoubedb7e90ee22
diff --git a/scripts/serial-pty.py b/scripts/serial-pty.pynew file mode 100644index 0000000..8041171--- /dev/null+++ b/scripts/serial-pty.py@@ -0,0 +1,17 @@+#!/usr/bin/env python3+# On the Mac host: create a pty for `tart run --serial-path`, write its name to argv[1] and append+# everything the guest writes to its console to argv[2]. Output survives a guest hang.+import os, sys, tty+m, s = os.openpty()+tty.setraw(s)+with open(sys.argv[1], "w") as f:+ f.write(os.ttyname(s))+out = open(sys.argv[2], "ab", 0)+while True:+ try:+ d = os.read(m, 65536)+ except OSError:+ break+ if not d:+ break+ out.write(d)diff --git a/scripts/vm-run-serial.sh b/scripts/vm-run-serial.shnew file mode 100644index 0000000..c38603e--- /dev/null+++ b/scripts/vm-run-serial.sh@@ -0,0 +1,7 @@+#!/bin/bash+# On the Mac host: run the xnupoc VM with its console (hvc0) captured to ../serial-cap.log.+cd "$(dirname "$0")/.."+rm -f ../serial-name+python3 scripts/serial-pty.py ../serial-name ../serial-cap.log &+for i in $(seq 1 50); do [ -s ../serial-name ] && break; sleep 0.1; done+exec tart run xnupoc --no-graphics --serial-path "$(cat ../serial-name)"