mirror of
https://github.com/fosslinux/live-bootstrap.git
synced 2026-03-23 11:36:32 +01:00
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.
65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
|
|
# SPDX-FileCopyrightText: 2023 Samuel Tyler <samuel@samuelt.me>
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
"""
|
|
Contains a class that represents a target directory
|
|
"""
|
|
|
|
import enum
|
|
import os
|
|
|
|
from lib.utils import mount, create_disk
|
|
|
|
class TargetType(enum.Enum):
|
|
"""Different types of target dirs we can have"""
|
|
NONE = 0
|
|
TMPFS = 1
|
|
|
|
class Target:
|
|
"""
|
|
Represents a target directory
|
|
"""
|
|
|
|
_disks = {}
|
|
_mountpoints = {}
|
|
|
|
def __init__(self, path="target"):
|
|
self.path = os.path.abspath(path)
|
|
self._type = TargetType.NONE
|
|
|
|
if not os.path.exists(self.path):
|
|
os.mkdir(self.path)
|
|
|
|
def tmpfs(self, size="8G"):
|
|
"""Mount a tmpfs"""
|
|
print(f"Mounting tmpfs on {self.path}")
|
|
mount("tmpfs", self.path, "tmpfs", f"size={size}")
|
|
self._type = TargetType.TMPFS
|
|
|
|
# pylint: disable=too-many-arguments,too-many-positional-arguments
|
|
def add_disk(self,
|
|
name,
|
|
size="16G",
|
|
filesystem="ext4",
|
|
tabletype="msdos",
|
|
bootable=False,
|
|
mkfs_args=None):
|
|
"""Add a disk"""
|
|
disk_path = os.path.join(self.path, f"{name}.img")
|
|
create_disk(disk_path,
|
|
tabletype,
|
|
filesystem,
|
|
size,
|
|
bootable,
|
|
mkfs_args)
|
|
self._disks[name] = disk_path
|
|
|
|
def get_disk(self, name):
|
|
"""Get the path to a device of a disk"""
|
|
return self._disks.get(name)
|
|
|
|
def add_existing_disk(self, name, path):
|
|
"""Register an existing disk image path."""
|
|
self._disks[name] = os.path.abspath(path)
|