From c2eeba33360b0941ff2a89f44712e9212066f786 Mon Sep 17 00:00:00 2001 From: Bruce Ashfield Date: Thu, 12 Mar 2026 17:50:02 +0000 Subject: kernel: skip kcfg search path injection for kernels with kernel-cache The kcfg sysroot search path (type=kmeta) was being injected unconditionally, which caused fragment conflicts for linux-yocto kernels that already have their own kernel-cache meta branch. The injected search path would roll back fragments to an older set. Make the injection conditional and fix the root cause: - kernel_cache_feature() now checks SRC_URI for type=kmeta entries. Kernels with kernel-cache get short paths (e.g. cfg/container.scc) that resolve directly via the kernel-cache's search path. Kernels without kernel-cache get the sysroot-relative ../../ paths as before. - distro_cond_feature() now passes d.getVar('SRC_URI') instead of an empty string, so kernel_cache_feature() can actually see whether the kernel has a kernel-cache. - SRC_URI append and inject_kcfg_search_path prefunc skip when type=kmeta is already present. - Remove unused kernel_cache_cond_feature() which was the original conditional implementation but was never wired up. This restores the original design intent from commit 5c212911 ("allow conditional use of yocto-cfg-fragments"): kernel-cache is the first choice for fragment resolution, sysroot is the fallback. Signed-off-by: Bruce Ashfield --- .../linux/linux-yocto_virtualization.inc | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/recipes-kernel/linux/linux-yocto_virtualization.inc b/recipes-kernel/linux/linux-yocto_virtualization.inc index 8d14ce92..486e77ce 100644 --- a/recipes-kernel/linux/linux-yocto_virtualization.inc +++ b/recipes-kernel/linux/linux-yocto_virtualization.inc @@ -11,18 +11,24 @@ KERNEL_FEATURES:append = "${@bb.utils.contains('DISTRO_FEATURES', 'aufs', ' feat # Always add a local/layer fragment for easy debug and enabling of options SRC_URI += "file://extra-configs.cfg" -# Inject the kcfg sysroot root into the scc search path so compound .scc +# Inject the kcfg sysroot into the scc search path so compound .scc # files (like container.scc) can resolve their include directives. -# kernel-yocto.bbclass adds type=kmeta directories to -I includes via -# find_kernel_feature_dirs/feat_dirs. The prefunc replaces the placeholder -# directory with a symlink to the kcfg sysroot so that spp can resolve -# include directives within .scc files that reference other fragments -# by relative path (e.g. "include cfg/9p.scc" inside container.scc). +# Only needed for kernels that do NOT have a type=kmeta SRC_URI entry +# (i.e. no kernel-cache). The prefunc replaces this placeholder with +# a symlink to the kcfg sysroot only for non-kernel-cache kernels. +# For kernel-cache kernels the placeholder stays empty (harmless). SRC_URI:append = " file://kcfg-search-path;type=kmeta;destsuffix=kcfg-sysroot" python inject_kcfg_search_path() { import os, shutil + # Skip if the kernel has its own kmeta (kernel-cache) + src_uri = d.getVar('SRC_URI') + # Check for type=kmeta entries other than our own kcfg-search-path + for entry in src_uri.split(): + if 'type=kmeta' in entry and 'kcfg-search-path' not in entry: + return + unpackdir = d.getVar('UNPACKDIR') workdir = d.getVar('WORKDIR') search_dir = os.path.join(unpackdir, 'kcfg-sysroot') @@ -41,26 +47,20 @@ python inject_kcfg_search_path() { do_kernel_metadata[prefuncs] += "inject_kcfg_search_path" -# if the kernel-yocto meta-data routine automatically starts to add the -# recipe-sysroot-native, we can do away with this conditional, since all -# features will be found at the same relative offset from a search -# directory -def kernel_cache_cond_feature(src_uri,feature): - import re - kernel_cache = re.search("kernel-cache", src_uri ) - if kernel_cache: - return feature - - return "../../recipe-sysroot-native/kcfg/" + feature - -# no conditional, just use the yocto-kernel-cache addition, yes -# the src_uri isn't used, but we may need to check it in the future +# Return the correct path for a kernel configuration fragment. +# Kernels with their own kernel-cache (type=kmeta in SRC_URI) already +# have fragments on spp's search path, so we use short paths that +# resolve directly. Kernels without kernel-cache need the sysroot- +# relative path (which requires the kcfg-search-path injection above). def kernel_cache_feature(src_uri,feature): + for entry in src_uri.split(): + if 'type=kmeta' in entry and 'kcfg-search-path' not in entry: + return feature return "../../recipe-sysroot-native/kcfg/" + feature def distro_cond_feature(feature_fragment,distro_feature,d): import bb - feat = kernel_cache_feature("",feature_fragment) + feat = kernel_cache_feature(d.getVar('SRC_URI'),feature_fragment) return bb.utils.contains('DISTRO_FEATURES', distro_feature, ' ' + feat, ' ', d) # kept as a reference if we go back to a dynamically calculated -- cgit v1.2.3-54-g00ecf