feat: Kernel config validation tool#16224
Open
rlmenge wants to merge 6 commits intomicrosoft:3.0-devfrom
Open
Conversation
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
Contributor
There was a problem hiding this comment.
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_checkerPython package (schema models +check_configand interactiveadd_configCLI). - Added
azl3-os-required-kernel-configs.jsoncontaining 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 |
…OOT for all kernels
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a Python-based kernel config checker that validates kernel
.configfiles against a centralized JSON schema of required configurations. This catches unintentional config regressions during PR review.What this does
SPECS/kernel*/config*files change, checking them against the required config definitions.check_config.pychecks a.configfile against the schema, queries config values across all flavors/architectures, and supports interactive addition of new config requirements viaadd_config.py.Components
76c824ab5check_config.py,add_config.py, Pydantic schema, READMEc468da49b66007efbcazl3-os-required-kernel-configs.jsonwith all required config definitionsSchema structure
The JSON schema uses a default + overrides pattern:
Usage
Tool was tested on fork at PR: rlmenge#53