pub fn kernel_list(json: bool) -> Result<()>Expand description
List cached kernel images.
§JSON output schema (--json)
{
"current_ktstr_kconfig_hash": "abc123...",
"active_prefixes_fetch_error": null,
"entries": [
{
"key": "7.1.0-rc2",
"path": "/path/to/cache/entry",
"version": "7.1.0-rc2",
"source": { "type": "tarball" },
"arch": "x86_64",
"built_at": "2026-04-15T12:34:56Z",
"ktstr_kconfig_hash": "abc123...",
"extra_kconfig_hash": null,
"kconfig_status": "matches",
"eol": false,
"config_hash": "def456...",
"image_name": "bzImage",
"image_path": "/path/to/cache/entry/bzImage",
"has_vmlinux": true,
"vmlinux_stripped": true
},
{
"key": "6.12.0-broken",
"path": "/path/to/cache/broken-entry",
"error": "metadata.json schema drift: missing field `source` at line 1 column 21",
"error_kind": "schema_drift"
}
]
}Wrapper fields:
current_ktstr_kconfig_hash: hex digest of the kconfig fragment the running binary was built against, so consumers can detect entries that were built with a different fragment.active_prefixes_fetch_error:nullon success, human-readable error string on failure to fetch the active kernel-series list from kernel.org. When non-null,eolannotation is disabled for the run (no series data to compare against) and every entry’seolisfalseregardless of actual support status — so consumers must check this field before trustingeol.entries: heterogeneous array; each element is either a valid entry (object with the full field set) or a corrupt entry (object withkey,path,error, anderror_kind). Corrupt entries have a structurally different shape — consumers should detect the"error"key and branch.
Entry fields (valid entries):
kconfig_status: one of"matches","stale", or"untracked"(the Display forms ofcache::KconfigStatus).matchesmeans the entry’sktstr_kconfig_hashequalscurrent_ktstr_kconfig_hash;stalemeans they differ;untrackedmeans the entry has no recorded kconfig hash (pre-dates kconfig hash tracking).extra_kconfig_hash: CRC32 (8 hex chars, lowercase) of the user--extra-kconfigfragment as raw bytes (no canonicalization), ornullwhen the entry was built without--extra-kconfig. Cache keys grow fromkc{baked}tokc{baked}-xkc{extra}when extras are present; this field stores thexkcsegment sokernel listis self-describing for entries that carry user modifications. Independent ofkconfig_status— an entry can match the baked-in hash AND carry a non-null extras hash.eol:trueiff the entry’s version series does not appear in the active-prefix list. Only meaningful whenactive_prefixes_fetch_errorisnull.has_vmlinux: whether the cache entry includes the uncompressedvmlinux(needed for DWARF-driven probes); whenfalse, only the compressedimage_pathis available.vmlinux_stripped: whether the cached vmlinux came from a successful strip pass (true) or the raw-fallback path (false). Afalsehere indicates the strip pipeline errored on this kernel and the unstripped bytes were copied instead — the entry still works but carries a large on-disk payload that signals a parseability regression worth investigating. Alwaysfalsewhenhas_vmlinuxisfalse.source: tagged object (serde internally tagged on"type"). Variants:{"type": "tarball"},{"type": "git", "git_hash": ?, "ref": ?},{"type": "local", "source_tree_path": ?, "git_hash": ?}. Variant-specific fields are nullable — consumers must dispatch on"type"before reading them. Seecache::KernelSource.
Entry fields (corrupt entries):
-
error: human-readable reason fromcache::read_metadata, prefixed by failure class so programmatic consumers can branch onstarts_withwithout parsing the free-form tail. Prefixes:"metadata.json missing"— file absent (not a cache entry)."metadata.json unreadable: ..."— I/O error onfs::read_to_stringother than ENOENT (e.g. EISDIR, permission)."metadata.json schema drift: ..."— JSON parsed but does not match theKernelMetadatashape (serde_jsonCategory::Data). Typical cause: older cache from a ktstr whose schema has since changed."metadata.json malformed: ..."— not valid JSON at all (serde_jsonCategory::Syntax)."metadata.json truncated: ..."— JSON ends mid-value (serde_jsonCategory::Eof), e.g. a partially-written metadata from a crashedstore()."metadata.json parse error: ..."— fallback for an unexpectedCategory::Iofromfrom_str; does not fire on the current serde_json version but kept as a defense-in-depth fallback so the field is never absent."image file <name> missing from entry directory"— metadata parsed cleanly but the declared image file is gone (partial download, manual deletion, failed strip+rename).
The example above shows the schema-drift case; consumers that treat corrupt entries as a single category can key on the
"error"key alone. -
error_kind: machine-readable classification of the failure mode — a stable snake_case identifier CI scripts can dispatch on without parsing the free-formerror. Values:"missing","unreadable","schema_drift","malformed","truncated","parse_error","image_missing", and"unknown"as a defensive fallback for a future producer prefix that has not yet been taught to the classifier. Always present on corrupt entries; always absent on valid entries. Seecrate::cache::ListedEntry::error_kindfor the classifier contract.