Skip to content

feat: Kernel config validation tool#16224

Open
rlmenge wants to merge 6 commits intomicrosoft:3.0-devfrom
rlmenge:rlmenge/config-checker-pr-review
Open

feat: Kernel config validation tool#16224
rlmenge wants to merge 6 commits intomicrosoft:3.0-devfrom
rlmenge:rlmenge/config-checker-pr-review

Conversation

@rlmenge
Copy link
Contributor

@rlmenge rlmenge commented Mar 18, 2026

Adds a Python-based kernel config checker that validates kernel .config files against a centralized JSON schema of required configurations. This catches unintentional config regressions during PR review.

What this does

  • Validates kernel configs on PR: A GitHub Actions workflow runs automatically when SPECS/kernel*/config* files change, checking them against the required config definitions.
  • Supports per-kernel overrides: A default set of 226 required configs applies to all kernels, with per-flavor overrides for kernel (8), kernel-64k (8), and kernel-hwe (16). Kernels without overrides in the JSON are skipped.
  • Provides CLI tools: check_config.py checks a .config file against the schema, queries config values across all flavors/architectures, and supports interactive addition of new config requirements via add_config.py.

Components

Commit Description
76c824ab5 Core tool: check_config.py, add_config.py, Pydantic schema, README
c468da49b GitHub Actions workflow for CI validation
66007efbc azl3-os-required-kernel-configs.json with all required config definitions

Schema structure

The JSON schema uses a default + overrides pattern:

  • default: configs required across all kernel flavors (226 configs, per-architecture values)
  • overrides: per-kernel adjustments (e.g., kernel enables BBR3)

Usage

# Check a config file
cd toolkit/scripts
python3 -m kernel_config_checker.check_config \
  ../../SPECS/kernel-hwe/config \
  kernel_config_checker/kernel_configs_json/azl3-os-required-kernel-configs.json \
  kernel-hwe x86_64

# Query a config across all flavors
python3 -m kernel_config_checker.check_config --check-all \
  kernel_config_checker/kernel_configs_json/azl3-os-required-kernel-configs.json \
  CONFIG_DXGKRNL

# Interactively add a new required config
python3 -m kernel_config_checker.add_config \
  kernel_config_checker/kernel_configs_json/azl3-os-required-kernel-configs.json

Tool was tested on fork at PR: rlmenge#53

rlmenge added 3 commits March 17, 2026 23:48
Add a Python-based kernel config checker that validates kernel .config
files against a JSON schema of required configurations. Includes:

- check_config.py: CLI tool to check configs, add new requirements
  interactively, and run bulk checks across all kernel flavors/arches
- schema/schema.py: Pydantic models for kernel config requirements
  with per-kernel override support
- schema/print_schema.py: Schema printer utility
- README.md: Usage documentation and examples

Uses Pydantic for validation and enum-based config values (y/n/m)
with proper serialization.
…idation

Add check-kernel-configs.yml workflow that runs the kernel config
checker against all kernel flavors (kernel, kernel-hwe, kernel-64k)
and architectures on PR changes. Uses subshell execution for reliable
working directory handling. Skips kernels without overrides in the
JSON schema.
Add azl3-os-required-kernel-configs.json containing required kernel
configuration values for Azure Linux 3. Includes per-kernel overrides
for kernel-hwe and kernel-64k flavors. Configs are sorted
alphabetically for maintainability.
… stale overrides

- Add CONFIG_CRYPTO_ARC4 and CONFIG_CRYPTO_DEV_BCM_SPU for arm64 FIPS crypto
- Remove stale arm64 overrides from kernel-hwe and kernel-64k
- Remove unnecessary arm64 'n' values from default configs
@rlmenge rlmenge marked this pull request as ready for review March 18, 2026 08:02
@rlmenge rlmenge requested a review from a team as a code owner March 18, 2026 08:02
@rlmenge rlmenge requested a review from Copilot March 18, 2026 08:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a Python-based kernel config validation tool (plus CI wiring) to detect regressions in SPECS/kernel*/config* by validating them against a centralized “required kernel configs” JSON schema.

Changes:

  • Added kernel_config_checker Python package (schema models + check_config and interactive add_config CLI).
  • Added azl3-os-required-kernel-configs.json containing default required configs plus per-kernel overrides.
  • Added a GitHub Actions workflow to run the checker automatically on PRs/pushes that touch kernel config files.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
toolkit/scripts/requirements.txt Adds pydantic dependency needed by the checker
toolkit/scripts/kernel_config_checker/schema/schema.py Defines Pydantic models + load/save helpers for the required-config JSON
toolkit/scripts/kernel_config_checker/schema/print_schema.py Utility to emit generated JSON Schema for the models
toolkit/scripts/kernel_config_checker/schema/init.py Marks schema directory as a Python package
toolkit/scripts/kernel_config_checker/kernel_configs_json/azl3-os-required-kernel-configs.json Centralized required kernel config definitions (default + overrides)
toolkit/scripts/kernel_config_checker/check_config.py Main config parsing + validation CLI and query helper
toolkit/scripts/kernel_config_checker/add_config.py Interactive helper to add new required-config entries safely
toolkit/scripts/kernel_config_checker/init.py Marks checker directory as a Python package
toolkit/scripts/kernel_config_checker/README.md Usage and schema documentation for the tool
.github/workflows/check-kernel-configs.yml CI workflow to validate changed kernel configs during PRs/pushes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

# via -r requirements.in
validators==0.20.0
# via -r requirements.in
pydantic>=2.0.0
Comment on lines +55 to +67
def parse_kernel_config(config_path: Path) -> Dict[str, str]:
"""Parse a Linux kernel .config file."""
config = {}
with open(config_path, "r") as f:
for line in f:
line = line.strip()
if line.startswith("#") and "is not set" in line:
config_name = line.split()[1]
config[config_name] = "n"
elif line and not line.startswith("#") and "=" in line:
key, value = line.split("=", 1)
config[key] = value
return config
rlmenge added 2 commits March 18, 2026 15:14
…add_config

- Validate and normalize architecture argument (reject typos, map aarch64 to arm64)
- Validate config name is non-empty and alphanumeric
- Require non-empty justification for auditability
- Detect duplicate config entries and prompt before replacing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.0-dev PRs Destined for AzureLinux 3.0 Tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants