analyze: introduce cpu-features command

This may be useful when configuring the ConditionCPUFeature= setting.
This commit is contained in:
Yu Watanabe
2026-09-23 12:51:26 +09:00
parent ef3e0ff7bb
commit 724d18a22a
11 changed files with 203 additions and 2 deletions
+12
View File
@@ -56,6 +56,10 @@ __get_architectures() {
systemd-analyze --no-legend --no-pager architectures 2>/dev/null | { while read -r a b; do echo " $a"; done; }
}
__get_cpu_features() {
systemd-analyze --no-legend --no-pager cpu-features 2>/dev/null | { while read -r a b; do echo " $a"; done; }
}
__get_filesystem_sets() {
local line
systemd-analyze filesystems --no-pager 2>/dev/null | while IFS= read -r line; do
@@ -91,6 +95,7 @@ _systemd_analyze() {
[DLOPEN_METADATA]='dlopen-metadata'
[PLOT]='plot'
[ARCHITECTURES]='architectures'
[CPU_FEATURES]='cpu-features'
[FDSTORE]='fdstore'
[CAPABILITY]='capability'
[TRANSIENT_SETTINGS]='transient-settings'
@@ -250,6 +255,13 @@ _systemd_analyze() {
comps=$( __get_architectures )
fi
elif __contains_word "$verb" ${VERBS[CPU_FEATURES]}; then
if [[ $cur = -* ]]; then
comps='--help --version --no-pager --json=off --json=pretty --json=short --no-legend'
else
comps=$( __get_cpu_features )
fi
elif __contains_word "$verb" ${VERBS[FDSTORE]}; then
if [[ $cur = -* ]]; then
comps='--help --version --system --user --global -H --host -M --machine --no-pager --json=off --json=pretty --json=short --root --image'
+8
View File
@@ -52,6 +52,13 @@
_describe -t architectures 'architectures' _architectures || compadd "$@"
}
(( $+functions[_systemd-analyze_cpu-features] )) ||
_systemd-analyze_cpu-features() {
local -a _features
_features=( $(systemd-analyze --quiet --no-pager --no-legend cpu-features 2>/dev/null | { while read -r a b; do echo " $a"; done; }) )
_describe -t features 'cpu features' _features || compadd "$@"
}
(( $+functions[_systemd-analyze_plot] )) ||
_systemd-analyze_plot() {
local -a _options
@@ -95,6 +102,7 @@
'has-tpm2:Report whether TPM2 support is available'
'transient-settings:List transient settings for unit types'
'architectures:List known architectures'
'cpu-features:List known CPU features'
'smbios11:List strings passed via SMBIOS Type #11'
'chid:List local CHIDs'
'compare-versions:Compare two version strings'