mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-21 03:36:35 +00:00
a5efd45168
t1→t2 hypervisor: 3224 ms → 264 ms (12×). 128 MiB guest now boots
cleanly without OOM, reverting the temporary 512 MiB bump.
Root causes:
1. build-microvm-image.sh staged the entire chroot into the cpio
without dropping /boot, embedding a duplicate vmlinuz, Alpine's
stock initramfs-virt, System.map, and a "boot → ." symlink loop
(~25 MiB). Decompression peak exceeded 128 MiB. Strip /boot after
the kernel is copied out, before the cpio. Initramfs drops from
31 MiB → 11 MiB (53 MiB → 28 MiB uncompressed); total artifact
42 MiB → 22 MiB.
2. vm/lifecycle.go burned 3 s of fixed sleep on every direct-boot
launch: 2 s nbdkit pre-exec wait (no nbdkit on direct-boot) and
1 s post-fork settle (QEMU binds QMP within ~10 ms when there is
no firmware, ROM, or block layer). Both extracted to
directBoot-aware helpers — nbdkitPreExecWait collapses to 0, and
qemuStartSettleWait to 50 ms.
3. KernelCmdline only carried `console=ttyS0 virtio_mmio.device=…`.
Added boot-time perf flags: quiet loglevel=3 (silence printk over
115200-baud isa-serial), mitigations=off (KVM guest on trusted
host, single-tenant LB workload), tsc=reliable, no_timer_check,
reboot=t, i8042.{nopnp,noaux,nokbd} (microvm has no PS/2).
4. init.sh dropped modprobe virtio_mmio (built-in:
CONFIG_VIRTIO_MMIO=y) and tightened polling: fw_cfg/iface waits go
from 10 × 200 ms (up to 2 s) to 5 × 20 ms (up to 100 ms).
Phase 2 gates:
- t1→t2 ≤ 300 ms ✅ 264 ms / 281 ms
- artifact ≤ 50 MiB ✅ 22 MiB (gate already in build script)
- ELBv2 e2e green ✅ 32/33 (pre-existing client-VM failure,
unrelated to microvm path)
57 lines
1.8 KiB
Bash
Executable File
57 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
mount -t proc proc /proc
|
|
mount -t sysfs sys /sys
|
|
mount -t devtmpfs dev /dev
|
|
|
|
# virtio_mmio is built-in (CONFIG_VIRTIO_MMIO=y) so virtio-net devices are
|
|
# already enumerated by the time PID 1 runs — no modprobe needed.
|
|
# qemu_fw_cfg and virtio_net are =m in stock Alpine linux-virt, so load them.
|
|
modprobe qemu_fw_cfg 2>/dev/null || modprobe fw_cfg_sysfs 2>/dev/null || true
|
|
modprobe virtio_net 2>/dev/null || true
|
|
|
|
for i in 1 2 3 4 5; do
|
|
[ -f /sys/firmware/qemu_fw_cfg/by_name/opt/spinifex/netcfg/raw ] && break
|
|
sleep 0.02
|
|
done
|
|
|
|
if [ ! -f /sys/firmware/qemu_fw_cfg/by_name/opt/spinifex/netcfg/raw ]; then
|
|
echo "[init] FATAL: fw_cfg netcfg not available" >&2
|
|
exit 1
|
|
fi
|
|
|
|
. /sys/firmware/qemu_fw_cfg/by_name/opt/spinifex/netcfg/raw
|
|
|
|
for n in 0 1 2 3 4 5; do
|
|
eval mac=\$NIC${n}_MAC
|
|
[ -z "$mac" ] && continue
|
|
|
|
iface=""
|
|
for attempt in 1 2 3 4 5; do
|
|
iface=$(ip -o link | awk -v m="$mac" 'tolower($0) ~ tolower(m) {print $2}' | tr -d :)
|
|
[ -n "$iface" ] && break
|
|
sleep 0.02
|
|
done
|
|
|
|
if [ -z "$iface" ]; then
|
|
echo "[init] WARNING: no interface found for MAC $mac (NIC$n), skipping" >&2
|
|
continue
|
|
fi
|
|
|
|
eval cidr=\$NIC${n}_CIDR
|
|
eval gw=\$NIC${n}_GW
|
|
eval default=\$NIC${n}_DEFAULT
|
|
eval rdst=\$NIC${n}_ROUTE_DST
|
|
eval rvia=\$NIC${n}_ROUTE_VIA
|
|
|
|
ip link set "$iface" up
|
|
[ -n "$cidr" ] && ip addr add "$cidr" dev "$iface"
|
|
[ "$default" = "1" ] && [ -n "$gw" ] && ip route add default via "$gw" dev "$iface"
|
|
[ -n "$rdst" ] && [ -n "$rvia" ] && ip route add "$rdst" via "$rvia" dev "$iface"
|
|
done
|
|
|
|
cp /sys/firmware/qemu_fw_cfg/by_name/opt/spinifex/lb-agent-env/raw /etc/conf.d/lb-agent
|
|
mkdir -p /etc/ssl/certs
|
|
cp /sys/firmware/qemu_fw_cfg/by_name/opt/spinifex/ca-cert/raw /etc/ssl/certs/ca-certificates.crt
|
|
|
|
exec /sbin/init
|