Skip to content

fix(os/yocto): gate dstack.cfg on the built kernel config - #1166

Open
kvinwang wants to merge 2 commits into
nextfrom
fix/yocto-gate-dstack-kernel-cfg
Open

fix(os/yocto): gate dstack.cfg on the built kernel config#1166
kvinwang wants to merge 2 commits into
nextfrom
fix/yocto-gate-dstack-kernel-cfg

Conversation

@kvinwang

@kvinwang kvinwang commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Why

check-kernel-config.sh exists because, in its own words, "a fragment line is a wish, not a guarantee" — kconfig silently drops a request whose dependencies are not met, and silently clamps a tristate.

The mkosi backend runs it over its whole fragment. The yocto backend ran it over dstack-docker.cfg only:

"$REPO_ROOT/os/common/scripts/check-kernel-config.sh" \
    "$KERNEL_CONFIG_FILE" \
    ".../dstack-docker.cfg"

That left dstack.cfg's 73 assertions completely unchecked.

Why it was exempt

Three of them are false. Compared against a real built .config:

✗ CONFIG_HOTPLUG_CPU   fragment=n   built=y
✗ CONFIG_SCSI          fragment=n   built=y
✗ CONFIG_INPUT         fragment=n   built=y

They lose to machine-level KERNEL_FEATURESlinux-yocto%.bbappend appends features/scsi/disk.scc for the dstack machine, and the machine's own feature set brings the other two. The fragment claims the kernel has them off; it does not.

Three lines that could not be satisfied kept the other seventy unverified along with them. That is a bad trade, and it is the whole reason the exemption existed.

What changed

Drop the three, gate the file. The fragment now says only what the build actually does, and every remaining line is checked before anything ships.

Why this got more urgent

The sixteen =n lines added in #1160 went into this same file. They were verified by hand with bitbake -c configure, but nothing stopped a later KERNEL_FEATURES addition from quietly pulling one of those drivers back while the fragment still claimed it was off — which is exactly the state CONFIG_SCSI is in today. The gate is what turns those sixteen from a one-time check into an invariant.

Not addressed here

Whether the yocto image can actually drop SCSI. The mkosi guest kernel does — verified in #1160, CONFIG_SCSI=n survives its olddefconfig — so the two guest kernels genuinely differ on it, along with CONFIG_INPUT.

Settling that needs a boot test on GCP and AWS, where the root disk may be virtio-scsi rather than virtio-blk. Guessing from a build that cannot boot is how you turn a documentation problem into an outage, so it belongs in its own change. The fragment carries a comment saying so.

Testing

Against the real built .config from bitbake -c configure virtual/kernel:

case result
both fragments, as committed exit 0
CONFIG_SCSI=n put back wanted CONFIG_SCSI=n, got CONFIG_SCSI=y → exit 1
any other force-enabled symbol asserted off exit 1
restored exit 0

bash -n and shellcheck -x -P SCRIPTDIR clean on export-artifacts.sh (note os/yocto is excluded from the repo's shellcheck hook, so this was run by hand).

check-kernel-config.sh exists because a kconfig fragment line is a wish, not
a guarantee: kconfig silently drops a request whose dependencies are not met
and silently clamps a tristate. The mkosi backend runs it over its whole
fragment. The yocto backend ran it over dstack-docker.cfg only, leaving
dstack.cfg's seventy-odd assertions unchecked.

The reason was three of those assertions being false. CONFIG_SCSI,
CONFIG_INPUT and CONFIG_HOTPLUG_CPU lose to machine-level KERNEL_FEATURES --
features/scsi/disk.scc is appended for the dstack machine and the machine's
own feature set brings the other two -- so the built kernel has all three
enabled while the fragment claims otherwise. Three lines that could not be
satisfied kept the other seventy unverified along with them, which is a bad
trade.

Drop the three and gate the file. The fragment now says only what the build
actually does, and every remaining line is checked before anything ships.

This matters more than it did last week: the sixteen =n lines added in "drop
guest kernel drivers no CVM can reach" went into this same file. They were
verified by hand with bitbake -c configure, but nothing stopped a later
KERNEL_FEATURES addition from quietly pulling one of those drivers back while
the fragment still claimed it was off -- exactly the state CONFIG_SCSI is in
today.

Not addressed here: whether the yocto image can actually drop SCSI. The mkosi
guest kernel does, verified, so the two guest kernels genuinely differ on it.
Settling that needs a boot test on GCP and AWS, where the root disk may be
virtio-scsi rather than virtio-blk, so it belongs in its own change rather
than being guessed at from a build that cannot boot.

Verified against the real built .config: the gate passes with both fragments,
and fails as it should when CONFIG_SCSI=n is put back or when any other
force-enabled symbol is asserted off.
Copilot AI lite review requested due to automatic review settings September 2, 2026 09:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrow, aligns with the existing multi-fragment checker contract, and the fragment adjustments are consistent with the stated goal of making Yocto kernel assertions enforceable.

Pull request overview

This PR brings the Yocto guest-kernel pipeline in line with the mkosi backend by ensuring the full Yocto kernel fragment set is verified against the built kernel .config before artifacts are exported/shipped.

Changes:

  • Gate os/yocto/.../dstack.cfg with check-kernel-config.sh during Yocto artifact export (in addition to the already-gated dstack-docker.cfg).
  • Remove three =n assertions (CONFIG_HOTPLUG_CPU, CONFIG_SCSI, CONFIG_INPUT) from the Yocto dstack.cfg fragment because they do not match the kernel produced by the Yocto machine configuration.
  • Add an explanatory note to dstack.cfg documenting why those assertions are intentionally absent and why dropping them enables gating the rest of the fragment.
File summaries
File Description
os/yocto/scripts/export-artifacts.sh Extend kernel-config gating to include both Yocto kernel fragments during artifact export.
os/yocto/layers/meta-dstack/recipes-kernel/linux/files/dstack.cfg Remove unsatisfied assertions and document why those symbols are intentionally not asserted in Yocto.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread os/yocto/scripts/export-artifacts.sh Outdated
The comment attributed all three to machine-level KERNEL_FEATURES. That is
only true of one of them, and only indirectly.

HOTPLUG_CPU is def_bool y with no prompt, so no fragment can set it anywhere
-- the mkosi guest kernel has it enabled too and simply never asserted
otherwise. INPUT has a prompt only under EXPERT, which this machine does not
set, so it falls back to default y, and CONFIG_VT=y selects it as well; mkosi
turns it off only because it has EXPERT=y and VT=n together. SCSI is the one
KERNEL_FEATURES case, and even there the feature sets CONFIG_BLK_DEV_SD=y,
which depends on SCSI and drags it in.

Getting this right matters for the follow-up: two of the three cannot be
fixed by touching KERNEL_FEATURES at all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants