Qwen3-0.6B inference (12 KB), bare-metal bootable OS (22 KB), and from-scratch Mini-GPT trainer with live Braille TUI (32 KB) in 100% pure x86-64 NASM assembly. Zero C, zero libc, zero dependencies.
#!/bin/bash
# Runs INSIDE `unshare -Urn` to provide a 100% air-gapped virtual network for eBPF-Jev egress QA.
# Zero host NICs, zero host LAN routes, zero internet routes.
set -euo pipefail
REPO_ROOT="${1:?missing repo root}"
RUN_DIR="${2:?missing run dir}"
RUN_NAME="${3:?missing run name}"
cd "$REPO_ROOT"
printf '%s\n' "$$" > "$RUN_DIR/netns.pid"
# 1. Configure air-gapped isolated interfaces (ONLY lo, dummy0, tap0 exist in this netns)
ip link set lo up
ip link add dummy0 type dummy
ip link set dummy0 up
sysctl -qw net.ipv6.conf.dummy0.accept_dad=0
ip addr add 198.51.100.66/32 dev dummy0
ip addr add 2001:db8:cafe::66/128 dev dummy0 nodad
ip tuntap add dev tap0 mode tap
ip link set tap0 up
sysctl -qw net.ipv6.conf.tap0.accept_dad=0
ip addr add 10.77.0.1/24 dev tap0
ip addr add fd77::1/64 dev tap0 nodad
sysctl -qw net.ipv4.ip_forward=1
sysctl -qw net.ipv6.conf.all.forwarding=1
{
echo "=== ip addr (isolated unshare -Urn netns) ==="
ip addr
echo "=== ip route ==="
ip route
echo "=== ip -6 route ==="
ip -6 route
} > "$RUN_DIR/netns_routes.txt"
# 2. Start isolated mock services (DNS :53, Proxy :3128, Corp API :8080, External Sink 198.51.100.66 & 2001:db8:cafe::66)
python3 "$REPO_ROOT/demo/pi-egress/egress_services.py" "$RUN_DIR" >"$RUN_DIR/egress_services.log" 2>&1 &
svc_pid=$!
printf '%s\n' "$svc_pid" > "$RUN_DIR/egress_services.pid"
cleanup() {
local rc=$?
if [[ -n "${qemu_pid:-}" ]] && kill -0 "$qemu_pid" 2>/dev/null; then
kill -TERM "$qemu_pid" 2>/dev/null || true
for ((i=0; i<50; i++)); do
kill -0 "$qemu_pid" 2>/dev/null || break
sleep 0.1
done
kill -KILL "$qemu_pid" 2>/dev/null || true
fi
if [[ -n "${svc_pid:-}" ]] && kill -0 "$svc_pid" 2>/dev/null; then
kill -TERM "$svc_pid" 2>/dev/null || true
wait "$svc_pid" 2>/dev/null || true
fi
exit "$rc"
}
trap cleanup EXIT INT TERM
for ((i=0; i<100; i++)); do
kill -0 "$svc_pid" 2>/dev/null || { echo "egress_services.py exited early. See $RUN_DIR/egress_services.log" >&2; exit 1; }
[[ -e "$RUN_DIR/egress_services.ready" ]] && break
sleep 0.05
done
[[ -e "$RUN_DIR/egress_services.ready" ]] || { echo "egress_services.py timed out" >&2; exit 1; }
# 3. Launch Linux 6.12 KVM guest attached ONLY to isolated tap0 (Unix sockets live on shared filesystem)
qemu-system-x86_64 \
-enable-kvm -machine q35 -cpu host -m 3072 -smp 2 -no-reboot -display none \
-serial "unix:$RUN_DIR/shell.sock,server=on,wait=off" \
-serial "unix:$RUN_DIR/hud.sock,server=on,wait=off" \
-monitor none \
-netdev tap,id=net0,ifname=tap0,script=no,downscript=no \
-device virtio-net-pci,netdev=net0,mac=52:54:00:77:00:02 \
-virtfs "local,path=$REPO_ROOT,mount_tag=workspace,security_model=none,id=jev" \
-drive "file=testbed/root.ext4,format=raw,if=virtio,snapshot=on" \
-kernel testbed/vmlinuz -initrd testbed/initrd \
-append "console=ttyS0 panic=1 quiet root=/dev/vda rw init=/jev-init lsm=lockdown,capability,landlock,yama,apparmor,bpf jev_job=egress jev_run=$RUN_NAME" \
>"$RUN_DIR/qemu.log" 2>&1 &
qemu_pid=$!
printf '%s\n' "$qemu_pid" > "$RUN_DIR/qemu.pid"
wait "$qemu_pid"