loaders: add YAML partition source with schema validation - #155
Open
Igor Opaniuk (igoropaniuk) wants to merge 4 commits into
Open
loaders: add YAML partition source with schema validation#155Igor Opaniuk (igoropaniuk) wants to merge 4 commits into
Igor Opaniuk (igoropaniuk) wants to merge 4 commits into
Conversation
The YAML partition source introduced in [1] needs a YAML parser and a schema validator at runtime. Declare PyYAML and jsonschema as install dependencies so pip pulls them in automatically. No code imports these yet; this only prepares the ground for the YAML loader. Build, lint, unit tests and the pinned checksum manifest are unaffected. [1] qualcomm-linux#124 Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
The Dependencies section still claimed the tool ran on the standard library alone. Update it to note the two runtime dependencies now declared in pyproject.toml (PyYAML and jsonschema) and that pip installs them automatically. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Introduce the structured YAML source format from [1] for a single storage device. loaders/yaml.py loads a `disk` mapping and `partitions` list, validates it against a packaged JSON Schema, and normalises it into the same LoadedSpec the .conf loader produces, so both formats emit byte-identical XML. Normalisation mirrors loaders/conf.py field for field: defaults are copied in the same key order, partition_size_in_kb is reused and the attribute bits are decoded identically. YAML booleans are rendered as lowercase "true"/"false" so they match the legacy strings. The schema enforces the YAML footgun mitigations: GUIDs and sizes must be quoted strings, unknown keys are rejected, and the disk type is constrained to the known storage classes. Register .yaml/.yml in the loaders dispatcher behind a late import so the .conf path never pays for PyYAML or jsonschema, and ship the schema as package data. [1] qualcomm-linux#124 Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Pin the load-bearing property that the YAML and .conf loaders produce the same LoadedSpec: an equivalence test against the real glymur-crd/nvme board, a synthetic multi-LUN spec exercising attribute bits, and an end-to-end assertion that both formats emit byte-identical XML through the shared emitter. Add schema-rejection cases for the documented footguns (unquoted all-digit GUID, unquoted size, unknown key, missing type-guid, malformed size, unknown disk type) and a non-mapping top-level document. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Igor Opaniuk (igoropaniuk)
requested review from
Dmitry Baryshkov (lumag),
Nicolas Dechesne (ndechesne) and
Viswanath Kraleti (vkraleti)
as code owners
August 6, 2026 08:49
Viswanath Kraleti (vkraleti)
approved these changes
Aug 10, 2026
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.
Second step of the partition-source rework [1], building on the loaders package: this adds the structured YAML input format for a single storage device.
The .conf line format cannot be validated: sizes are parsed by best-effort regex, GUIDs are bare strings, booleans are ad-hoc, and mistakes only surface when a device fails to boot. A structured, schema-validated source catches these errors at build time and is the foundation for everything that follows in [1] - shared partition groups, board variants, and multi-storage boards.
A new
loaders/yaml.pyloads a disk mapping plus partitions list, validates it against a packaged JSON Schema, and normalises it into the sameLoadedSpecthe.confloader produces - so both formats emit byte-identical XML, which the test suite pins with an equivalence test against a real board layout and an end-to-end XML comparison. The schema enforces the known YAML footguns up front: GUIDs and sizes must be quoted strings, unknown keys are rejected, disk types are constrained.PyYAMLandjsonschemabecome the project's first runtime dependencies; the dispatcher late-imports them, so the .conf path never pays for either.No board is migrated and nothing consumes YAML in the build yet: every generated artifact is unchanged, as CI proves via the pinned checksum manifest.
[1] #124