Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Raphael Ning <raphning@gmail.com>
To: Simon Horman <horms@verge.net.au>
Cc: kexec@lists.infradead.org, Raphael Ning <raphning@gmail.com>,
	Julien Grall <julien@xen.org>, Hongyan Xia <hx242@xen.org>,
	Raphael Ning <raphning@amazon.com>
Subject: [PATCH] kexec: Make --status work with normal kexec images
Date: Tue, 23 Mar 2021 17:50:07 +0000	[thread overview]
Message-ID: <20210323175007.3069-1-raphning@gmail.com> (raw)

From: Raphael Ning <raphning@amazon.com>

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 <raphning@amazon.com>
---
 kexec/kexec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kexec/kexec.c b/kexec/kexec.c
index ffc689ac3d7f..0c4b9619bfd7 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -1336,6 +1336,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;
@@ -1393,6 +1394,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;
@@ -1512,7 +1514,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;
-- 
2.23.3


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

             reply	other threads:[~2021-03-23 17:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 17:50 Raphael Ning [this message]
2021-04-02 10:01 ` [PATCH] kexec: Make --status work with normal kexec images Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210323175007.3069-1-raphning@gmail.com \
    --to=raphning@gmail.com \
    --cc=horms@verge.net.au \
    --cc=hx242@xen.org \
    --cc=julien@xen.org \
    --cc=kexec@lists.infradead.org \
    --cc=raphning@amazon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox