live-bootstrap/steps/improve/import_payload.sh
vxtls f30c20b7be fix(kernel-bootstrap): restore kexec-fiwix baseline and move post-fiwix distfiles into raw payload import path
The instability was not caused by kexec-fiwix logic itself but by oversized early-stage payload pressure in kernel-bootstrap mode.
When too many distfiles are injected before the Fiwix handoff, the early memory/file-table assumptions become fragile and KVM can fail during transition.
This change restores kexec-fiwix.c to the known baseline (matching commit 984b8322...) and fixes the actual failure mode by moving non-early distfiles out of the initial image.

What changed:
- Keep only bootstrap-required distfiles in early init image.
- Generate a separate raw payload image (LBPAYLD1 format) for the remaining distfiles.
- Attach payload image as an extra disk in QEMU/bare-metal kernel-bootstrap flow.
- Add a dedicated C89/tcc-compatible importer (payload-import) that scans payload disks and copies files into /external/distfiles after jump: fiwix.
- Insert improve: import_payload immediately after jump: fiwix so the full distfile set is restored before heavy build steps continue.
- Add PAYLOAD_REQUIRED config gating so this behavior is active only in kernel-bootstrap paths that need it.

Why this design:
- Preserves minimal early environment assumptions (no dependency on full shell utilities for the copy operation itself).
- Avoids adding filesystem-construction toolchain dependencies for the payload container by using a simple length-prefixed raw format.
- Keeps bare-metal and QEMU behavior aligned: both can carry full build artifacts without overloading the early handoff stage.
- Leaves kexec-fiwix behavior deterministic and auditable by reverting to a known-good baseline implementation.
2026-03-01 13:45:16 -05:00

22 lines
589 B
Bash

#!/bin/sh
#
# SPDX-FileCopyrightText: 2026 live-bootstrap contributors
# SPDX-License-Identifier: MIT
set -ex
if match x${PAYLOAD_REQUIRED} xTrue; then
mkdir -p /dev
test -b /dev/sda || mknod -m 600 /dev/sda b 8 0
test -b /dev/sdb || mknod -m 600 /dev/sdb b 8 16
test -b /dev/sdc || mknod -m 600 /dev/sdc b 8 32
test -b /dev/sdd || mknod -m 600 /dev/sdd b 8 48
mkdir -p /external/distfiles
if test -f /external/distfiles/.payload_imported; then
exit 0
fi
payload-import /external/distfiles
touch /external/distfiles/.payload_imported
fi