From 4b97ff97852832b4856f76827df2d53d34baae59 Mon Sep 17 00:00:00 2001 From: Raphael Ning Date: Tue, 23 Mar 2021 17:50:07 +0000 Subject: kexec: Make --status work with normal kexec images According to kexec(8) manpage, --status (-S) works with both normal kexec (loaded by -l) and crash kernel (loaded by -p) image types, and defaults to the latter. However, the implementation does not match the description: `kexec -l -S` queries the -p image type as if -l were not specified. This is because there is no internal flag defined for the normal kexec type, and -S treats the zero flag as the trigger for the default behaviour (-p). Fix that by making sure the default behaviour for -S is not applied when the -l option is present. Signed-off-by: Raphael Ning Signed-off-by: Simon Horman --- kexec/kexec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kexec/kexec.c b/kexec/kexec.c index b4431ef1..f63b36b7 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -1337,6 +1337,7 @@ static void print_crashkernel_region_size(void) int main(int argc, char *argv[]) { + int has_opt_load = 0; int do_load = 1; int do_exec = 0; int do_load_jump_back_helper = 0; @@ -1394,6 +1395,7 @@ int main(int argc, char *argv[]) do_exec = 1; break; case OPT_LOAD: + has_opt_load = 1; do_load = 1; do_exec = 0; do_shutdown = 0; @@ -1513,7 +1515,7 @@ int main(int argc, char *argv[]) do_sync = 0; if (do_status) { - if (kexec_flags == 0) + if (kexec_flags == 0 && !has_opt_load) kexec_flags = KEXEC_ON_CRASH; do_load = 0; do_reuse_initrd = 0; -- cgit 1.2.3-korg